Search code examples
mfcwindows-10windows-messages

MFC App Can't Maximize Only In Administrator Mode


I've got an MFC app on Windows 10 that has the maximize button disabled as it wasn't designed to be resized. If the program is run not as administrator/elevated then the user can minimize the window to the taskbar and then restore/maximize it like normal. However, if the app is run as administrator/elevated privileges then the window can be minimized to the taskbar but never restored/maximized.

Things I've tried:

  • Left-clicking the icon on the taskbar - nothing happens.
  • Hovering over the icon on the taskbar then hovering over the tiny preview above the icon - this shows the window but goes away as soon as you stop hovering and clicking on the small preview does nothing.
  • Enabling the maximize button and setting the NoActivate property to true - doesn't help.
  • Alt-tabbing to the application does not do anything.
  • I've inspected the app when it has this issue using spy++ 64 and I can see the messages but I'm not sure what's wrong. See below

This is the log of the successful (non-admin) minimize then maximize where the maximize attempt happened around ID 290: https://pastebin.com/kRT4ABrC

This is the log of the unsuccessful (admin) minimize then maximize where the maximize attempt happened around ID 176: https://pastebin.com/nAiXUa8p

Anyone have any ideas what is wrong? It does look like the unsuccessful log is missing a bunch of WM_ACTIVATEAPP messages, but I'm not sure what else looks off.

"code" necessary for pastebin link posts

Solution

  • Found the issue! I searched our code for "WM" and found a few custom message handlers including one for ON_WM_MOVE (See for more info.). I still don't understand why it causes an issue, but removing it gives us the desired effect. Below is the code that was causing the issue for anyone curious. The positionPages method is custom code that may be the culprit:

    void CMyDlg::OnMove(int x, int y)
    {
        CDialogEx::OnMove(x, y);
        positionPages(false); // This keeps the page being displayed in the right location
    }