码迷,mamicode.com
首页 > Windows程序 > 详细

DirectX游戏编程-1.创建空白window窗口

时间:2015-05-25 18:36:59      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

 1 #include <windows.h>
 2 
 3 #define WIN_CLASS "GameFrame" //窗口类名
 4 #define WIN_NAME "SampleGame" //窗口标题
 5 #define WIN_WIDTH 800          //窗口宽度
 6 #define WIN_HEIGHT 600          //窗口高度
 7 
 8 
 9 //窗口消息处理函数
10 LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
11 {
12     switch (msg)
13     {
14     case WM_DESTROY:
15         PostQuitMessage(0);
16         break;
17     case WM_LBUTTONUP:
18         MessageBox(NULL,"Hello Directx!","Info",MB_OK);
19         break;
20     }
21     return DefWindowProc(hwnd,msg,wparam,lparam);
22 }
23 
24 
25 //标准win32程序入口
26 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
27 {
28     WNDCLASSEX wc={sizeof(WNDCLASSEX),CS_CLASSDC,WndProc,0,0,hInstance,LoadIcon(NULL,IDI_APPLICATION),LoadCursor(NULL,IDC_ARROW),NULL,NULL,WIN_CLASS,NULL};
29     RegisterClassEx(&wc);
30     HWND hwnd= CreateWindow(WIN_CLASS,WIN_NAME,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,WIN_WIDTH,WIN_HEIGHT,NULL,NULL,hInstance,NULL);
31     if (hwnd==0)
32     {
33         return 0;
34     }
35     ShowWindow(hwnd,nShowCmd);
36     UpdateWindow(hwnd);
37     MSG msg;
38     ZeroMemory(&msg,sizeof(MSG));
39     while (msg.message!=WM_QUIT)
40     {
41         if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
42         {
43             TranslateMessage(&msg);
44             DispatchMessage(&msg);
45         }
46     }
47     UnregisterClass(WIN_CLASS,wc.hInstance);
48     return 0;
49 }

 

DirectX游戏编程-1.创建空白window窗口

标签:

原文地址:http://www.cnblogs.com/qq578023708/p/4528436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!