CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Location
    Manitoba, Canada
    Posts
    82

    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!



  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: I'm Confused! GetWindowRect / MoveWindow

    Check out ScreenToClient() and ClientToScreen().

    Regards,

    Paul McKenzie


  3. #3
    Guest

    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);




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured