-
December 6th, 2010, 05:02 AM
#1
SetWindowPos problem.
Hi all,
I'm using SetWindowPos() to resize my dialog size according to the program state.
(A state can be received at any point during the program execution.)
My problem is that the dialog size gets overriden by windows when the following occurs.
1. The user clicks on the dialog title and hold the left button pressed to reposition the window.
2. the program receive an event and the dialog size needs to be resized so a call to SetWindowPos is made (At this point the dialog size looks correct)
3. The user releases the mouse button and the dialog is resized to the previews size!
Can anyone please help me to overcome this problem?
Many thanks!!
-
December 6th, 2010, 05:54 AM
#2
Re: SetWindowPos problem.
Is it allowed for a user to change the dialog size (at any time)?
-
December 6th, 2010, 06:20 AM
#3
Re: SetWindowPos problem.
No, the users are not allowed to change the dialog size.
-
December 6th, 2010, 07:23 AM
#4
Re: SetWindowPos problem.
Then you can prevent the user from resizing. You can catch WM_SYSCOMMAND and don't do anything for SC_SIZE. Or, better, simply remove the command from the menu.
Code:
CMenu* pSysMenu = GetSystemMenu(FALSE);
if(pSysMenu != NULL)
pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
Last edited by cilu; December 6th, 2010 at 09:09 AM.
-
December 6th, 2010, 07:58 AM
#5
Re: SetWindowPos problem.
Cilu, thank you for you quick reply.
I think that I didn't clarify my question good enough.
The users are unable to resize the dialog but they can still reposition the window (by clicking on the dialog title and moving the window while the left button is pressed , standard Windows ).
The problem is that if the user clicks on the window title (to move the window) and I call SetWindowPos before the user releases the left button then the dialog size will be restored to the size it was when the user first clicked on the left button...
1. user click on the window title to reposition the window (left button is pressed).
2. I call SetWindowPos() to resize the window size (works fine)
3. The user releases the left button and the dialog size is changed to the size it was before I called SetWindowPos.
If the user doesn't click on the window title while I call SetWindowPos everything works just fine...
Please help!
Last edited by Salvadoravi; December 6th, 2010 at 08:11 AM.
-
December 6th, 2010, 08:12 AM
#6
Re: SetWindowPos problem.
Originally Posted by Salvadoravi
No, the users are not allowed to change the dialog size.
Why don't you change the border style so they can't resize. Or, handle the mouse up button and call SetWindowPos there.
-
December 6th, 2010, 08:52 AM
#7
Re: SetWindowPos problem.
What is the event you were reacting at?
If it is WM_SIZE (::OnSize) you probably better would handle WM_SIZING (::OnSizing) cause the latter would be fired before the sizing already happened, i. e. you would be able to correct the size prior to the window being already drawn.
If the event neither is any of the above (???) you would need to retrieve the current sizes before calling SetWindowPos though that still could fail as the messages and events actually might come later than you were handling the sizing.
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
|