DirectX/10.0/Direct3D/创建框架
外观
< DirectX | 10.0/Direct3D
- 包含 <windows.h>
- 包含 <tchar.h>
- 包含 <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; }
}