4
votes

I have a top-level window that was created with WS_POPUP / WS_EX_APPWINDOW so it uses non-standard frame and its caption appears on taskbar. Yet I have custom WM_NCHITTEST handler if that matters.

When the window is "collapsed to taskbar" (removed from screen) and user clicks on its icon/caption on taskbar the window is getting WM_QUERYOPEN message and gets opened by DefWindowProc.

But when the window is opened and user clicks on its icon/caption in taskbar the window just gets deactivated - I need to collapse it.

Are there any messages sent by shell to the window when mouse is on its caption in taskbar?

I am trying to reproduce standard Windows Shell behavior - first click on taskbar's window icon reveals the window and second click - hides it. First part (revealing) works by default but not the second (hiding).

UPDATE: Here are messages that my window gets when it is on screen and user clicks on its caption in taskbar:

<01287> 00150DAE S WM_NCACTIVATE fActive:False
<01288> 00150DAE R WM_NCACTIVATE fDeactivateOK:True
<01289> 00150DAE S WM_ACTIVATE fActive:WA_INACTIVE fMinimized:False hwndPrevious:(null)
<01290> 00150DAE R WM_ACTIVATE
<01291> 00150DAE S WM_ACTIVATEAPP fActive:False dwThreadID:000041EC
<01292> 00150DAE R WM_ACTIVATEAPP
<01293> 00150DAE S WM_KILLFOCUS hwndGetFocus:(null)
<01294> 00150DAE R WM_KILLFOCUS
<01295> 00150DAE S WM_IME_SETCONTEXT fSet:0 iShow:C000000F
<01296> 00150DAE S WM_IME_NOTIFY dwCommand:IMN_CLOSESTATUSWINDOW dwCommand:00000001 dwData:00000000
<01297> 00150DAE R WM_IME_NOTIFY
<01298> 00150DAE R WM_IME_SETCONTEXT

Window styles: WS_POPUP | WS_VISIBLE | WS_SYSMENU

Window ex-styles: WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_APPWINDOW

If that matters the window looks like this:

enter image description here

That's just a test.

1
I'd assume that WM_SIZE is sent too late (i.e. when the window has already been minimized), but maybe WM_WINDOWPOSCHANGING could be helpful, with the undocumented SWP_STATECHANGED flag.IInspectable
When window is on screen and you click on its icon in taskbar its position is not changing. And indeed, I do not see any WM_POSWINDOWCHANGING messages on it. Only WM_ACTIVATE as focus goes from the window to taskbar.c-smile
Not very likely, without a system menu, but does your window receive a WM_SYSCOMMAND message?IInspectable
Have you tried using Spy++ to see what messages are sent to your window and/or its owner window? See msdn.microsoft.com/en-us/library/dd460725.aspxStuart
You can try to add WS_MINIMIZEBOX to the windows style like this: WS_POPUP | WS_MINIMIZEBOX.VuVirt

1 Answers

2
votes

You can try to add WS_MINIMIZEBOX to the window style like this: WS_POPUP | WS_MINIMIZEBOX.