Problem resizing control in dialog!
Hi Gurus!
I've a very weird problem! I want to resize a picture control inside a dialog. I designed the dialog including its controls.
In the program I wrote the following lines:
// Get window size
CRect rect;
m_preview.GetWindowRect(&rect);
m_preview.MoveWindow(&rect);
It should show the control exactly the same as I placed it inside the dialog.....but it moves the picture control a few pixels down.
Any ideas why is this happening?
Thanks!
Re: Problem resizing control in dialog!
Run thru debugger for actual values of the RECT and also read up documentation on MSDN. You'll figure out whats happening..
Re: Problem resizing control in dialog!
You should convert the rectangle from the screen to the client coordinates of the dialog before you call MoveWindow function.
Code:
CRect rect;
m_preview.GetWindowRect(&rect);
this->ScreenToClient(rect);
m_preview.MoveWindow(&rect);
// where this is a pointer to your dialog box
Re: Problem resizing control in dialog!
Thanks a lot for all your help!
Re: Problem resizing control in dialog!
Quote:
Originally Posted by amarcode
// where this is a pointer to your dialog box
[/code]
:rolleyes:
this is absolutely unnecessary.
Re: Problem resizing control in dialog!
Quote:
Originally Posted by JohnCz
:rolleyes:
this is absolutely unnecessary.
I know it. I only wanted to point that the code shuld be placed in the dialog box class.