One-day Windows API training (18) enddialog Function

Source: Internet
Author: User
The last time I introduced how to display the function of the dialog box, how can I close the dialog box? This requires the use of the function enddialog. This function can only be used in the message processing function of the dialog box. After this function is called, it does not delete the dialog box immediately, but sets the end mark in the operating system. When the operating system detects this flag, it deletes the message loop in the dialog box and releases the resources occupied by the dialog box. In fact, the life cycle of the dialog box is like this. The dialogbox function is used to create a dialog box. In this way, the message wm_initdialog is sent before the dialog box is displayed, this gives the dialog box the opportunity to initialize the display of all the above windows or controls, such as setting text box strings. Finally, when you click the OK or cancel button, you will receive two Commands: idok or idcancel. Then you can call the function enddicel to end the life of the dialog box. The enddialog function declaration is as follows: winuserapiboolwinapienddialog (_ in hwnd hdlg, _ in int_ptr nresult ); HdlgIs the handle of the dialog box window. NresultIs the return value set for the dialogbox function. An example of calling this function is as follows: #001 // the dialog box is displayed. #002 // #003 // Cai junsheng 2007/07/12 #004 // #005 int_ptr callback about (hwnd hdlg, uint message, wparam, lparam) #006 {#007 unreferenced_parameter (lparam); #008 switch (Message) #009 {#010 case wm_initdialog: #011 return (int_ptr) True; #012 #013 case wm_command: #014 if (loword (wparam) = idok | loword (wparam) = idcancel) #015 { #016 enddialog (hdlg, loword (wparam ));#017 return (int_ptr) True; #018} #019 break; #020} #021 return (int_ptr) false; #022}

Row 3 calls the enddialog function to close the dialog box.

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.