小弟我在一个对话框的OnInitDialog中添加了一个CScrollView,但是多次打开这个View,图越来越靠右,越来越小,小弟我希望他占满整个对话框
我在一个对话框的OnInitDialog中添加了一个CScrollView,但是多次打开这个View,图越来越靠右,越来越小,我希望他占满整个对话框?
请高手指点怎么修改
CCreateContext pContext;
CWnd* pFrameWnd = this;
pContext.m_pCurrentDoc = new CDocument;
pContext.m_pNewViewClass = RUNTIME_CLASS(CScrollView);
CScrollView *pView =CScrollView *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
ASSERT(pView);
pView->ShowWindow(SW_NORMAL);
CRect rectWindow;
GetWindowRect(rectWindow);
rectWindow.right -= 5;
rectWindow.bottom -= 70;
pView->MoveWindow(rectWindow);
------解决方案--------------------
GetWindowRect(rectWindow); 好象是要传指针进去吧.
GetWindowRect(rectWindow);
改成
GetClientRect(&rectWindow);
试试
GetWindowRect 是整个窗口相对于屏幕左上角的坐标
GetClientRect 是客户区相对于窗口左上角的坐标
请高手指点怎么修改
CCreateContext pContext;
CWnd* pFrameWnd = this;
pContext.m_pCurrentDoc = new CDocument;
pContext.m_pNewViewClass = RUNTIME_CLASS(CScrollView);
CScrollView *pView =CScrollView *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
ASSERT(pView);
pView->ShowWindow(SW_NORMAL);
CRect rectWindow;
GetWindowRect(rectWindow);
rectWindow.right -= 5;
rectWindow.bottom -= 70;
pView->MoveWindow(rectWindow);
------解决方案--------------------
GetWindowRect(rectWindow); 好象是要传指针进去吧.
GetWindowRect(rectWindow);
改成
GetClientRect(&rectWindow);
试试
GetWindowRect 是整个窗口相对于屏幕左上角的坐标
GetClientRect 是客户区相对于窗口左上角的坐标