📄 direct3d_1.cpp
字号:
#include "stdio.h"
#include "windows.h"
HWND hWnd;
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
PAINTSTRUCT pt;
HDC hdc;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&pt);
TextOut(hdc,100,100,"Hello,Boy and Girl!",strlen("Hello,Boy and Girl!"));
EndPaint(hwnd,&pt);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否退出应用程序?","退出对话框",MB_YESNO))
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
ATOM InitWindow(HINSTANCE Hinstance)
{
WNDCLASS wcls;
wcls.lpszClassName="direct3d";
wcls.cbClsExtra=0;
wcls.cbWndExtra=0;
wcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wcls.hIcon=LoadIcon(NULL,IDI_ASTERISK);
wcls.hInstance=Hinstance;
wcls.lpfnWndProc=WndProc;
wcls.lpszMenuName=NULL;
wcls.style=CS_VREDRAW;
return RegisterClass(&wcls);
}
VOID Create_Show_UpdateWindow(HINSTANCE hInstance)
{
hWnd=CreateWindow("direct3d","TheFirstWindow!",WS_OVERLAPPEDWINDOW,0,0,600,450,NULL,NULL,hInstance,NULL);
if(!hWnd)
{
MessageBox(hWnd,"Create unsuccessed!","dd",MB_OK);
}
ShowWindow(hWnd,SW_SHOWDEFAULT);
UpdateWindow(hWnd);
}
int WINAPI WinMain(HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
InitWindow(hInstance);
Create_Show_UpdateWindow(hInstance);
MSG msg;
while(msg.message!=WM_QUIT)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -