Re: SetWindowPos problem.
Is it allowed for a user to change the dialog size (at any time)?
Re: SetWindowPos problem.
No, the users are not allowed to change the dialog size.
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);
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!
Re: SetWindowPos problem.
Quote:
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.
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.