Ive been writing a DirectX application for some time and there has been a bug that I have been unable to fix, but this is to do wth the Windowsx API.
I can run my DirectX application (Fullscreen) fine, but when I Minimise it then restore, fullscreen mode does not return.
This isnt homework btw!
#include "main.h"
// the WindowProc function prototype
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = "GameClass";
RegisterClassEx(&wc);
hWnd = CreateWindowEx(NULL,
"GameClass",
"GameDemo",
WS_EX_TOPMOST | WS_POPUP,
0, 0,
SCREEN_WIDTH, SCREEN_HEIGHT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd, nCmdShow);
G_Init(hWnd);
MSG msg;
while(TRUE)
{
DWORD starting_point = GetTickCount();
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
G_Render();
// if pressing ESCAPE send WM_DESTROY
if(KEY_DOWN(VK_ESCAPE)) {
PostMessage(hWnd, WM_DESTROY, 0, 0);
}
while ((GetTickCount() - starting_point) < 25);
}
G_Clean();
return msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
case WM_SETFOCUS:
{
// what to put???
} break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
Also note that the background colour of the window is WHITE a WHITE empty box appears in the top left covering a the same distance as SCREEN_WIDTH and SCREEN_HEIGHT, which are my fullscreen rosolution definitions.