Generate Dialog-Based Programs
1. Use Win32 Wizard to generate a template 2. Generate the resource file (.rc) Win32 program does not support dialogs (Dialog) edited by VC7.0 Resource Editor. His ResourceType is DialoGex. The modified method is to change it to Dialog, and other parts are also modified. It is best to become a format of VC6. Related Articles See: http://support.microsoft.com/default.aspx? ScID = KB; EN-US; 138971
The resource file structure see MSDN's ms-help: //ms.vscc.2003/ms.msdnqtr.2003feb.2052/winui/winui/windowsuserinterface/ResourceFileFormatsOhtm
Resourceid ResourceType Left, Top, Width, Height StyleptionFontbegin // List of Controls Created In The Dialogend
3. Create CREATEWINDOW to CREATEDIALOG () Create a Non-Modal dialog 4. Modify the message processing callback function: >> Message handler Return Value is BOOL (can not change) >> Return true if the window process handles a message; do not process A message, returning false; >> After CreateDialog, WM_INITDIALOG, add >> Add Form Close Option: 1> WM_Command ... case IDCancel: {enddialog (hwnd, wmid); // Only Close window PostMessage HWnd, WM_DESTROY, 0, 0); // Exit The program return true;} >> Non-modular dialog box is subject to the program's message queue, which is different from the modal dialog. To pass these messages to the dialog process To change the message loop. (Can not change) IF (hdlgwnd == 0 ||! IsDialogmessage (hdlgwnd, & msg)) {if (! "{TranslateMessage (& MSG) {TranslateMessage (& MSG); DispatchMessage (& MSG);}} 2> Remove the Default DefWindowProc this, so that the X button can be used // default: // Return DefWindowProc (HWND, Message, WPARAM, LPARAM);
5. All Dialog emptyware issues are WM_COMMAND messages, and LOWORD (WPARAM) gets the ID number 6. Several functions: Establish a Modal dialog: Dialogbox () VS creates a non-modal dialog: createDialog () End dialog: EndDialog () Get control: getdlgitem ()
Set control characters: setWindowText () Get control characters: getWindowText ()
Send block message: sendMessage () Sends a non-blocking message: PostMessage ()