C++基于對話框的程序的框架實(shí)例
更新時(shí)間:2014年10月15日 16:41:42 投稿:shichen2014
這篇文章主要介紹了C++基于對話框的程序的框架,以實(shí)例形式講述了C++對話框程序框架,有助于深入理解基于C++的Windows程序設(shè)計(jì),需要的朋友可以參考下
本文實(shí)例講述了C++基于對話框的程序的框架。分享給大家供大家參考。具體如下:
resource.cpp源文件如下:
復(fù)制代碼 代碼如下:
#include "resource.h"
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;
}
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頭文件如下:
復(fù)制代碼 代碼如下:
#include <afxwin.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()
};
#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ì)有所幫助。
相關(guān)文章
C++ 面向?qū)ο蟪绦蛟O(shè)計(jì)--內(nèi)存分區(qū)詳解
這篇文章主要介紹了剖析C++的面向?qū)ο缶幊趟枷?C++的面向?qū)ο筇匦允瞧鋵語言的重要拓展之處,需要的朋友可以參考下,希望能夠給你帶來幫助2021-08-08讓應(yīng)用程序只運(yùn)行一個(gè)實(shí)例的實(shí)現(xiàn)方法
我們在使用《360軟件管家》時(shí)發(fā)現(xiàn),在《360軟件管家》已經(jīng)運(yùn)行了的情況下,再次點(diǎn)擊《360軟件管家》的圖標(biāo),那么它不會再運(yùn)行另外一個(gè)《360軟件管家》,而是將已有的《360軟件管家》給激活,始終只能運(yùn)行一個(gè)《360軟件管家》的實(shí)例2013-05-05C語言中fgetgrent()函數(shù)和fgetpwent()函數(shù)的用法對比
這篇文章主要介紹了C語言中fgetgrent()函數(shù)和fgetpwent()函數(shù)的用法對比,分別用于讀取組格式函數(shù)和讀取密碼格式,需要的朋友可以參考下2015-08-08C語言實(shí)現(xiàn)可保存的動態(tài)通訊錄的示例代碼
這篇文章主要為大家詳細(xì)介紹了如何利用C語言實(shí)現(xiàn)一個(gè)簡單的可保存的動態(tài)通訊錄,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)C語言有一定幫助,需要的可以參考一下2022-07-07