Sometimes, maybe you will not want to use domodal to create a dialog! You are gonna use another method to handle the same question. That's is good! Here, I give you another method to create a dialog for all of the xxxcontrol and something like that ....
Primarily, I wanna talk about initcommoncontrolsex. The MFC describe it like this:
Initcommoncontrolsex ---->Registers specific common control classes from the common control dynamic-link library (DLL ).
Parameters
-
Lpinitctrls
-
Address of an initcommoncontrolsex structure that contains information specifying which control classes will be registered.
Return values: returns true if successful, or false otherwise.
Usually, we get icc_win95_classes to apply to our project! Pay attention to this advise:
By the way, let me see what initcommoncontrolsex structure is? The MFC describe it like this:
typedef struct tagINITCOMMONCONTROLSEX { DWORD dwSize; DWORD dwICC;} INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX;
Members
-
Dwsize
-
Size of the structure, in bytes.
-
Dwicc
-
Set of bit flags that indicate which common control classes will be loaded from the DLL. This value can be a combination of the following:
Icc_animate_class |
Load animate control class. |
Icc_bar_classes |
Load toolbar, status bar, trackbar, and tooltip control classes. |
Icc_cool_classes |
Load rebar control class. |
Icc_date_classes |
Load Date and Time picker control class. |
Icc_hotkey_class |
Load hot key control class. |
Icc_internet_classes |
Load IP Address class. |
Icc_listview_classes |
Load List View and header control classes. |
Icc_pagescroller_class |
Load pager control class. |
Icc_progress_class |
Load progress bar control class. |
Icc_tab_classes |
Load tab and tooltip control classes. |
Icc_treeview_classes |
Load Tree View and tooltip control classes. |
Icc_updown_class |
Load up-down control class. |
Icc_userex_classes |
Load comboboxex class. |
Icc_win95_classes |
Load animate control, header, hot key, list view, progress bar, status bar, tab, tooltip, toolbar, trackbar, tree view, and up-down control classes. |
I interpret the main part of dwicc form Engish to Chinese like this:
Icc_bar_classes -- registers the toolbar, status bar, trackbar, and tooltip classes.
Icc_cool_classes -- registers the rebar class.
Icc_date_classes -- registers the date and time picker class.
Icc_hotkey_class -- register the hot key class.
Icc_internet_classes -- registers the IP address picker class.
Icc_listview_classes -- register the listview and header classes.
Icc_pagescroller_class -- register the pager class.
Icc_progress_class -- register the progress bar class.
Icc_tab_classes -- register the tab and tooltip classes.
Icc_treeview_classes -- registers the Treeview and tooltip classes.
Icc_updown_class -- register the up-down class.
Icc_userex_classes -- register the comboboxex class.
Icc_win95_classes -- registers all classes registered by the initcommoncontrols function.
Especially if you use DLL to callback some datas and then show them or display them to the dialog that you have setted to be ready to receive data from local DLL or romote DLL data.
If you use Window XP application procedure to generate a dialog or form, but you don't want to apply to traditional (conventional) method, so please try to make use of this way that I just told you above. here, I give you a simple instance. (The next content is the core of code)
Bool cxxxxapp: initinstance ()
{
// Initcommoncontrolsex () is required on Windows XP if an application
// Manifest specifies use of comctl32.dll version 6 or later to enable
// Visual styles. Otherwise, any window creation will fail.
Initcommoncontrolsex initctrls;
Initctrls. dwsize = sizeof (initctrls );
// Set this to include all the common control classes you want to use
// In your application.
Initctrls. dwicc = icc_win95_classes;
Initcommoncontrolsex (& initctrls );
Cwinapp: initinstance ();
.........
// Here, you must write off domodal function like:
/* Setregistrykey (_ T ("Local Appwizard-generated Applications "));
Cpricewindowdlg DLG;
M_pmainwnd = & DLG;
Int_ptr nresponse = DLG. domodal ();
If (nresponse = idok)
{
// Todo: Place code here to handle when the dialog is
// Dismissed with OK
}
Else if (nresponse = idcancel)
{
// Todo: Place code here to handle when the dialog is
// Dismissed with cancel
}
*/
Return false; // here, since the dialog has been closed, return false so that we exit
// Application, rather than start the application's message pump.
}