The program framework code of the dialog box is as follows:
/// Resource. h /// Control ID. // # define idd_main 100 # define idc_ OK 101 # define idc_cancel 102
//// Main. h // # ifndef _ main_h # DEFINE _ main_h # include <windows. h> //// pre-declaration of user-defined functions. // bool winapi resume (hwnd, uint umsg, wparam, lparam); bool resume (hwnd, hwndfocus, lparam); void main_oncommand (hwnd, int ID, hwnd hwndctl, uint codenostrap); void main_onclose (hwnd );
# Endif
/// Dialogs. cpp // # include <commctrl. h>
# Include "Main. H" # include "resource. H" int winapi winmain (hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) {initcommoncontrols ();
// Create dialog box. dialogbox (hinstance, makeintresource (idd_main), null, main_proc); Return 0 ;}
//// Main. CPP // # include <windows. h> # include <windowsx. h> # include "Main. H "# include" resource. H "/// Main Dialog Box Process. // bool winapi main_proc (hwnd, uint umsg, wparam, lparam) {Switch (umsg) {handle_msg (hwnd, handler, timeout); handle_msg (hwnd, wm_command, main_oncommand); handle_msg (hwnd, wm_close, main_onclose);} return false;} bool main_oninitdialog (hwnd, hwnd hwndfocu S, lparam) {// Add initializing code here // return true;} void main_oncommand (hwnd, int ID, hwnd hwndctl, uint codenostrap) {Switch (ID) {Case idc_ OK: MessageBox (hwnd, text ("You clicked OK! "), Text (" Test2 "), mb_ OK); enddialog (hwnd, ID); break; Case idc_cancel: MessageBox (hwnd, text (" You clicked cancel! "), Text (" Test2 "), mb_ OK); enddialog (hwnd, ID); break; default: Break ;}} void main_onclose (hwnd) {enddialog (hwnd, 0 );}