Windows Programming--windows Program Framework

Source: Internet
Author: User

Source

1#include <Windows.h>2 3 LRESULT CALLBACK Windproc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM);4 5 intWinMain (hinstance hInst, hinstance tmp, LPSTR szcmd,intnshow)6 {7 wndclass wndclass;8tchar* ClassName = TEXT ("MyClass");9 HWND hwnd;Ten msg msg; One  AWndclass.cbclsextra =0; -Wndclass.cbwndextra =0; -Wndclass.hbrbackground = (hbrush) (Color_window +1); theWndclass.hcursor =loadcursor (NULL, idc_arrow); -Wndclass.hicon =LoadIcon (NULL, idi_application); -Wndclass.hinstance =HInst; -Wndclass.lpfnwndproc =Windproc; +Wndclass.lpszclassname =ClassName; -Wndclass.lpszmenuname =NULL; +Wndclass.style = Cs_vredraw |Cs_hredraw; A  at     if(! RegisterClass (&wndclass)) -     { -MessageBox (NULL, TEXT ("gegister Class fail!!"), TEXT ("Error"), MB_OK); -         return 0; -     } -  inhwnd = CreateWindow (ClassName, TEXT ("Hello"), Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, -, -, NULL, NULL, HINST, NULL); -     if(hwnd = =NULL) to     { +MessageBox (NULL, TEXT ("Create Window fail!!"), TEXT ("Error"), MB_OK); -         return 0; the     } * ShowWindow (hwnd, nshow); $ UpdateWindow (HWND);Panax Notoginseng  -      while(GetMessage (&msg,null,0,0)) the     { +TranslateMessage (&msg); ADispatchMessage (&msg); the     } +  -     return 0; $ } $  - LRESULT CALLBACK Windproc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) - { the     Switch(message) -     {Wuyi      CaseWm_destroy: thePostQuitMessage (0);//Send Wm_quit message -         return 0; Wu     default: -          Break; About     } $  -     returnDefWindowProc (hwnd, message, WParam, lParam); -}
View Code

Windows Forms programs spend most of their lifetime in the message loop.

Windows Programming--windows Program Framework

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.