|
1 Add dialog resources
2 Call the DialogBox function in the WinMain function
3 Define the message processing function of the dialog box, the format refers to MSDN
4 Message mapping
<< Windows Core Programming >> has specific examples in the book
INT_PTR CALLBACK MyDlgProc (HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
); // Window function prototype declaration
BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam) // Message processing (required)
{
}
VOID Dlg_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) // Command message processing
{
}
INT_PTR CALLBACK MyDlgProc (HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_INITDIALOG:
return SetDlgMsgResult (hwndDlg, uMsg, HANDLE_WM_INITDIALOG ((hwndDlg), (wParam), (lParam), (Dlg_OnInitDialog)));
break; //// Message map
case WM_COMMAND:
return SetDlgMsgResult (hwndDlg, uMsg, HANDLE_WM_COMMAND ((hwndDlg), (wParam), (lParam), (Dlg_OnCommand)));
break;
}
return FALSE;
}
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
DialogBox (hInstance, MAKEINTRESOURCE (IDD_DLG), NULL, MyDlgProc);
} |
|