Windows API Programs

Source: Internet
Author: User

#include "StdAfx.h" #include <windows.h> #include <mmsystem.h>lresult CALLBACK WndProc (Hwnd,uint,wparam, LPARAM); int WINAPI WinMain (hinstance hinstance,hinstance hprevinstance,pstr szcmdline,int icmdshow) {static TCHAR Szappname[]=text ("Hellowin"); HWND hwnd; MSG msg; Wndclass Wndclass;wndclass.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) getstockobject (White_brush); wndclass.lpszmenuname=null;wndclass.lpszclassname= Szappname;if (! RegisterClass (&wndclass)) {MessageBox (Null,text ("This program requiers Windows nt!"), Szappname,mb_iconerror); return 0;} Hwnd=createwindow (Szappname,//window class Nametext ("The Hello Program"),//window captionws_overlappedwindow,// Window stylecw_usedefault,//initial x positioncw_usedefault,//initial Y positioncw_usedefault,//initial x sizeCW_ UsedefAult,//initial y sizenull,//parent window handlenull,//window menu Handlehinstance,//program instance handlenull); ShowWindow (hwnd,icmdshow); UpdateWindow (HWND), while (GetMessage (&msg,null,0,0)) {TranslateMessage (&msg);D ispatchmessage (&msg);} return Msg.wparam;} LRESULT CALLBACK WndProc (HWND hwnd,uint message,wparam wparam,lparam iparam) {HDC hdc; Paintstruct PS; RECT rect;switch (message) {Case Wm_create:playsound (TEXT ("Hellowin.wav"), null,snd_filename| Snd_async); return 0;case wm_paint:hdc=beginpaint (HWND,&AMP;PS); GetClientRect (Hwnd,&rect);D Rawtext (Hdc,text ("Hello"), -1,&rect,dt_singleline | Dt_center | Dt_vcenter); EndPaint (HWND,&AMP;PS); return 0;case wm_destroy:postquitmessage (0); return 0;} return DefWindowProc (Hwnd,message,wparam,iparam);}

  

Windows API Programs

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.