Hello MFC - Add Resource and About Dialog
Add Resource

dialog bar

property:
- Style: Popup
- System Menu: True
- Title Bar: True
Set Icon
- add picture


- picture control
type: Icon
Image: IDI_ICON1

About Dialog
-
add class

-
add resource head file
#include "resource.h"
project

Add Button
- Declare
private:
CButton m_btnAbout;
- impl
CRect rt;
rt.top = 10;
rt.left = 150;
rt.right = 250;
rt.bottom = 30;
m_btnAbout.Create(_T("About"),
WS_CHILD | WS_VISIBLE,
rt,
this,
ID_ABOUT); // #define ID_ABOUT 1101
Button Event
- Declare
public:
afx_msg void OnBtnClick();
- impl
afx_msg void CMainWindow::OnBtnClick()
{
CAboutDlg dlgAbout; // #include "AboutDlg.h"
dlgAbout.DoModal();
}
Add Message Map
- Declare
DECLARE_MESSAGE_MAP()
- impl
BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd)
ON_COMMAND(ID_ABOUT, OnBtnClick)
END_MESSAGE_MAP()
浙公网安备 33010602011771号