|
-
February 2nd, 2010, 07:13 AM
#1
SetWindowPos() problem
I have a small MFC dialog app that gets an event notification when I receive an email.
In my OnEmailEvent() event handler I resize the dialog so it will fit to the size of the email.
Code:
void OnEmailEvent()
{
this->SetWindowPos( &wndTopMost, 0, 0, m_rcDialog.Width(), m_rcDialog.Height(), SWP_NOMOVE );
}
Everything is working great BUT there is an edge case (bug??) that I've failed to solve when the following sequence of events happens:
1. The user clicks on the dialog window title and hold the mouse button pressed.
2. An email is received so the OnEmailEvent function is triggered and the dialog gets resized.
3. The user releases the mouse button and the dialog will be resized again to what it was BEFORE the event handler resized it.
Is there a way to overcome this?
Please help!!
Many thanks
-
February 2nd, 2010, 10:54 AM
#2
Re: SetWindowPos() problem
It's a bug definitely. But not in the OS code. Unless you execute specific code regarding window size or placement, the size of a window will not change.
Most likely the OnLButtonUp message handler calls directly or indirectly such a code. Look for it.
If you can't find anything, there's another solution, involving more work but granting results surely. Place TRACE0 statements in all the places were you have code modifying the size or placement of your window and watch which one is executed.
Not only resizing and moving, but also the quick destruction and re-creation of the window can generate the same undesired effect.
-
February 2nd, 2010, 01:39 PM
#3
Re: SetWindowPos() problem
Guard the mouse up event. In the OnEmailEvent, set a m_bEmailResizeEvent flag, and in the OnMouseUp event, check if the flag has been set and if it has, skip the resize operation this time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|