I've done things like this a number of times, and I've had windows, for example, that
could only be minimized and maximized but never restored. Lots of clever encodings of
state; for example, if it is maximized, then "restore" means "minimize" and if it is
minimized, "restore" means "maximize". I usually end up with a switch statement in the
OnSize handler. Key here is the OnSize handler is called twice: once to actually and
then, having discovered that it is handling a restore from maximize or minimize and then
does the resize, gets called again. So I end up needing a "previous state" variable that
helps drive the state machine.
Again, the key to understanding this is the knowledge that a window that is in the
"maximized" state believes its size to be proper size for a maximized window, and if you
brute-force resize a maximized window (e.g., SetWindowPos), then it is still considered
"maximized" and attempts to re-maximize it will be ignored. "Maximiized" is a state
determined NOT by the window dimensions, but by an internal state flag. So if you set the
window size to be the monitor size of the monitor it is shown on, you visually cannot tell
this from a maximized window. But a restored window can be dragged around, and a
maximized window cannot be dragged around. If you manage to get the mouse on the edge of
a window that is the size of the display, it will allow you to drage the edges and resize
it with the mouse; if the window is physically the same size as a restored window but is
actually maximized, the edge-dragging is inoperable. So "maximized" is a state of mind
which is completely unrelated to its screen size.
Now, here's another interesting manifestation. If I am running a program, say, Visual
Studio, on my main development machine (native: 1920x1200 dpi) but I'm doing it via Remote
Desktop from my Summer Office (the back porch), then the window is the size of my laptop
(1364x768). If it gets dark out here, and the floundivorous beasties come out, and I shut
down my laptop and move into my indoor office and re-atach to my desktop, I find that VS
occupies only a part of my screen. Furthermore, I can't drag it or maximize it to fill my
1920x1200 screen. It is *already* maximized. I first have to *restore* it (using the
button on the caption bar), then if I again *maximize* it (using the button on the caption
bar) then, and only then, does it expand to fill the 1920x1200 area. You can reasonably
claim that this is a bug, in that the WM_DISPLAYCHANGE message is not intelligently
handled, but nearly every program I use behaves this way. Only Microsoft Office
mainstream (Word, Excel, PowerPoint) gets it right. FrontPage does not. CorelDraw Suite
has always gotten it right (at least through X3, the highest version I hve installed at
the moment). So if you *really* want to get it right, the problem is more complex.
joe
joe
Post by David LowndesPost by WoodyPost by David LowndesCan you show us how to reproduce this - by small changes to a stock
MFC project for instance?
The setup I have is complex, and it isn't your typical MFC project. I
will try to describe what I think are the important points. Perhaps
you can see what I'm doing wrong from this.
Sorry.
I suggest that you start with a stock MFC framework application, and
add the minimum key aspects of your application that allow you to
reproduce the problem.
Without doing something like that the problem is too complex (for me
at least) to decipher this way.
Dave
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm