简体   繁体   English

是否可以在 SDI 应用程序(相对于基于对话框的应用程序)中使用 ActiveX 控件?

[英]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.

相关问题 为基于对话框的应用程序实现回调功能 - Implementing callback function for dialog-based application 如何在基于MFC对话框的应用程序中关闭主窗口 - How to close the main window in MFC dialog-based application 在基于对话框的VC ++应用程序中无法调用DoModal Twice - Fail to call DoModal Twice in a Dialog-based VC++ application 如何在MFC SDI CFormView应用程序中调整表单(对话框)的大小? - How does one resize the form(dialog) in a MFC SDI CFormView application? 从视图访问 SDI mfc 应用程序中的模态对话框 - Access from View to modal dialog in SDI mfc application 是否可以为基于对话框的窗口而不是框架窗口创建MDI窗口? - Is it possible to create an MDI window to the dialog-based window instead of the frame window? 如何防止我的基于MFC对话框的应用程序在ESC键后关闭,但允许其他控件处理它? - How to prevent my MFC dialog-based app from closing after ESC key, but allow other controls to process it? 如何在基于MFC对话框的应用程序中使用计时器? - How to Use Timer in MFC Dialog based Application? 如何在Visual Studio 2012中为基于Win32 Dialog的应用程序启用“插入Activex控件”? - How to enable 'Insert Activex Control' in Visual Studio 2012 for a Win32 Dialog based application? Activex控件有可能吗? - is this possible with activex controls?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM