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
|
#include <windows.h>
#include <d3d11.h>
#include <math.h>
HINSTANCE hInstance;
HWND hWnd;
/*int nCmdShow = SW_SHOWMAXIMIZED;*/
WNDPROC wndProc; LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //window procedure
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) //app entrypoint
{
WNDCLASSEX wnd; //structure declaration
UINT uMsg = {0}; //message declaration
wnd.cbSize = sizeof(WNDCLASSEX);
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wnd.hCursor = LoadCursor(hInstance,IDC_ARROW);
wnd.hIcon = LoadIcon(hInstance,IDC_ARROW);
wnd.hInstance = hInstance;
wnd.lpfnWndProc = wndProc;
wnd.lpszClassName = L"psiEngineMain";
wnd.lpszMenuName = L"MainMenu";
wnd.hIconSm = NULL;
if(!RegisterClassEx(&wnd)) //register class with system
return false;
HWND main_window = CreateWindow(L"psiEngineMain",L"Psi Engine v. 0.01 Alpha",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, //create the window which will be shown
CW_USEDEFAULT,0,0,0,0,hInstance,0);
ShowWindow(main_window,SW_SHOWDEFAULT); //show window
UpdateWindow(main_window); //update window
while(GetMessage((LPMSG)uMsg,hWnd,0,0) != false){
TranslateMessage((LPMSG)uMsg);
DispatchMessage((LPMSG)uMsg);
}
switch (uMsg){
case WM_PAINT:
UpdateWindow(main_window);
MessageBox(NULL,L"Window opened successfully",L"Welcome!",MB_OKCANCEL);
break;
case WM_QUIT:
PostQuitMessage(true);
break;
case WM_DESTROY:
DestroyWindow(hWnd); //close window
break;
}
return uMsg;
}
|