Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Maximizing in MDI

Posted on 1997-11-12
Medium Priority
Last Modified: 2013-12-03
I'm writting an MDI-like interface that does not use the standard windows MDI classes and procedures.  I have a couple of questions involving maximizing/minimizing the MDI child (document windows).  

1.  I need to know how to tell when a MDI child window has be maximized, minimized, or restored.  What is the best message (or messages) to "hook" for this.  WM_SYSCOMMAND, WM_WINDOWPOSCHANGED or is there some other.  I don't want to hook a message that occurs only in some cases, like will the SYSCOMMAND message always occur, regardless of how the window is maximized.minimized.

2.  The default behavior for maximizing a window is that it enlarges to fill the parent's client area.  However, it still has its title (caption).  The standard MDI behavior is that the title should disappear.  How should I do this?  Do I want to resize the MDI child window's client area to fill its window frame (leaving no room for the title)?  Do I want to change the window styles so there is no caption?   (I don't even know if that can be done)  Or is there a better way?

3.  How does a program make a window maximize or minimize?  Should is send a WM_SYSCOMMAND message to the window or is there a better way?
Question by:nietod
  • 3
  • 2
LVL 15

Accepted Solution

Tommy Hui earned 210 total points
ID: 1408360
1. The WM_SYSCOMMAND will be sent whenever the user does anything to cause it to minimize or maximize (by pressing the corresponding caption buttons or the system menu). You can catch the WPARAM to see what happened. Look in the header files for SC_xxx IDs.

2. If you resize the child, you still have the caption, so that won't work. The best guess would be to remove the caption by changing its style: use GetWindowLong(GWL_STYLE) and mask out WS_CAPTION. Make sure the child does not have a style that implies a caption like WS_OVERLAPPEDWINDOW.

3. You can send the window a WM_SYSCOMMAND with the appropriate SC_xxx in WPARAM.

LVL 22

Author Comment

ID: 1408361
I'm not 100% sure of a couple points.  (Actually they are related) I realize that the WM_SYSCOMMAND message occurs when the window is maximized/minimized using the menus or buttons, but my concern is there some other way a window could be maximized/minimized where the messages would not be sent.  For example, is there an API command (or some event) that does it without sending the messages.  

Kinda related to that, is how do I maximize/minimize a window "manually"?  I realize that sending the SYSCOMMAND will work, but does that just cause the Default window procedure to call some API command or is that it?

In case this wasn't clear, let me give an example in a similar case.  The WM_CLOSE message is sent when ever the close box is hit.  But if I had tasks to perform every time a window was closed, I would not want to hook the WM_CLOSE message because it is not always sent.  For example, if DestroyWindow() is called directly to close a window.  Also, if I want to close a window, I can call DestroyWindow() directly rather than using the WM_CLOSE message (which leads to calling DestroyWindow()).

I suspect that is not an issue with the minimize/maximize case, but I want to make sure that this same sort of design is not in use.

By the way in, question 2, I was proposing resizing the client area so there is no room for a caption in the non-client area.  But if changing the styles works, it is a better way.  I was just afraid that some styles (like the caption) wouldn't change.
LVL 15

Expert Comment

by:Tommy Hui
ID: 1408362
WM_SYSCOMMAND is it for maximizing, minimizing, and restoring a window. That's what the regular MDI child uses to signal certain events in the MDI frame.

WM_CLOSE is not a regular message you would use because that is a request to close the window. It does not mean go away. To know whenever a window is closing, you should catch WM_DESTROY.
LVL 22

Author Comment

ID: 1408363
I understand the close issue.  I just wanted to make sure the same issue wasn't happening with the maximizing.  i.e. is the SYSCOMMAND message a request just like the CLOSE message?  Apparently it is not.  I just wanted to make sure.
LVL 22

Author Comment

ID: 1408364
Thui, it turns out the maximize/minimize process does work just like the close process.  The WM_SYSCOMMAND is just a "request" to perform an action and the default window procedure performs that action using an API procedure.  In this case, the procedure is ShowWindow().  ShowWindow() can be used directly to maximize or minimize a window and it does not result in a WM_SYSCOMMAND.  (Which is what I needed and will greatly simplify my code.)

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question