Windows Programming Self-Study: Window Center display Hello,world

Source: Internet
Author: User

1#include <windows.h>2 3LRESULT CALLBACK Mywndproc (HWND hwnd,//Handle to Window4UINT umsg,//message identifier5WPARAM WPARAM,//First message parameter6LPARAM LPARAM//Second message parameter7   );8 9 intWINAPI WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpCmdLine,intnshowcmd)Ten { One wndclass wnd; A HWND hwnd; - msg msg; -Wnd.style = Cs_hredraw | Cs_vredraw;//The horizontal or vertical change window is redrawn with Mywndproc's WM_PAINT message Association theWnd.lpfnwndproc =Mywndproc; -Wnd.cbclsextra =0; -Wnd.cbwndextra =0; -Wnd.hicon =LoadIcon (NULL, idi_application); +Wnd.hcursor =loadcursor (NULL, idc_arrow); -Wnd.hbrbackground =(Hbrush) getstockobject (White_brush); +Wnd.lpszmenuname =NULL; AWnd.lpszclassname ="Helloclass";//window class identifier, used in the first parameter of CreateWindow atWnd.hinstance =hinstance; -     if(! RegisterClass (&wnd)) -     { -MessageBox (NULL, TEXT ("Unable to create window"), TEXT ("ERROR"), mb_ok|mb_iconerror); -         return 0; -     } in      -hwnd = CreateWindow ("Helloclass", TEXT ("Hello"), Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_usedefault, cw_usedefault, NULL, NULL, HINSTANCE, NULL);//The second argument is a window caption to ShowWindow (hwnd, nshowcmd); +      while(GetMessage (&msg, NULL,0,0)) -     { theTranslateMessage (&msg); *DispatchMessage (&msg); $     }Panax Notoginseng     return 0; - } the  + LRESULT CALLBACK Mywndproc (HWND hwnd, UINT umsg, WPARAM WPARAM, LPARAM LPARAM) A { theHDC hdc;//defining a device environment handle +Paintstruct PS;//Drawing Structures -Rect rect;//Rectangular Structure $     Switch(umsg) $     { -      CaseWM_PAINT: -     {     theHDC = BeginPaint (hwnd, &PS); -GetClientRect (hwnd, &rect);WuyiDrawText (HDC, TEXT ("hello,world!"), -1, &rect, dt_singleline| dt_center|dt_vcenter); theEndPaint (hwnd, &PS); -     } Wu      Break;  -      CaseWm_destroy: AboutPostQuitMessage (0); $         return 0; -     } -  -     returnDefWindowProc (hwnd, umsg, WParam, LParam);  A}

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.