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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include<windows.h>
#include<stdio.h>
int int_AppRunning = 1;
LRESULT CALLBACK OurWindowProcedure(HWND han_Wind,UINT uint_Message,WPARAM parameter1,LPARAM parameter2)
{
switch(uint_Message)
{
case WM_LBUTTONUP:
{
int_AppRunning = WM_LBUTTONUP;
break;
}
case WM_LBUTTONDOWN:
{
int_AppRunning = WM_LBUTTONDOWN;
break;
}
case WM_RBUTTONDOWN:
{
int_AppRunning = WM_RBUTTONDOWN;
break;
}
case WM_KEYDOWN:
{
int_AppRunning = 0;
break;
}
break;
}
return DefWindowProc(han_Wind,uint_Message,parameter1,parameter2);
}
HWND NewWindow(LPCTSTR str_Title,int int_XPos, int int_YPos, int int_Width, int int_Height)
{
WNDCLASSEX wnd_Structure;
wnd_Structure.cbSize = sizeof(WNDCLASSEX);
wnd_Structure.style = CS_HREDRAW | CS_VREDRAW;
wnd_Structure.lpfnWndProc = OurWindowProcedure;
wnd_Structure.cbClsExtra = 0;
wnd_Structure.cbWndExtra = 0;
wnd_Structure.hInstance = GetModuleHandle(NULL);
wnd_Structure.hIcon = NULL;
wnd_Structure.hCursor = NULL;
wnd_Structure.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
wnd_Structure.lpszMenuName = NULL;
wnd_Structure.lpszClassName = "WindowClassName";
wnd_Structure.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wnd_Structure);
return CreateWindowEx(WS_EX_CONTROLPARENT, "WindowClassName", str_Title, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, int_XPos, int_YPos, int_Width, int_Height, NULL, NULL, GetModuleHandle(NULL), NULL);
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreviousInstance,LPSTR lpcmdline,int nCmdShow)
{
MSG msg_Message;
FILE *outFile;
char name[100];
int count = 0;
HWND han_Window = NewWindow("DirectX C++ Tutorial",100,100,500,500);
while(int_AppRunning > 0)
{
count++;
if(PeekMessage(&msg_Message,han_Window,0,0,PM_REMOVE))
{
if(!IsDialogMessage(han_Window,&msg_Message))
{
DispatchMessage(&msg_Message);
}
}
if (int_AppRunning == WM_LBUTTONUP)
{
MessageBox(han_Window,"left mouse up","InitializeDevice()",MB_OK);
}
else if (int_AppRunning == WM_LBUTTONDOWN)
{
MessageBox(han_Window,"left mouse down","InitializeDevice()",MB_OK);
}
else if (int_AppRunning == WM_RBUTTONDOWN)
{
MessageBox(han_Window,"right mouse down","InitializeDevice()",MB_OK);
}
else if (int_AppRunning == 0)
{
MessageBox(han_Window,"you pressed a key, exiting","InitializeDevice()",MB_OK);
}
if (int_AppRunning > 0) int_AppRunning = 999;
}
DestroyWindow(han_Window);
return 0;
}
|