(C) window programs for the first Windows + API (

Source: Internet
Author: User

#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);intWINAPI WinMain (hinstance hinstance, hinstance hprevinstance, PSTR szCmdLine,inticmdshow) {    StaticTCHAR szappname[] = TEXT ("Windowofc"); HWND hwnd;//form Handle VariablesMSG msg;//Message VariablesWndclass Wndclass;//window class Variables//Configuring the window class structureWndclass.style = Cs_hredraw |Cs_vredraw; Wndclass.lpfnwndproc=WndProc; Wndclass.cbclsextra=0; Wndclass.cbwndextra=0; Wndclass.hinstance=hinstance; Wndclass.hicon=LoadIcon (NULL, idi_application); Wndclass.hcursor=loadcursor (NULL, Idc_arrow); Wndclass.hbrbackground=(Hbrush) Color_window; Wndclass.lpszmenuname=NULL; Wndclass.lpszclassname=Szappname; //Register window class    if(! RegisterClass (&wndclass)) {MessageBox (NULL, TEXT ("failed to register window Class! "), Szappname, Mb_iconerror); return 0; } hwnd=CreateWindow (Szappname, TEXT ("C language Calls Windows API created window"), Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_usedefault, Cw_usedefault,    NULL, NULL, HINSTANCE, NULL);    ShowWindow (hwnd, icmdshow);    UpdateWindow (HWND);  while(GetMessage (&msg, NULL,0,0) {translatemessage (&msg); DispatchMessage (&msg); }    returnMsg.wparam;};//Message handling methods, callback functions for Windows operating systemsLRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) {HDC hdc;    Paintstruct PS;    Rect rect; Switch(message) { CaseWm_create:messagebox (NULL, TEXT ("the window is created! "), NULL, Mb_iconerror); return 0;  CaseWM_PAINT:HDC= BeginPaint (hwnd, &PS); GetClientRect (hwnd,&rect); DrawText (hdc, TEXT ("Hello C windows"), -1, &rect, Dt_singleline | Dt_center |dt_vcenter); EndPaint (hwnd,&PS); return 0;  CaseWm_destroy:postquitmessage (0); return 0; }    returnDefWindowProc (hwnd, message, WParam, LParam);};

(C) window programs for the first Windows + API (

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.