窗口客户区的CRect始终拿不对,不知道为啥我想拿一个窗口的客户区相对于整个屏幕坐标系的rect,GetClientRect(&m_crectWindowsRect);//我先拿窗口客户区的rect
ClientToScreen(&m_crectWindowsRect); //然后转成基于屏幕坐标系的rect
但是这样,得到的m_crectWindowsRect,和窗口客户区的rect不匹配,不知道为啥

解决方案 »

  1.   

    怎么不匹配?
    用windowsdc画屏幕坐标
      

  2.   


    GetWindowRect(&m_crectWindowsRect);
    ClientToScreen(&m_crectWindowsRect); 
    如果写成这样,
    第一次取到的m_crectWindowsRect:top 0,bottom 332,left 0,right 486
    第二次取到的m_crectWindowsRect:top 29,bottom 361,left 3,right 489
      

  3.   

    LZ你用WIN32 API
    BOOL GetWindowRect( 
      HWND hWnd, 
      LPRECT lpRect 
    ); 
    hWnd 
    [in] Handle to the window. 
    lpRect 
    [out] Long pointer to a RECT structure that receives the screen coordinates of the upper-left and lower-right corners of the window. 
    Return ValueshWnd指明你客户区的句柄
      

  4.   

    支持1楼。
    还有注意这几个函数都有个this指针,是某个窗口来调用。