1#include <windows.h>2 3 #defineWin_class "Gameframe"//window class name4 #defineWin_name "Samplegame"//Window Title5 #defineWin_width 800//window Width6 #defineWin_height 600//Window Height7 8 9 //window Message handler functionTen LRESULT CALLBACK WndProc (HWND hwnd,uint msg,wparam wparam,lparam LPARAM) One { A Switch(msg) - { - CaseWm_destroy: thePostQuitMessage (0); - Break; - CaseWm_lbuttonup: -MessageBox (NULL,"Hello directx!","Info", MB_OK); + Break; - } + returnDefWindowProc (hwnd,msg,wparam,lparam); A } at - - //standard Win32 Program Entry - intWINAPI WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpCmdLine,intnshowcmd) - { -Wndclassex wc={sizeof(Wndclassex), Cs_classdc,wndproc,0,0, Hinstance,loadicon (null,idi_application), LoadCursor (Null,idc_arrow), null,null,win_class,null}; inRegisterClassEx (&WC); -HWND hwnd=CreateWindow (Win_class,win_name,ws_overlappedwindow,cw_usedefault,cw_usedefault,win_width,win_height,null, Null,hinstance,null); to if(hwnd==0) + { - return 0; the } * ShowWindow (hwnd,nshowcmd); $ UpdateWindow (HWND);Panax Notoginseng msg msg; -ZeroMemory (&msg,sizeof(MSG)); the while(msg.message!=wm_quit) + { A if(PeekMessage (&msg,null,0,0, Pm_remove)) the { +TranslateMessage (&msg); -DispatchMessage (&msg); $ } $ } - Unregisterclass (win_class,wc.hinstance); - return 0; the}
DirectX Game Programming-1. Create a blank Windows window