?
Solved

Maximizing in MDI

Posted on 1997-11-12
5
Medium Priority
?
551 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
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.

0
 
LVL 22

Author Comment

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

Author Comment

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

Author Comment

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

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

762 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