ClientToScreen 和ScreenToClient 用法 分类: VC++ 2013-10-30 08:15 2184人阅读 评论(0) 收藏
2013-10-30 08:15
465 查看
ClientToScreen( )是把窗口坐标转换为屏幕坐标
ScreenToClient( )是把屏幕坐标转换为窗口坐标
屏幕坐标是相对于屏幕左上角的,而窗口坐标是相对于窗口用户区左上角的
VC下,有些函数使用窗口坐标,有些使用屏幕坐标,使用时要分清。
一个窗体分为两部分:系统区和客户区
象标题和菜单之类的是系统区,由系统来控制,客户区就是你的地盘喽!!!
Width, Height 是指整体的,ClientWidth, ClientHeight是指客户区的,两者相减就是
系统区的啦!!!
ClientToScreen是把坐标从当前窗体转化成全屏幕的!!!
ScreenToClient是把屏幕坐标转化成相对当前窗体的坐标!!!!
//Resize window to proper size based on video standard
CRect recDstD1( 0, 0, 720, 576 );
static_preview_window.ClientToScreen(&recDstD1); // recDstD1 {top=53 bottom=629 left=200 right=920} CRect
static_preview_window.SetWindowPos(&CWnd::wndBottom, recDstD1.left, recDstD1.top, recDstD1.right - recDstD1.left + 10, new_height + 10, SWP_NOMOVE | SWP_SHOWWINDOW);
bool m_bIsLButtonDawn =false;
void CDrawDlg::OnMouseMove(UINT nFlags, CPoint point)
void CDrawDlg::OnLButtonUp(UINT nFlags, CPoint point)
void CDrawDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CWnd *pwnd=GetDlgItem(IDC_EDIT1);
CDC *pDC=pwnd->GetDC();
CRect rect;
this->ClientToScreen(&point);
pwnd->ScreenToClient(&point);
pwnd->GetClientRect(&rect);
if(rect.PtInRect(point))
{
m_fp.x=point.x;
m_fp.y=point.y;
}
ReleaseDC(pDC);
m_bIsLButtonDawn =true;
CDialog::OnLButtonDown(nFlags, point);
ScreenToClient( )是把屏幕坐标转换为窗口坐标
屏幕坐标是相对于屏幕左上角的,而窗口坐标是相对于窗口用户区左上角的
VC下,有些函数使用窗口坐标,有些使用屏幕坐标,使用时要分清。
一个窗体分为两部分:系统区和客户区
象标题和菜单之类的是系统区,由系统来控制,客户区就是你的地盘喽!!!
Width, Height 是指整体的,ClientWidth, ClientHeight是指客户区的,两者相减就是
系统区的啦!!!
ClientToScreen是把坐标从当前窗体转化成全屏幕的!!!
ScreenToClient是把屏幕坐标转化成相对当前窗体的坐标!!!!
//Resize window to proper size based on video standard
CRect recDstD1( 0, 0, 720, 576 );
static_preview_window.ClientToScreen(&recDstD1); // recDstD1 {top=53 bottom=629 left=200 right=920} CRect
static_preview_window.SetWindowPos(&CWnd::wndBottom, recDstD1.left, recDstD1.top, recDstD1.right - recDstD1.left + 10, new_height + 10, SWP_NOMOVE | SWP_SHOWWINDOW);
bool m_bIsLButtonDawn =false;
void CDrawDlg::OnMouseMove(UINT nFlags, CPoint point)
void CDrawDlg::OnLButtonUp(UINT nFlags, CPoint point)
void CDrawDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CWnd *pwnd=GetDlgItem(IDC_EDIT1);
CDC *pDC=pwnd->GetDC();
CRect rect;
this->ClientToScreen(&point);
pwnd->ScreenToClient(&point);
pwnd->GetClientRect(&rect);
if(rect.PtInRect(point))
{
m_fp.x=point.x;
m_fp.y=point.y;
}
ReleaseDC(pDC);
m_bIsLButtonDawn =true;
CDialog::OnLButtonDown(nFlags, point);
相关文章推荐
- GetWindowRect、GetClientRect、ScreenToClient与ClientToScreen 分类: VC++ 2013-10-30 08:20 1122人阅读 评论(0) 收藏
- udp协议的数据接收与发送的代码 分类: VC++ 网络基础 2014-02-25 08:15 700人阅读 评论(0) 收藏
- 线程中CreateEvent和SetEvent及WaitForSingleObject的用法 分类: VC++ 2013-10-09 09:00 707人阅读 评论(0) 收藏
- MFC中CFileDialog用法 分类: VC++ 2014-10-14 15:56 502人阅读 评论(0) 收藏
- JavaScript概念之screen/client/offset/scroll/inner/avail的width/left 分类: JavaScript HTML+CSS 2015-05-27 16:42 635人阅读 评论(0) 收藏
- Android中AsyncTask的简单用法 分类: Android Activity 2014-07-04 09:21 56人阅读 评论(0) 收藏
- linux之cut用法 分类: ubuntu 测试 python基础学习 2014-02-10 14:54 213人阅读 评论(0) 收藏
- directdraw显示yuv422(yuy2) 分类: VC++ 2013-11-14 14:58 932人阅读 评论(0) 收藏
- win32程序中简单应用mfc 分类: VC++ 2013-10-08 08:31 584人阅读 评论(0) 收藏
- VC++信息安全编程(13)Windows2000/xp/vista/7磁盘扇区读写技术 分类: 磁盘的扇区读写 VC++ 2015-04-29 10:38 357人阅读 评论(0) 收藏
- assert 用法及获取IP 分类: python基础学习 2013-07-24 16:54 344人阅读 评论(0) 收藏
- 【原创】memset和memcpy用法总结 分类: Linux --- C Linux --- C++ 2014-11-11 20:45 70人阅读 评论(0) 收藏
- g++基本用法 分类: arm-linux-Ubuntu 2014-06-18 17:50 414人阅读 评论(0) 收藏
- 初学者必知的Python中优雅的用法 分类: Python 2015-05-11 15:02 782人阅读 评论(0) 收藏
- WaitForSingleObject函数 分类: VC++ 2013-09-14 17:32 403人阅读 评论(0) 收藏
- errno的基本用法 分类: H_HISTORY 2013-02-18 21:49 1840人阅读 评论(0) 收藏
- PPM图像格式(Portable Pixelmap) 分类: VC++ 文件格式 2014-11-25 11:32 513人阅读 评论(0) 收藏
- emulator: Failed to&nb… 分类: Android开发 2014-05-30 10:52 52人阅读 评论(0) 收藏
- echo的高级用法-颜色输出与光标定位 分类: Ubuntu学习笔记 2015-07-26 22:54 17人阅读 评论(0) 收藏
- 服务级后门自己做——创建服务 分类: VC++ 2013-10-08 08:32 585人阅读 评论(0) 收藏