One-day training of Windows APIs (19) destroywindow Function

Source: Internet
Author: User
I have already introduced how to directly click the close button to close the application. But what functions do I need to delete a window object? For example, if you have created 30 windows and want to close and delete 12th windows, you need to use the destroywindow function. After the destroywindow function is called, the operating system will perform a series of Delete actions, first send the wm_destroy message, and then send the wm_ncdestroy message. If this window has a subwindow or another window owner, you need to send a delete message to all subwindows. The destroywindow function declaration is as follows: winuserapiboolwinapidestroywindow (_ in hwnd ); HwndIs the window handle to be deleted. Example of calling this function: #001 // #002 // function: wndproc (hwnd, uint, wparam, lparam) #003 // #004 // objective: process messages in the main window. #005 // #006 // Cai junsheng 2007/07/12 QQ: 9073204 #007 // #008 lresult callback wndproc (hwnd, uint message, wparam, lparam) #009 {#010 int wmid, wmevent; #011 paintstruct pS; #012 HDC; #013 #014 switch (Message) #015 {#016 case wm_command: #017 wmid = loword (wparam); #018 wmevent = hiword (wparam); #019 // menu option command response: #020 switch (wmid) #021 {#022 case idm_about: #023 dialogbox (hinst, makeintresource (idd_aboutbox), hwnd, about); #024 break; #025 case idm_exit: #026 destroywindow (hwnd );#027 break; #028 default: #029 return defwindowproc (hwnd, message, wparam, lparam); #030} #031 break; #032 case wm_paint: #033 HDC = beginpaint (hwnd, & PS); #034 // #035 endpaint (hwnd, & PS); #036 break; #037 case wm_destroy: #038 postquitmessage (0); #039 break; #040 default: #041 return defwindowproc (hwnd, message, wparam, lparam); #042} #043 return 0; #044} row 26th is the message that when the menu button exits, the destroywindow function is called, and then the message wm_destro is sent. Y to 37th rows for processing.

 

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.