Code
# Include <windows. h>
# Include <windowsx. h>
# Include "resource. H"
# Include <wchar. h>
Void button_oncommand (hwnd, int ID, hwnd hwndclt, uint codenostrap)
{
Switch (ID)
{
Case idok:
Wchar_t lpsz [max_path];
Wmemset (lpsz, 0, max_path );
// Control macro
Edit_gettext (getdlgitem (hwnd, idc_edit1), lpsz, max_path );
MessageBox (hwnd, lpsz, l "OK", null );
Break;
Case idcancel:
MessageBox (hwnd, l "Click cancle! ", L" cancle ", null );
Break;
}
}
Lresult callback procmain (hwnd hdlg, uint MSG, wparam, lparam)
{
Switch (MSG)
{
// Message delivery method
Handle_msg (hdlg, wm_command, button_oncommand );
// Traditional Method
Case wm_initdialog:
Break;
Case wm_close:
Postquitmessage (0 );
Break;
// Case wm_command:
// The button will send the wm_command message to the parent window. parameters:
// Loword (wparam) is the Child Window ID.
// Hiword (wparam) is the notification code.
// Lparam is the sub-window handle.
/*
Switch (loword (wparam ))
{
Case idok:
MessageBox (hdlg, l "click OK! ", L" OK ", null );
// Enablewindow (hwnd) lparam, false );
Break;
Case idcancel:
MessageBox (hdlg, l "Click cancle! ", L" cancle ", null );
Break;
}
*/
// Break;
Case wm_destroy:
Postquitmessage (0 );
Break;
// Default:
// Return defwindowproc (hdlg, MSG, wparam, lparam );
}
Return 0;
}
Int winapi winmain (hinstance, hinstance hprevinstance, lpstr lpcmdline, int nshowcmd)
{
Dialogboxparam (hinstance, makeintresource (idd_dialog1), null, (dlgproc) procmain, 0 );
Return 0;
}