Thread: MessageBox de-maximizes window

  1. #1
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591

    MessageBox de-maximizes window

    If I use MessageBox() to create a simple message box for my window (to be specific a Dialog Box), if it is maximized, MessageBox will de-maximize (restore to its original size) the window. I'm not sure if this is the intended behaviour, but is there anyway to prevent this?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    That’s interesting - I don’ t think that’s intended behavior.

    Remember that MessageBox() has it’s own message loop. So even if you’re calling it from within your message handler, messages can still be processed.

    If that doesn’t help any, you could zip up a small demo app the shows the issue.

    gg

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Meaning I could respond to a WM_SIZE message and stop it from de-maximizing?... I tried this, and it works well in forcing the window to re-maximize (although when the MessageBox pops up you can still see it quickly restoring then maximizing again in the background instead of maintaining its maximized state as would have been nice), unfortunately though, there's no real way of distinguishing between when the user is intentionally de-maximizing the window or when the message box is (SC_RESTORE is one indicator, however I quickly found out there are other user-initiated ways of restoring a window without SC_RESTORE's involvement, i.e. double-clicking the caption bar).
    I've checked my application again, and this appears to be happening with any form of pop-up (i.e. if I launch another dialog box from it, it will de-maximize the window as well). Maybe this is because the window I am using was created by DialogBox, or am I just doing/returning something wrong?
    I could go through all the work to transform my Dialog Box into a registered window and use CreateWindow instead, though I would still think it odd that DialogBoxes should be de-maximized by default when pop-ups occur from them...

    here is a copy of my application (does not contain all files, just the .exe). To see what is happening, click "yes" to the first prompt to bring you to the window entitled "Setup", and then maximize it. Once maximized, click any of the first 4 buttons, or the Close button. Any of these will launch a pop-up/dialog box which will promptly de-maximize the window.



    Link removed by moderator. Sorry. Policy is to supply the source, not the executable.
    Cornedbee
    Last edited by CornedBee; 09-06-2007 at 04:57 PM.

  4. #4
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    I've just tried a sample simple window demo and it turns it that this did not occur with a registered window, which leads me to believe more now that this is an issue with Dialog Boxes only. Furthermore, I've noticed now that this occurs even when switching windows (i.e. alt-tabbing out of the dialog box also de-maximizes it). I have no idea what is causing this. My dialog box is defined as so in my resource file:
    Code:
    IDD_DIALOG DIALOGEX DISCARDABLE 5, 0, 0, 0
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_SHELLFONT | WS_MINIMIZEBOX
    CAPTION "Setup"
    FONT 8, "MS Shell Dlg"
    {
    }
    and has the following styles added to it during run-time:
    Code:
     WS_SIZEBOX | WS_MAXIMIZEBOX

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Error in reading from file
    By paulovitorbal in forum C Programming
    Replies: 4
    Last Post: 05-02-2006, 06:15 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM