WEB开发网
开发学院软件开发VC Visual C++ MFC简明教程(3) 阅读

Visual C++ MFC简明教程(3)

 2010-03-28 20:34:45 来源:WEB开发网   
核心提示:CStatic文本的外观下面的代码对于理解CStatic是有帮助的,它与上一讲中介绍的代码类似,Visual C++ MFC简明教程(3)(3),但是修改了CStatic的建立部分,//static1.cpp#include// Declare the application classclass CTestApp :

CStatic文本的外观

下面的代码对于理解CStatic是有帮助的。它与上一讲中介绍的代码类似,但是修改了CStatic的建立部分。

//static1.cpp
#include
// Declare the application class
class CTestApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
// Create an instance of the application class
CTestApp TestApp;
// Declare the main window class
class CTestWindow : public CFrameWnd
{
CStatic* cs;
public:
CTestWindow();
};
// The InitInstance function is called
// once when the application first executes
BOOL CTestApp::InitInstance()
{
m_pMainWnd = new CTestWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
// The constructor for the window class
CTestWindow::CTestWindow()
{
CRect r;
// Create the window itself
Create(NULL,
"CStatic Tests",
WS_OVERLAPPEDWINDOW,
CRect(0,0,200,200));
// Get the size of the client rectangle
GetClientRect(&r);
r.InflateRect(-20,-20);
// Create a static label
cs = new CStatic();
cs->Create("hello world",
WS_CHILD|WS_VISIBLE|WS_BORDER|SS_CENTER,
r,
this);
}

下面是窗口构造函数加上了行编号:

CTestWindow::CTestWindow()
{
CRect r;
// Create the window itself
1 Create(NULL,
"CStatic Tests",
WS_OVERLAPPEDWINDOW,
CRect(0,0,200,200));
// Get the size of the client rectangle
2 GetClientRect(&r);
3 r.InflateRect(-20,-20);
// Create a static label
4 cs = new CStatic();
5 cs->Create("hello world",
WS_CHILD|WS_VISIBLE|WS_BORDER|SS_CENTER,
r,
this);
}

上一页  1 2 3 4 5  下一页

Tags:Visual MFC 简明教程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接