< DirectX < 10.0 < Direct3D
- include <windows.h>
- include <tchar.h>
- include <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;
}
}
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.