C++基于對話框的程序的框架實(shí)例
本文實(shí)例講述了C++基于對話框的程序的框架。分享給大家供大家參考。具體如下:
resource.cpp源文件如下:
CMyApp theApp;
BOOL CMyApp::InitInstance()
{
CMainDialog dlg;
m_pMainWnd = &dlg; //給m_pMainWnd 主窗口
dlg.DoModal();
return FALSE; //不進(jìn)入消息循環(huán)
}
BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_MESSAGE(WM_CUTTERSTART, OnCutterStart) //自定義消息
END_MESSAGE_MAP()
//CMainDialog
CMainDialog::CMainDialog(CWnd* pParentWnd):CDialog(IDD_MAIN, pParentWnd)
{
}
BOOL CMainDialog::OnInitDialog( )
{
CDialog::OnInitDialog();
return TRUE;
}
void CMainDialog::OnStop()
{
MessageBox("OnStop");
}
long CMainDialog::OnCutterStart(WPARAM wParam, LPARAM lParam) //處理自定義消息
{
MessageBox("OnCutterStart");
return 0;
}
resource.h頭文件如下:
#define WM_CUTTERSTART WM_USER+100
//CMyApp
class CMyApp:public CWinApp
{
public:
BOOL InitInstance();
};
//CMyDialog
class CMainDialog:public CDialog
{
public:
CMainDialog(CWnd* pParentWnd = NULL);
protected:
virtual BOOL OnInitDialog( );
afx_msg void OnStop();
afx_msg long OnCutterStart(WPARAM wParam, LPARAM lParam); //處理自定義消息的聲明
DECLARE_MESSAGE_MAP()
};
希望本文所述對大家的C++程序設(shè)計(jì)有所幫助。
上一篇:Visual C++中Tab View的多種實(shí)現(xiàn)方法
欄 目:C語言
下一篇:C++計(jì)算ICMP頭的校驗(yàn)和實(shí)例
本文標(biāo)題:C++基于對話框的程序的框架實(shí)例
本文地址:http://www.jygsgssxh.com/a1/Cyuyan/3234.html
您可能感興趣的文章
- 04-02c語言沒有round函數(shù) round c語言
 - 01-10深入理解C++中常見的關(guān)鍵字含義
 - 01-10使用C++實(shí)現(xiàn)全排列算法的方法詳解
 - 01-10c++中inline的用法分析
 - 01-10用C++實(shí)現(xiàn)DBSCAN聚類算法
 - 01-10全排列算法的非遞歸實(shí)現(xiàn)與遞歸實(shí)現(xiàn)的方法(C++)
 - 01-10C++大數(shù)模板(推薦)
 - 01-10淺談C/C++中的static與extern關(guān)鍵字的使用詳解
 - 01-10深入C/C++浮點(diǎn)數(shù)在內(nèi)存中的存儲方式詳解
 - 01-10基于atoi()與itoa()函數(shù)的內(nèi)部實(shí)現(xiàn)方法詳解
 


閱讀排行
本欄相關(guān)
- 04-02c語言函數(shù)調(diào)用后清空內(nèi)存 c語言調(diào)用
 - 04-02func函數(shù)+在C語言 func函數(shù)在c語言中
 - 04-02c語言的正則匹配函數(shù) c語言正則表達(dá)
 - 04-02c語言用函數(shù)寫分段 用c語言表示分段
 - 04-02c語言中對數(shù)函數(shù)的表達(dá)式 c語言中對
 - 04-02c語言編寫函數(shù)冒泡排序 c語言冒泡排
 - 04-02c語言沒有round函數(shù) round c語言
 - 04-02c語言分段函數(shù)怎么求 用c語言求分段
 - 04-02C語言中怎么打出三角函數(shù) c語言中怎
 - 04-02c語言調(diào)用函數(shù)求fibo C語言調(diào)用函數(shù)求
 


