DirectX遊戲編程-1.建立空白window視窗

來源:互聯網
上載者:User

標籤:

 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視窗

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.