I'm Confused! GetWindowRect / MoveWindow
I'm a bit confused at the apparent inconsistency between GetWindowRect and MoveWindow (or SetWindowPos) in VC5
I'm using a Static as a "placeholder" for creating a dialog within a dialog but when I do a GetWindowRect of the Static I get SCREEN coordinates and when I do MoveWindow for the dialog it expects coordinates relative to the dialog.
So what's the correct approach -- do I also have to get the dialog's Rect? Am I missing a function somewhere that returns numbers compatible with MoveWindow? Or am I taking entirely the wrong approach and is there an easier way to tell the child dialog where to position itself relative to the parent dialog?
If anyone cares to hazard an explanation -- I'm curious why this inconsistency exists. It seems odd to use two different coordinate systems when getting or setting.
Thanks!
Re: I'm Confused! GetWindowRect / MoveWindow
Check out ScreenToClient() and ClientToScreen().
Regards,
Paul McKenzie
Re: I'm Confused! GetWindowRect / MoveWindow
You should call ScreenToClient in the CWnd derived class (which I guess in your case is a dialog) to convert between the co-ordinate systems...
BOOL Yadda::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
GetDlgItem(IDC_MY_PLACEHOLDER)->GetWindowRect(&rect);
ScreenToClient(&rect);