我在初始化时,把一个子窗体B 贴在 父窗体A上,B的style是Popup, 这为了效果不能改为child,所以想问怎么在初始化得到父窗体的桌面坐标,
当然,也不一定会非在Oninitdialog()获取,变通的方法也可以,只要能达到初始化后看到 B 贴在A上就可以了。

解决方案 »

  1.   

    只要子窗体B知道父窗体A的hwnd,什么你都可以做。
      

  2.   

    是可以的用
    CRect rect;
    ::GetClientRect(this->m_hWnd ,&rect);
    ClientToScreen(&rect);
    获得主窗体的位置大小,将该值传到子窗口类去,来设置子窗口的位置。
      

  3.   

    CRect( POINT topLeft, POINT bottomRight );topLeft
    Specifies the top-left position of CRect.bottomRight
    Specifies the bottom-right position of CRect.
      

  4.   

    CRect( POINT topLeft, POINT bottomRight );topLeft
    Specifies the top-left position of CRect.bottomRight
    Specifies the bottom-right position of CRect.
      

  5.   

    这都不是我想要的!这都只是获父窗体的Rect了,我要是桌面坐标系下的坐标位置。
      

  6.   

    父窗体的Rect就是桌面坐标....
    你再试试这样.肯定行
    CRect rect;
    this->GetWindowRect (&rect);
      

  7.   

    CRect r;
    GetWindowRect(&r);
    /*
    CString s;
    s.Format("left:%d top:%d right:%d bottom:%d width:%d height:%d",
      r.left,r.top,r.right,r.bottom,r.Width(),r.Height());
    AfxMessageBox(s);
    */
      

  8.   


    试了,你们应该也没有说错了,可能是我表达不到位。但我窗体默认都是显示在屏幕中央位置,我就是想的这个位置,好像这个显示到屏幕中央位置这个操作是在OnInitDialog之后操作的。
      

  9.   

    子对话框的OnInitDialog函数中加入:
    CRect rect;
    CWnd* pParent=GetParent();
    pParent->GetClientRect(&rect);
    pParent->ClientToScreen(&rect);
      

  10.   


    MoveWindow(0,0,745,625);
    0,0  代表你想要设置的桌面坐标   (设你想要的值)
    746,625  代表你的窗口大小CenterWindow(GetDesktopWindow());  (将窗口显示在桌面中央) 不知道是不是你要的答案  ?
     
      

  11.   

    指令可以设在OnInitDialog里 
    执行下 应该可以