1
votes

I'm making a custom caption bar with custom draw buttons by removing the window default bar with SetWindowLong(hWndParent, GWL_STYLE, 0). Everything is going good by now except I'm stuck at making my window minimize by clicking the taskbar programmatically. I'm trying the WM_ACTIVATEAPP right now but the window are unable to minimize properly.

This is the code for WM_ACTIVATEAPP for main window:

case WM_ACTIVATEAPP:
    if(LOWORD(wParam) == FALSE)
        SendMessage(hWndParent,WM_SYSCOMMAND,SC_MINIMIZE,NULL);
    break;

When you left click the task bar,it will minimize BUT once you released the click.. the window will be restored.. Is there something missing? I want to make it minimize after you release the click.

Notes: I dint put the activate window code because the window seems to be able to restore itself by clicking the taskbar after being minimized with custom draw button.

1

1 Answers

1
votes

You're probably not handling WM_NCACTIVATE as well. Try handling it, similar to this:

case WM_NCACTIVATE:
    break;
case WM_ACTIVATEAPP:
    if (LOWORD(wParam) == FALSE)
        SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, NULL);
    break;

Edit:

I must have missed the part of your question where you said you removed the default bar by setting the style to 0. That is definitely not the proper way to do it, you should do something along the lines of this, as found here:

LONG lStyle = GetWindowLong(hWnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
SetWindowLong(hWnd, GWL_STYLE, lStyle);

After you do that you should no longer need to handle WM_ACTIVATEAPP or WM_NCACTIVATE to properly minimize/maximize the window.