1

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.

D13
  • 123
  • 3
  • 12

1 Answers1

1

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.

Community
  • 1
  • 1
Jammerx2
  • 794
  • 4
  • 12
  • I tried it just now and it totally made the window unable to simulate minimize from taskbar at all. Same for simple window with same setup and it also cant simulate minimize from taskbar. Edit: Sorry for the late comment, testing it right now. Edit2: Thanks a lot you saved me there.. have been searching the solution since yesterday and I didn't know I made a mistake in the style settings in the first place. – D13 Sep 21 '13 at 07:26