Why does moving a Form cause the Resize event to fire?

P

Peter Anthony

It seems kind of strange that if a Form is just moved that Resize events
fire. This makes it hard to tell the difference betweeen resizing and moving
a Form.

I can understand why resizing might also be considered a move (since the
Form's location can be thought to be based on one from Top/Bottom and one
from Left/Right, and some of these WILL change when resizing), but can't
understand why JUST moving is considered resizing. I was trying to create an
automatic pop-up window that shows the size dimensions (w,h) of the Form as
it is being resized. But it also comes up when I'm moving the Form, which
looks odd.

I suppose I could keep track of the size of the Form and then ignore any
Resize event if the size is unchanged. But IMHO that's a kludgy work around,
since IMHO Resize events should not fire if the Form doesn't change size!
 
C

Cholo Lennon

What version are you using? I tested it on C++ CLI 2005 SP1 (W2k) with a simple
form (with default properties) and I couldn't reproduce your behavior. When I
move the form I receive Move event, when I resize I receive Resize event.

Check with Spy++ the reception and the order of the following messages
WM_MOVING, WM_MOVE, WM_SIZE, WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED to
discard .Net framework bug(s).


Regards
 
P

Peter Anthony

I'm using VC++ 2008 Express (beta 2) /CLI on both Vista and XP machines
(home and work).

I did an experiment. I set a breakpoint in my ResizeStart even handler. I
then just moved the form (using the top bar and dragging). The breakpoint
was hit immediately.

I solved it by saving the old size of the form and ignore any Resize events
unless the form actually changes size. This works quite well.

Never used Spy++, don't even know what it is. Sounds like a debug tool to
capture windows messages. Is it part of VC++, or is it 3rd party, or an MS
download, ...?
 
C

Cholo Lennon

Ohh I've not tested VC++ 2008 Express / Vista yet, so I can't help you :-(

Yes, Spy++ is a tool to monitor window messages. Spy++ is a microsoft
application that comes with VS.
You can use a free replacement tool for Spy++ called Winspector
(http://www.windows-spy.com/)

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top