#include <windows.h>
const int TAR_HIGH=800;
const int TAR_WEIGHT=600;
const wchar_t TAR_TITLE[]=L"FFFF团力作-建大英雄传";
LRESULT CALLBACK SdjzuProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_PAINT:
ValidateRect(hwnd,NULL);
break;
case WM_KEYDOWN:
if(wParam=VK_ESCAPE)
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd )
{
WNDCLASSEX wndclass={0};
wndclass.cbSize=sizeof(WNDCLASSEX);
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=SdjzuProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=(HICON)::LoadImage(NULL,L"tarico.ico",IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=L"sdjzuhero";
//注册窗口
if(!RegisterClassEx(&wndclass))
return -1;
HWND hwnd=CreateWindow(L"sdjzuhero",TAR_TITLE,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,TAR_HIGH,TAR_WEIGHT,NULL,NULL,hInstance,NULL);//第三个参数控制了窗口的样式,合集为WS_OVERLAPPEDWINDOW
MoveWindow(hwnd,250,80,TAR_HIGH,TAR_WEIGHT,true);
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
MSG msg={0};
while(msg.message!=WM_QUIT)
{
if(PeekMessage(&msg,0,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
UnregisterClass(L"sdjzuhero",wndclass.hInstance);
return 0;
}
备忘…………存档用,具体不解释。【备忘】一个标准的win32窗口框架