Solved

Maximizing in MDI

Posted on 1997-11-12
5
542 Views
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?
0
Comment
Question by:nietod
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 70 total points
Comment Utility
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.

0
 
LVL 22

Author Comment

by:nietod
Comment Utility
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.
0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
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.
0
 
LVL 22

Author Comment

by:nietod
Comment Utility
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.
0
 
LVL 22

Author Comment

by:nietod
Comment Utility
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.)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now