MFC MDI 程序中拆分子窗口
我正在尝试拆分我正在开发的 MFC MDI 程序的子窗口,但遇到了一些问题。我知道我必须使用 CSplitterWnd 类,并且一直在尝试按照此处帖子上的说明进行操作:
使用 CSplitterWnd 在 CChildFrame 中创建多个视图
,但似乎无法使其工作,任何人都可以为我提供有关这些说明的一些建议,我有一些具体问题:
CRightView 是否也是 CView 派生类以及其中应包含哪些代码(如果有)?
m_pLeftView、m_pRightView、m_pPhongView 和 m_pPhongInfo 是否都是相应类的变量,它们是否具有任何特定类型?
m_pLeftView、CTreeView从哪里来,好像不是标准基类?
CChildFrame::OnCreateClient 中的 rc.Width 给出了未声明的标识符错误,我是否应该在此处声明一些内容?
我很感激任何关于这方面的建议,真的很努力让分离器工作。
谢谢
I am trying to split the Child Window of an MFC MDI progarm that I am working on but am having some problems. I know I have to use the CSplitterWnd class and have been trying to follow the instructions on the post here:
Create multi views in a CChildFrame using CSplitterWnd
but can't seem to get it to work, would anyone be able to offer me some advice with regard to these instructions, I have some specific questions:
Is CRightView also a CView derived class and what code should go in there if any?
Are m_pLeftView, m_pRightView, m_pPhongView and m_pPhongInfo all variables of the appropriate classes and do they have any particular type?
Where does CTreeView come from, does not seem to be a standard base class?
rc.Width in CChildFrame::OnCreateClient gives an undeclared identifier error, is there something I should be declaring somewhere here?
I would appreciate any advice about this, really struggling to get the splitter to work.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几天的努力,我成功解决了自己的问题,我在这里为可能遇到同样问题的其他人添加解决方案。
声明两个视图类,在我的例子中,
CElement
View 是一个CWnd
派生类,CSampleViewer3dView
是一个CView
派生类。在
CChildFrame
中添加一个具有私有访问权限的变量,输入CSplitterWnd
并命名为m_wndSplitter
。在
CChildFrame
中添加对OnCreateClient
函数的覆盖,这应该添加代码:到ChildFrm.h,您还应该向ChildFrm.h添加一个布尔标志m_bInitSplitter:
您还必须添加:
在ChildFrm.cpp的构造函数中,当您使用向导添加变量时,将以下代码添加到ChildFrm.cpp中:
将以下代码放入CChildFrame::OnCreateClient:
将
WM_SIZE
消息的覆盖添加到CChildFrame
并插入以下代码:您可以通过将 0.25 和 0.75 的值更改为所需的百分比来编辑每个窗口的大小。您希望每个视图占据的屏幕。
ChildFrm.cpp
,例如ElementView.h
和SampleViewer3dView.h
。然后,您应该在 MDI 程序的子窗口中拥有两个独立的视图。
After working on it for a couple of days I've managed to solve my own problem, I'm adding the solution here for anyone else who might have the same problem.
Declare the two view classes, in my case
CElement
View which is aCWnd
derived class andCSampleViewer3dView
which is aCView
derived class.In
CChildFrame
add a variable with access private, typeCSplitterWnd
and namem_wndSplitter
.Add an override for the
OnCreateClient
function inCChildFrame
, this should add the code:to ChildFrm.h, you should also add a boolean flag m_bInitSplitter to ChildFrm.h:
you also have to add:
to the constructor of ChildFrm.cpp, the following code is added to ChildFrm.cpp when you add the variable using the wizard:
Put the following code into CChildFrame::OnCreateClient:
Add an override for the
WM_SIZE
message toCChildFrame
and insert the following code:You can edit the size of each window by changing the values of 0.25 and 0.75 to the required percentage of the screen that you want each view to take up.
ChildFrm.cpp
, e.g.ElementView.h
andSampleViewer3dView.h
.You should then have two independent views in the child window of an MDI program.