Windows programming: The first Windows program

Source: Internet
Author: User

1 #defineWin32_lean_and_mean2#include <windows.h>3#include <windowsx.h>4#include <math.h>5 #defineWindow_class_name L "WINCLASS1"6 //window processing Functions7 LRESULT CALLBACK WindowProc (HWND hwnd,8 UINT msg,9 WPARAM WPARAM,Ten LPARAM Lpram) One { A paintstruct PS; - HDC hdc; -     Switch(msg) the     { -      Casewm_create: -     { -                       return 0; +} Break; -      CaseWM_PAINT: +     { AHDC = BeginPaint (hwnd, &PS); atEndPaint (hwnd, &PS); -                      return 0; -} Break; -     default: Break; -     } -     returnDefWindowProc (hwnd, MSG, WParam, lpram); in } - voidGamemain () to { +     return; - } the intWINAPI WinMain (hinstance hinstance, * hinstance hPrevInstance, $ LPSTR lpCmdLine,Panax Notoginseng     intncmdshow) - { the     //Defining window Classes + wndclassex Winclass; A HWND hwnd; the msg msg; +     //populating a member of a window class -Winclass.cbsize =sizeof(wndclassex); $Winclass.style = Cs_dblclks | CS_OWNDC | Cs_hredraw |Cs_vredraw; $Winclass.lpfnwndproc = WindowProc;//window Message handler function -Winclass.cbclsextra =0; -Winclass.cbwndextra =0; theWinclass.hinstance =hinstance; -Winclass.hicon =LoadIcon (NULL, idi_application);WuyiWinclass.hcursor =loadcursor (NULL, idc_arrow); theWinclass.hbrbackground =(Hbrush) getstockobject (Black_brush); -Winclass.lpszmenuname =NULL; WuWinclass.lpszclassname = Window_class_name;//window class name -WINCLASS.HICONSM =LoadIcon (NULL, idi_application); About  $     //Register window class -     if(! RegisterClassEx (&winclass)) -     { -         return 0; A     } +  the     //create a member of a window class -     if(! (HWnd =CreateWindowEx (NULL, $ Window_class_name, theL"Hello World", theWs_overlappedwindow |ws_visible, the         0,0, the         640,480, - NULL, in NULL, the hinstance, the NULL ))) About     { the         return 0; the     } the  +     //message Loops -      while(true) the     {Bayi         if(PeekMessage (&msg, HWnd,0,0, Pm_remove)) the         { the             if(Msg.message = =wm_quit) -             { -                  Break; the             } theTranslateMessage (&msg); theDispatchMessage (&msg); the         } - Gamemain (); the     } the     returnMsg.wparam; the}

Windows programming: The first Windows program

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.