[英]Is it possible to use ActiveX controls in an SDI application (as opposed to a dialog-based application)?
I'm new to MFC and ActiveX.我是 MFC 和 ActiveX 的新手。 I'm trying to use a 3rd party ActiveX control in my MFC application.
我正在尝试在我的 MFC 应用程序中使用第 3 方 ActiveX 控件。
I successfully did it using a dialog-based MFC Application,我使用基于对话框的 MFC 应用程序成功地做到了,
but it doesn't work if I select 'Single document' when creating a new MFC project(solution) in Visual Studio.但如果在 Visual Studio 中创建新的 MFC 项目(解决方案)时,我 select 'Single document' 将不起作用。
1. How can I use a 3rd-party ActiveX control if I want to create a 'single/multiple document' MFC application? 1.如果我想创建一个“单/多文档”MFC 应用程序,如何使用第 3 方 ActiveX 控件?
2. What is the idiomatic way to use 3rd-party ActiveX control with C++? 2. C++ 使用 3rd-party ActiveX 控件的惯用方式是什么? (it's ok even if it's not MFC)
(即使不是MFC也没关系)
I really appreciate any help.我真的很感激任何帮助。
The easiest way to integrate/support controls (and activeX controls) in your MFC SDI application, is to derive your view class from CFormView.在 MFC SDI 应用程序中集成/支持控件(和 activeX 控件)的最简单方法是从 CFormView 派生视图 class。 That will allow you to add Win32 and ActiveX controls to your form window, similar to how you did it with a dialog-based application.
这将允许您将 Win32 和 ActiveX 控件添加到您的表单 window,类似于您使用基于对话框的应用程序的方式。
When you create a new MFC SDI application, ensure the "ActiveX Controls" checkbox is checked in the Advanced Features section of the wizard.当您创建新的 MFC SDI 应用程序时,请确保在向导的“高级功能”部分中选中“ActiveX 控件”复选框。 Then in the "Generated Classes" section change the base class for your view class to CFormView.
然后在“生成的类”部分将基础 class 更改为 CFormView。
This will give you a dialog resource (for your view), which you can drag/drop Win32 or ActiveX controls onto.这将为您提供一个对话框资源(用于您的视图),您可以将 Win32 或 ActiveX 控件拖放到该资源上。
Sincerely,真挚地,
@Ed Dore's answer works, but if you wanna do this by code , @Ed Dore 的回答有效,但如果你想通过代码做到这一点,
declare an instance of your control's wrapper class, and use the Create() function of it.声明控件的包装器 class 的实例,并使用它的 Create() function。
Now you don't need any dialog window(CDialogEx) or CFormView,现在你不需要任何对话窗口(CDialogEx)或CFormView,
and also don't need DDX stuff.而且也不需要DDX的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.