Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a modal window(1st window) inside which another window(2nd window) gets called, when 1st window is maximized it does not call for ShowWindow() function which in turn 2nd window is not launched by default and secondly when the 1st window is restored the 2nd window is launched i.e ShowWindow() is called.

Can someone tell me why when window is maximized ShowWindow() is not called? When I explicitly pass WM_SHOWWINDOW by postmessage() in initDialog() 2nd window launches.

Thanks,
Posted

1 solution

It can be resolved, but why? Here is my advice: never ever show anything on top of modal window/dialog. Doing so is a clear indication that your UI design needs to be seriously and critically reviewed.

Yes, this is a typical behavior for some Microsoft applications, such as Control Panel applet in Windows, but why follow apparently bad samples of UI design? Probably Microsoft does it because they have a log of legacy code.

—SA
 
Share this answer
 
Comments
pasztorpisti 24-Feb-14 20:05pm    
In my opinion showing a modal window (e.g.: by opening a modal dialog from another modal dialog) is OK, people are used to this design. Whether it is a good design or not is a good subject for debate: some software, typically "editor" programs like Blender3D have a UI design philosophy that everything should be modeless and everything is just a view to a fraction of the edited data. The input is also extremely practical: left hand - keyboard, right hand - mouse, and the keyboard events always go the the views that are under the mouse cursor. Its another problem that most people cant even place a cube inside the editor when they first open it but still, it provides one of the best user interfaces that facilitate extremely fast user interaction. Still, recently they have implemented a "classical" setup probably to attract more casual users.

Here OP probably has a different problem: He tries to solve a problem by using very ugly hack. When it comes to window messages and their order/occurrence in some specific cases (like "when this and that is maximized") then window messages get totally unpredictable and your program becomes vulnerable to window version changes, and not only windows version changes but also to changing the window manager on the same machine!!! (like aero to classical...) Message orders may change, some messages may disappear in some cases.
Sergey Alexandrovich Kryukov 24-Feb-14 20:11pm    
I cannot and don't want to argue with you on this, just because this is not an extremely principle issue. Nevertheless, I would still advise what I advised, because it will be a useful practical rule and will cause minimum trouble, while having nicer design.

Do you have better advice which would keep to OP's design decision? Do you think it worth doing?

—SA
pasztorpisti 24-Feb-14 20:51pm    
The problem OP is struggling with is a common problem. Window state changes (like minimizing/maximizing/showing/hiding - tied to WM_WINDOWPOSCHANGED) are often unreliable and hard to detect and they have corner cases (like different behavior for maximized windows). I've recently fixed a similar hacky code where minimizing/bringing back a window removed the maximized state from its parent (yes, the child window was also top level, dont ask why...) - that bug was also related to WM_WINDOWPOSCHANGED. WM_WINDOWPOSCHANGED is evil, I have fixed tons of bugs related to this and its better to avoid attaching event handlers to it whenever possible (especially because the windows version/window manager related differences).

From the words of OP I suspect that he uses the wrong event to show the second dialog anyway... And reading the question again I don't know what he wants to do. Using PostMessage() to send WM_SHOWWINDOW is also a bad idea, I would use SendMessage() for a more deterministic behavior.
Sergey Alexandrovich Kryukov 24-Feb-14 21:15pm    
Understood...
Thank you.
—SA
Member 10433549 25-Feb-14 2:29am    
Thanks for help, can you please once again see my below post.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900