0
votes

In CWinApp::InitInstance() I have:

if (!ProcessShellCommand(cmdInfo))
  return FALSE;
m_pMainWnd->ShowWindow(m_MinimizeOnStartup ? SW_SHOWMINIMIZED : SW_SHOWNORMAL);
m_pMainWnd->UpdateWindow();

But my ShowWindow call is not resulting in an OnSize() or OnShowWindow() callback? During the ProcessShellCommand() those are called a few times as the first OnShowWindow() restores the window size when last shutdown via SetWindowPlacement(). That all works good, restoring to last state, but ProcessShellCommand() afterwards calls ShowWindow with SW_SHOW which causes a my hidden when minimized window to show on the taskbar. Where is the proper place to either show the window or minimize it (to hide it). Basically what happens is the minimize comes in (on SetWindowPlacement(), window is hidden, MFC later calls SW_SHOW which makes it minimized on the taskbar instead of hidden, my forced ShowWindow() doesn't do anything.

TIA!!

1
So it appears when already minimized it doesn't send it if request minimize. - df234987
In Win32 C++ application, I can receive WM_SIZE message even if I set SW_SHOWMINIMIZED via ShowWindowfunction after the window create like this: ShowWindow(hWnd, SW_SHOWMINIMIZED); But you can't receive corresponding OnSize call of MFC, is this your issue right? - Rita Han
yes, there was no OnSize nor OnShowWindow when it was already in that state. I found I could set m_nCmdShow=SW_HIDE in the CAppWnd and then later I would do the SetWindowPlacement() and let it do its thing. However, that function sends a SIZE_RESTORED prior to SIZE_MINIMIZED when using wp->showCmd=SW_SHOWMINIMIZED; so you get a flash of the window before it goes away (since my OnSize will ShowWindow(SW_SHOW) on SIZE_RESTORED if hidden). Not sure if a trick to get around that? - df234987
I took out my ShowWindow(SW_SHOW) on SIZE_RESTORED when not visible and it still ended up showing the window and now without the flash. So I'm good now! - df234987
If the issue solved you can post an answer and accept it. - Rita Han

1 Answers

0
votes

There is no OnSize() nor OnShowWindow() callback on ShowWindow() when already in those states. Set m_nCmdShow=SW_HIDE in CAppWnd then at the end of the InitInstance() call the SetWindowPlacement()