MFC-画面表示

#include <afxwin.h>
 
 
//クラス定義(ヘッダファイル記載が望ましい)
// アプリケーションのクラス。
class CMyApp : public CWinApp
{
public:
    virtual BOOL InitInstance();
};
 
// CMainFrame クラスのインターフェイス
class CMyWindow : public CFrameWnd
{
public:
    CMyWindow();
protected:
	afx_msg void OnPaint();
	DECLARE_MESSAGE_MAP()
};
//クラス定義
 
 
CMyApp MyApp;
 
/////////////////////////////////
//CMyAppメンバ関数
 
BOOL CMyApp::InitInstance()
{
    m_pMainWnd = new CMyWindow();
    m_pMainWnd->ShowWindow(m_nCmdShow);
    m_pMainWnd->UpdateWindow();
    return TRUE;
}
 
/////////////////////////////////
//CMyAppメンバ関数とメッセージマップ
 
BEGIN_MESSAGE_MAP(CMyWindow,CFrameWnd)
	ON_WM_PAINT ()
END_MESSAGE_MAP ()
 
 
CMyWindow::CMyWindow()
{
    Create(NULL, TEXT("sample"), WS_OVERLAPPEDWINDOW);
}
 
void CMyWindow::OnPaint()
{
	CPaintDC dc (this);
 
	CRect rect;
	GetClientRect(&rect);
 
	dc.DrawText(TEXT("Hello World"),-1,&rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
最終更新:2009年04月17日 15:54