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.

:sad: it seems i'm being ignored, I wonder what I'm doing wrong??

do you believe I am not doing any work myself?

do you not beleive that this is now homework of any sort!?

am I being discourtious? I havn't claimed my query was more important than anyone elses, although this seems to get a responce although yu dont seem to like it! I admit i didn't use Please or Ty :sad:

Is this thread too difficult? *hint* *hint*

have I given too little detail, too little code?

should this be moved into a differant forum?
I beleive that "Game Developement" may have been more appropriate but I did not know of its existance then.

(maybe the real reason I made this post has as a shameful BUMP post)

All, i can say is that this is shamefull, it takes me 3 hours to find out that the device is lost in DX9 when windows are switched, I had searched everywhere! I found it on a Managed C# Forum and im writing in Native C++ even if the solution they posted was as good as useless the idea behind it I could embedd into my existing code!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.