简体   繁体   English

如何在MFC对话框中替换/更新ActiveX控件

[英]How to replace/update an ActiveX control in a MFC dialog

I have an older MFC project build in VS 2003 that I want to port to VS 2010. The project uses an ActiveX control for grids, namely, VSFlexGrid7 from Component One. 我在VS 2003中有一个较旧的MFC项目,我希望将其移植到VS 2010.该项目使用ActiveX控件进行网格,即Component One的VSFlexGrid7。 The problem is, that this version of the ActiveX control does not work in Windows 7 (which is what I have). 问题是,这个版本的ActiveX控件在Windows 7中不起作用(这就是我所拥有的)。 There is a newer version of the grid, namely, VSFlexGrid8 which should be compatible with Windows 7. 有一个较新版本的网格,即VSFlexGrid8应该与Windows 7兼容。

The solution would be to replace all the older controls with the newer ones. 解决方案是用新的控件替换所有旧控件。

My question is, what would be the steps in replacing the controls, without touching other parts of the project. 我的问题是,更换控件的步骤是什么,而不涉及项目的其他部分。 What is the simplest method to accomplish this? 实现这一目标的最简单方法是什么? Do I have to modify classes, resource IDs, etc.? 我是否必须修改类,资源ID等?

[Solution: Replace CLSIDs in the .RC file] [解决方案:替换.RC文件中的CLSID]

Usually the control is created somewhere in your dialog code with CreateInstance. 通常,使用CreateInstance在对话框代码中的某处创建控件。 If the interface is compatible (I assume it is) , you just have to change the name or GUID that is used in the CreateInstance Code. 如果接口兼容(我认为是),您只需要更改CreateInstance代码中使用的名称或GUID。

The ActiveX control is bound to the resource file via the guid that represents the control. ActiveX控件通过代表控件的guid绑定到资源文件。 If you were to look inside the .rc file you will see the control with the associated guid. 如果您要查看.rc文件,您将看到带有关联guid的控件。 In your case, it's probably best to completely remove the control from the dialog (using the resource editor) assuming that you can drag the newer version onto the same dialog. 在您的情况下,最好从对话框中完全删除控件(使用资源编辑器),假设您可以将较新的版本拖到同一个对话框中。 Once you've done that, you'll need to generate a new class wrapper for the control. 完成后,您需要为控件生成一个新的类包装器。 The class wizard should be able to handle that for you. 类向导应该能够为您处理。 Once you've got a new class wrapper that represents the control, you'll need to replace the prior wrapper class in your source code. 一旦你有了一个代表控件的新类包装器,你就需要在源代码中替换先前的包装器类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM