1. Direct differences between Dialog Box Process and window process.
1. Return Value:
Window lresult
Dialog Box bool
2. Unprocessed messages:
Window to defwindowproc
If the dialog box is processed, return true. If not, return false.
3. Specific Message:
The dialog box does not process wm_paint, wm_destroy, and wm_create is not received, but initialized in wm_initdialog.
Wm_initdialog is the first message received in the dialog box.
2. Obtain hinstance In the MFC dialog box
1, hinstance = AfxGetInstanceHandle ();
2, hinstance = (hinstance) getwindowlong (hwmd, gwl_hinstance );
3. Modal Dialog Box and non-modal dialog box.
Domodal or dialogbox is modal.
Createdialog or createwindow is non-modal.
In the non-modal dialog box, specify "visible" in the dialog box properties, that is, after ws_visible style, createdialog can be displayed. If not specified, you must call showwindow to display the image.
Messages in the non-modal dialog box must pass through the message queue of the program. To process a message queue, determine whether the message is a dialog message:
While (getmessage (& MSG, null, 0, 0 ))
{
If (hdlgmodeless = 0 |! Isdialogmessage (hdlgmodeless, & MSG ))
{
Translatemessage (& MSG );
Dispatchmessage (& MSG );
}
}
The modal dialog box ends with enddialog, and the non-modal dialog box ends with destroywindow.
Dialog Box with parameters:
Dialogbox with parameters: int_ptr dialogboxparam (
Hinstance, // handle to Module
Lptstr lptemplatename, // dialog box template
Hwnd hwndparent, // handle to owner window
Dlgproc lpdialogfunc, // dialog box procedure
Lparam dwinitparam // initialization value
);
Parameter pointer = (parameter type *) lparam;
4. Use the. DLG file to layout the window.
View-resources include-compile-time ctictives input "# include" XXXX. DLG ""
This is equivalent to adding the content in the above file to the RC file.
Example:
XXXX. DLG:
/*--------------------------- HEXCALC.DLG dialog script ---------------------------*/HexCalc DIALOG -1, -1, 102, 122STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOXCLASS "HexCalc"CAPTION "Hex Calculator"{ PUSHBUTTON "D", 68, 8, 24, 14, 14 PUSHBUTTON "A", 65, 8, 40, 14, 14 PUSHBUTTON "7", 55, 8, 56, 14, 14 PUSHBUTTON "4", 52, 8, 72, 14, 14 PUSHBUTTON "1", 49, 8, 88, 14, 14 PUSHBUTTON "0", 48, 8, 104, 14, 14 PUSHBUTTON "0", 27, 26, 4, 50, 14 PUSHBUTTON "E", 69, 26, 24, 14, 14 PUSHBUTTON "B", 66, 26, 40, 14, 14 PUSHBUTTON "8", 56, 26, 56, 14, 14 PUSHBUTTON "5", 53, 26, 72, 14, 14 PUSHBUTTON "2", 50, 26, 88, 14, 14 PUSHBUTTON "Back", 8, 26, 104, 32, 14 PUSHBUTTON "C", 67, 44, 40, 14, 14 PUSHBUTTON "F", 70, 44, 24, 14, 14 PUSHBUTTON "9", 57, 44, 56, 14, 14 PUSHBUTTON "6", 54, 44, 72, 14, 14 PUSHBUTTON "3", 51, 44, 88, 14, 14 PUSHBUTTON "+", 43, 62, 24, 14, 14 PUSHBUTTON "-", 45, 62, 40, 14, 14 PUSHBUTTON "*", 42, 62, 56, 14, 14 PUSHBUTTON "/", 47, 62, 72, 14, 14 PUSHBUTTON "%", 37, 62, 88, 14, 14 PUSHBUTTON "Equals", 61, 62, 104, 32, 14 PUSHBUTTON "&&", 38, 80, 24, 14, 14 PUSHBUTTON "|", 124, 80, 40, 14, 14 PUSHBUTTON "^", 94, 80, 56, 14, 14 PUSHBUTTON "<", 60, 80, 72, 14, 14 PUSHBUTTON ">", 62, 80, 88, 14, 14}
V,
Open the file getopenfilename
Save the getsavefilename File
Find findtext
Replacetext
Unicode istextunicode
Obtain the color choosecolor