Notes-program code of the dialog box in C can do big things

Source: Internet
Author: User
The program framework code of the dialog box is as follows:
/// Resource. h /// Control ID. // # define idd_main 100 # define idc_ OK 101 # define idc_cancel 102
 
//// Main. h // # ifndef _ main_h # DEFINE _ main_h # include <windows. h> //// pre-declaration of user-defined functions. // bool winapi resume (hwnd, uint umsg, wparam, lparam); bool resume (hwnd, hwndfocus, lparam); void main_oncommand (hwnd, int ID, hwnd hwndctl, uint codenostrap); void main_onclose (hwnd );
# Endif
 
/// Dialogs. cpp // # include <commctrl. h>
# Include "Main. H" # include "resource. H" int winapi winmain (hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) {initcommoncontrols ();
// Create dialog box. dialogbox (hinstance, makeintresource (idd_main), null, main_proc); Return 0 ;}

//// Main. CPP // # include <windows. h> # include <windowsx. h> # include "Main. H "# include" resource. H "/// Main Dialog Box Process. // bool winapi main_proc (hwnd, uint umsg, wparam, lparam) {Switch (umsg) {handle_msg (hwnd, handler, timeout); handle_msg (hwnd, wm_command, main_oncommand); handle_msg (hwnd, wm_close, main_onclose);} return false;} bool main_oninitdialog (hwnd, hwnd hwndfocu S, lparam) {// Add initializing code here // return true;} void main_oncommand (hwnd, int ID, hwnd hwndctl, uint codenostrap) {Switch (ID) {Case idc_ OK: MessageBox (hwnd, text ("You clicked OK! "), Text (" Test2 "), mb_ OK); enddialog (hwnd, ID); break; Case idc_cancel: MessageBox (hwnd, text (" You clicked cancel! "), Text (" Test2 "), mb_ OK); enddialog (hwnd, ID); break; default: Break ;}} void main_onclose (hwnd) {enddialog (hwnd, 0 );}

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.