[英]How to connect an MFC control to a custom control in the visual dialog editor
I have created a custom control in the MFC visual dialog designer, as shown below: 我已经在MFC可视对话框设计器中创建了一个自定义控件,如下所示:
However, I am unsure how I can link my custom control (in this case I have created a class CGraphCtrl
which inherits from CWnd
) to the region that I have created in the visual editor, I assumed that I would be able to do this when I called CGraphCtrl::Create
, however, as that takes a const CRect&
as an argument, this overrides the region specified. 但是,我不确定如何将自定义控件(在这种情况下,我创建了一个从CWnd
继承的类CGraphCtrl
)链接到在可视化编辑器中创建的区域,我假设我可以在以下情况下执行此操作我调用了CGraphCtrl::Create
,但是因为它使用const CRect&
作为参数,所以它将覆盖指定的区域。 I am calling CGraphCtrl::Create
in CStockManagerDlg::OnInit
as follows: 我在CStockManagerDlg::OnInit
调用CGraphCtrl::Create
,如下所示:
m_graphCtrl.Create( _T("STATIC"), _T("Graph Control"), WS_CHILD | WS_VISIBLE,
CRect( 0, 0, 100, 100 ), this, IDC_GRAPH );
You can create a CStatic control in the visual dialog editor. 您可以在可视对话框编辑器中创建一个CStatic控件。 Then right-click on it and create a control member variable like CStatic m_graphCtrl. 然后右键单击它并创建一个控件成员变量,如CStatic m_graphCtrl。 Then edit that code to make it a CGraphCtrl m_graphCtrl. 然后编辑该代码,使其成为CGraphCtrl m_graphCtrl。 This attaches your code to the original CStatic. 这会将您的代码附加到原始CStatic。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.