怎么获得Picture控件的位置?就是Picture控件的左上角的X,Y的位置?

解决方案 »

  1.   

    Retrieves the window's bounding dimensions.BOOL GetWindowRect(
       LPRECT lpRect 
    ) const throw();
      

  2.   

    CWnd *pPicCtrl = GetDlgItem(IDC_STATIC1);  // 获取Pictrue控件在屏幕上的位置
      CRect rc;
      pPicCtrl->GetWindowRect(&rc);

    // 获取Pictrue控件在对话框上的位置
      ScreenToClient(rc);
      

  3.   

    CRect *cRect;
            CStatic ctrlStatic;//先将picture控件和 一个CStatic变量进行绑定
            //得到控件的客户区
    ctrlStatic.GetClientRect(cRect);
    (*cRect).NormalizeRect();//  
    ctrlStatic.ClientToScreen(cRect);

    //转换到屏幕坐标,其后获取正确的Picture区域大小
    [color=#FF0000] int rHeight = cRect->Height();
    int rWidth  = cRect->Width();

    //控件屏幕坐标转换到相对于对话框的客户坐标 
    ScreenToClient(cRect);
    // 之后再获取准确的 picture控件 与 对话框的相对坐标  int rPhotoLeft= cRect->left;
    int rPhotoTop = cRect->top ;
         int rPhotoRight   = cRect->right; 
         int rPhotoBottom  = cRect->bottom; [/color]
      

  4.   

    抱歉,没排好版面
    CRect *cRect; 
    CStatic ctrlStatic;//先将picture控件和 一个CStatic变量进行绑定  
    //得到控件的客户区 
    ctrlStatic.GetClientRect(cRect); 
    (*cRect).NormalizeRect();//  
    ctrlStatic.ClientToScreen(cRect); 
    //转换到屏幕坐标,其后获取正确的Picture区域大小 
    int rHeight = cRect->Height(); 
    int rWidth  = cRect->Width(); 
    //控件屏幕坐标转换到相对于对话框的客户坐标 
    ScreenToClient(cRect); 
    // 之后才能获取准确的 picture控件 与 对话框的相对坐标 
    int rPhotoLeft= cRect->left; 
    int rPhotoTop = cRect->top ; 
        int rPhotoRight  = cRect->right; 
        int rPhotoBottom = cRect->bottom;
      

  5.   


    int x,yx = rc.left;y = rc.top;
      

  6.   

    GetWindowRect得到矩形,然后在取左上角坐标保存到变量。
      

  7.   


    这样的方法可以!但是
    BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);是BOOL形,为什么能获得坐标值呢?
      

  8.   

    GetClientRect Function
    The GetClientRect function retrieves the coordinates of a window's client area.
    GetWindowRect Function:
    The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window.这两个有什么区别呀?
      

  9.   

    GetWindowRect 
    获得的坐标不是包括标题栏的宽度吗?
      

  10.   

    picture没有标题栏
    对于有标题栏的窗口,GetWindowRect包括标题栏的宽度