1

I'm working on an application frame using native C and win32 API. Writing handlers for placing an owned window inside the frame depending on user manipulation. So far I have:

case WM_WINDOWPOSCHANGED:

    GetWindowRect(hwnd, &rect);
    SetWindowPos(
        hexp, HWND_TOP, rect.left + 5, rect.top + 30,
            0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );

It works great except I don't seem able to restore it from a minimized state. I've searched the forum and tried a couple of things with the SC_RESTORE handler including:

case SC_RESTORE:

    ShowWindow(hwnd, SW_RESTORE);
    SetForegroundWindow(hwnd);
    BringWindowToTop(hwnd);    // Doesn't work

I've also tried:

case SC_RESTORE:

    SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);    // no luck either

Nothing seems to work. I have to right click and choose restore when the application is minimized for now. Any clues would be most welcome.

** Update ** I found an improvement.

First of all not sure its a good idea to use the WM_WINDOWPOSCHANGED event to manipulate a lot of windows. The system seems to trigger that a lot. Also while I'm still using it I've decided to check if the window is minimized first. It seems the system was continuing to check for position changes while minimised. That's what apparently made the taskbar hang. It's working much better now thanks. Forcing things doesn't seem to be a good way to go about it either :/

2
  • If you have solved your problem, You should add the solution as an answer and accept it.
    – Mark Hall
    Commented Feb 3, 2012 at 19:57
  • Thanks I can do that tomorrow apparently.
    – Chuck
    Commented Feb 4, 2012 at 11:01

1 Answer 1

1

I wonder if we're allowed to answer our own questions. Well I never touched C with the API much and it looks like I started out from a "wrong" concept. I thought I was going to write a frame that owns and manages windows and it turns out the os is telling me to get lost. It seems the whole thing is entering "Idle mode" and hangs on the taskbar. And then I realise that there already is windows that are ready to be managed. They are called "Dialogs". So I'll stop trying to glue windows together and working with proper dialogs. It's been a fun experimentation path this side. Sry to take your time with newbie questions. Well now you know if your window hangs on the taskbar "Windows" dropped it and it'll never come back.

Now to get back on track :\

Not the answer you're looking for? Browse other questions tagged or ask your own question.