怎么获得Picture控件的位置? 怎么获得Picture控件的位置?就是Picture控件的左上角的X,Y的位置? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Retrieves the window's bounding dimensions.BOOL GetWindowRect( LPRECT lpRect ) const throw(); CWnd *pPicCtrl = GetDlgItem(IDC_STATIC1); // 获取Pictrue控件在屏幕上的位置 CRect rc; pPicCtrl->GetWindowRect(&rc); // 获取Pictrue控件在对话框上的位置 ScreenToClient(rc); 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] 抱歉,没排好版面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; int x,yx = rc.left;y = rc.top; GetWindowRect得到矩形,然后在取左上角坐标保存到变量。 这样的方法可以!但是BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);是BOOL形,为什么能获得坐标值呢? GetClientRect FunctionThe 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.这两个有什么区别呀? GetWindowRect 获得的坐标不是包括标题栏的宽度吗? picture没有标题栏对于有标题栏的窗口,GetWindowRect包括标题栏的宽度 关于 gethostbyname() 函数? 网络通信数据接收问题? VC#怎样捕获JPEG格式图像的数据流(十六进制)并转换成JPEG的图片在控件上显示 求助:怎么在基于对话框的工程中的静态文本控件上显示位图? 这两个import有什么区别? 用Format格式輸出怎樣讓0輸出成00或000呀!是以%X的形式輸出 异步SOCKET是单线程工作的吗 CListCtrl显示大图标的时候怎样控制他单列、双列,或是多列显示呢? 送上最后40分:如何实现本程序自动重新启动 重金购买硬盘保护卡的全套技术! 高分求用MFC开发学生成绩管理系统 急用啊, 如何实现树控件单击事件?
LPRECT lpRect
) const throw();
CRect rc;
pPicCtrl->GetWindowRect(&rc);
// 获取Pictrue控件在对话框上的位置
ScreenToClient(rc);
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]
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;
int x,yx = rc.left;y = rc.top;
这样的方法可以!但是
BOOL GetWindowRect(HWND hWnd,LPRECT lpRect);是BOOL形,为什么能获得坐标值呢?
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.这两个有什么区别呀?
获得的坐标不是包括标题栏的宽度吗?
对于有标题栏的窗口,GetWindowRect包括标题栏的宽度