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 69 70 71 72 73 74 75 76 77
|
#include <windows.h>
HRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
LPCTSTR CLASSNAME=L"ProjectX-Class";
WNDCLASSEX wcex;
wcex.cbClsExtra=0;
wcex.cbSize=sizeof(WNDCLASSEX);
wcex.cbWndExtra=0;
wcex.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wcex.hCursor=NULL;
wcex.hIcon=NULL;
wcex.hIconSm=NULL;
wcex.hInstance=hInstance;
wcex.lpfnWndProc=WindowProc;
wcex.lpszClassName=CLASSNAME;
wcex.lpszMenuName=NULL;
wcex.style=0;
ATOM atom=RegisterClassEx(&wcex);
if(atom==0)
{
MessageBox(NULL,L"Windows Class Registration Failed!!!\nPlease try again later!",
NULL,MB_OK|MB_ICONERROR);
return 1;
}
HWND hwnd;
hwnd=CreateWindowEx(0,CLASSNAME,TEXT("Project-X"),WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
if(hwnd==NULL)
{
MessageBox(NULL,L"Window Creation Failed!!!\nPlease try again later!",NULL,MB_OK|MB_ICONERROR);
return 1;
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.lParam;
}
HRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_CLOSE:
if(MessageBox(hwnd,L"Are you sure you want to quiit the Project-X application?",
L"Warning...",MB_ICONQUESTION|MB_YESNO)==IDYES)
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
DefWindowProc(hwnd,uMsg,wParam,lParam);
break;
}
return 0;
}
|