Summary of Windows Programming dialog box

Source: Internet
Author: User

About dialog boxes

1 Types of dialog boxes

Dialogs are also resources, and dialogs in Windows are modal and non-modal, as well as common dialog boxes already defined in Windows systems, such as opening files, directories, palettes, string lookups, and so on.

2 differences between modal dialog boxes and non-modal dialogs

Modal dialogs are the kind of type you have to turn off when you open it. The non-modal dialog box is the type of pointing point that you can still make in the main form, even if you open the dialog box.

3 modal dialog box creation and Popup

<1>

Int_ptrdialogbox (        hinstancehinstance,   //Handle to Module       LPCTSTR lptemplate,    //dialog box template       HWND hwndparent,    //handle to owner window       dlgproc lpdialogfunc  //dialog box procedure);

<2>

INT_PTR   dialogboxindirect (        hinstancehinstance,       //Handle to module       lpcdlgtemplate lptemplate,// dialog box template       HWND hwndparent,          //Handle to owner window       dlgproc lpdialogfunc      //dialog Box Pro Cedure);

<3>

INT_PTR    Dialogboxindirectparam (hinstance hinstance,//handle to Module Lpcdlgtemplate hdialogtemplate,//dialog Box template  hwndhwndparent,               //Handle Toowner window Dlgproc lpdialogfunc,           //dialog box procedure LPARAM DW Initparam              //initialization value);

<4>

INT_PTR     Dialogboxparam (        hinstancehinstance,      //Handle to Module       LPCTSTR lptemplatename,  // dialog box template       HWND hwndparent,       //Handle to owner window       dlgproc lpdialogfunc,   //dialog Box Procedure       LPARAM Dwinitparam     //initialization value);

DialogBox and Dialogboxparam are loaded from the Resources dialog box, the remaining two are loaded from Memory dialog box. One of the parameters to note here is the Dlgproc Lpdialogfunc, the function prototype is:

Int_ptrcallbackdialogproc (hwndhwnddlg,//handle to dialog boxuint umsg,//message wparamwparam,//first message Parameterlparam lParam   //second message parameter);

This callback function is very similar to the form callback function, but the return type of the function is different.

4 Message processing for modal dialog boxes

DialogProc is very much like WindowProc, but it is not WindowProc, the WindowProc of the dialog is defined inside windows and it calls the DialogProc function.

BOOL Callbackdlgproc (HWND hdlg,uint msg,wparam wparam,lparam LPARAM) {         switch (msg)         {         Casewm_initdialog:                   returntrue;         Casewm_command:                   switch (LOWORD (wParam))                   {                   Caseidok:                            enddialog (hdlg,0);                            break;                   }                   break;         }         Returnfalse;}


Wm_initdialog messages are sent when the dialog is created, and can be used to initialize the various controls in the dialog box under this message.

5 The modal dialog box closes

Boolenddialog (Hwndhdlg,int_ptr nresult);

Specifies the return value of the function that created the dialog box.


6 creating complex dialog boxes with controls


7 modal dialog box self-defined control


Now that you are defining the control yourself, you must be in the form's design, the form's register, and the form procedure function that configures the response.

Production steps:

<1> find the custom control in the Toolbox and drag it to the panel

<2> Click Properties, specify the class name, and the ID

<3> Design a brochure in the WinMain function

<4> specifying its form procedure function


Summary of Windows Programming dialog box

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.