如题
解决方案 »
- 求相关介绍对滚动条编程的例子或者博客
- ListCtrl GetScrollPos() SetScrollPos的问题
- ADO远程连接sql server 的速度问题
- MFC短信猫与PreTranslateMessage处理消息的问题 高手来帮帮
- 急!!!!!如何在vc的对话框中打开并显示多页的word文档?
- List Control控件整行选中问题。
- 请那位高手帮忙如何得到文件序列的具体位置?
- 在Windows2000下写的Atl控件,不能在Windows95/98下使用
- 来者都有分:那位大虾总结过Visual C++ 6.0开发环境的快捷键或者是使用小技巧?
- 大虾们,来讨论一下课本上的数据结构与算法,都是干什么用的?比如huffman-----
- 请问如何在对话框中翻转控件?
- 一个很菜的问题,在线等待
GetWindowRect(&rt) ;
要得到视图指针
CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;// Get the active MDI child window.
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();// or CMDIChildWnd *pChild = pFrame->MDIGetActive();// Get the active view attached to the active MDI child
// window.
CMyView *pView = (CMyView *) pChild->GetActiveView();
CRect rt ;
pView->GetWindowRect(&rt) ;
-------------------------
比如在MDI的框架类中
要得到视图指针
CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;// Get the active MDI child window.
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();// or CMDIChildWnd *pChild = pFrame->MDIGetActive();// Get the active view attached to the active MDI child
// window.
CMyView *pView = (CMyView *) pChild->GetActiveView();
-------------------------
这段代码加在哪?
你可以根据你自己的程序的特点增加到不同的位置
pView->GetWindowRect(&rt) ;返回得rt就保存了当前视图的位置坐标
我现在已经获得了客户区的区域
但是left和top总是0
我想获得当前客户区的
top left heigth width
(相对于桌面来说)
为什么heigth 和width
总是一个常数?
不懂
比如在视图客户区鼠标左键单击,得到视图客户区范围void CLView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rt ;
GetWindowRect(&rt) ;
int height = rt.Height ;
int width = rt.Width ;
CView::OnLButtonDown(nFlags, point);
}
这两个值是改变的
int width = rt.Width ;
出错
--------------------------
C:\zhuatu\zhuatuView.cpp(119) : error C2664: 'CreateCompatibleBitmap' : cannot convert parameter 2 from 'int (void) const' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
C:\zhuatu\zhuatuView.cpp(123) : error C2664: 'BitBlt' : cannot convert parameter 3 from 'int (void) const' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
---------------------------
{
// TODO: Add your message handler code here and/or call default
CRect rt ;
GetWindowRect(&rt) ;
CString left ;
left.Format("%ld",rt.left) ;
CString top;
top.Format("%ld",rt.top ) ;
AfxMessageBox(left) ;
AfxMessageBox(top) ; CView::OnLButtonDown(nFlags, point);
}
有左上角和右下角坐标,可以通过这两点坐标算出高度和宽度
试试我上面的做法,这回没错了
可以这样:
long width = rt.right - rt.left ;
long height = rt.bottom- rt.top ;