跳转到内容

DirectX/10.0/Direct3D/创建框架

来自维基教科书,开放世界的开放书籍
  1. 包含 <windows.h>
  2. 包含 <tchar.h>
  3. 包含 <d3d9.h>

TCHAR ClassName[] = _T("Win32");  LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);  int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE p_HInstance,LPSTR lpstr,int cmdShow) {

    WNDCLASSEX wc;
    wc.hInstance = hInstance;
    wc.lpszClassName = ClassName;
    wc.style = CS_VREDRAW | CS_HREDRAW;
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
    wc.hIconSm = LoadIcon(hInstance,IDI_APPLICATION);
    wc.lpfnWndProc = WndProc;
    wc.hCursor = LoadCursor(hInstance,IDC_ARROW);
    wc.lpszMenuName = NULL;
    wc.cbClsExtra = 0;                      
    wc.cbWndExtra = 0;
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
    if(!RegisterClassEx(&wc))
    { 
        MessageBox(NULL,_T("Error On wcClass"),_T("info"),NULL);
    }
    HWND hwnd = CreateWindow(ClassName,_T("Test"),WS_OVERLAPPEDWINDOW, 
    CW_USEDEFAULT, CW_USEDEFAULT,600,300,NULL,NULL,hInstance,NULL);
    ShowWindow(hwnd,cmdShow);
    UpdateWindow(hwnd);
    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;

}  LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) {

   switch(message)
   {
      case WM_CLOSE :
           PostQuitMessage(0);
           break;
     default:
           return DefWindowProc(hwnd,message,wParam,lParam);
           break;
   }

}

华夏公益教科书