1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <windows.h>
LPCTSTR clsName = L"renClass";
LPCTSTR WndName = L"RenWindow";
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,LPARAM lParam,WPARAM wParam);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lCmdLine,
int nCmdShow)
{
MSG msg;
HWND hWnd;
WNDCLASSEX renWin;
renWin.cbSize = sizeof(WNDCLASSEX);
renWin.style = CS_HREDRAW | CS_VREDRAW;
renWin.cbClsExtra = 0;
renWin.cbWndExtra = 0;
renWin.lpfnWndProc = WndProc;
renWin.hInstance = hInstance;
renWin.hIcon = LoadIcon(NULL,IDI_APPLICATION);
renWin.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
renWin.hCursor = LoadCursor(NULL,IDC_ARROW);
renWin.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
renWin.lpszMenuName = NULL;
renWin.lpszClassName = clsName;
RegisterClassEx(&renWin);
hWnd = CreateWindow(clsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
return 0;
ShowWindow(hWnd,SW_SHOWNORMAL);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
};
return msg.wParam;
};
LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,LPARAM lParam,WPARAM wParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd,msg,lParam,wParam);
}
return 0;
};
|