GetWindowRect(&rt);

ClientToScreen( rt );
为什么返回的TOP=0;如何获得窗口相对桌面的坐标的

解决方案 »

  1.   

    CRect rc;
    GetClientRect(rc);
      

  2.   

    CWnd::GetWindowRect
    void GetWindowRect( LPRECT lpRect ) const;ParameterslpRectPoints to a CRect object or a RECT structure that will receive the screen coordinates of the upper-left and lower-right corners.指向一个CRect对象或RECT结构,用于接收左上角和右下角的屏幕坐标。 ResCopies the dimensions of the bounding rectangle of the CWnd object to the structure pointed to by lpRect. The dimensions are given in screen coordinates relative to the upper-left corner of the display screen. The dimensions of the caption, border, and scroll bars, if present, are included.这个函数将CWnd对象的边界矩形的大小拷贝到lpRect所指向的结构中。大小是用相对于显示器屏幕左上角的屏幕坐标给出的,其中包括了标题条,边框和滚动条的大小,如果有的话。