现在碰到一件郁闷的事情:一个ocx控件只能在Delphi 6.0以上的环境中使用,
可是现在公司里用的是Delphi 5.0,
并且一定要使用这个ocx控件,所以想在Delphi 7.0里把这个ocx封装成dll控件,
以便在Delphi 5.0里面使用,这个可行么?刚才试了一下,没有成功:(
可是现在公司里用的是Delphi 5.0,
并且一定要使用这个ocx控件,所以想在Delphi 7.0里把这个ocx封装成dll控件,
以便在Delphi 5.0里面使用,这个可行么?刚才试了一下,没有成功:(
在D7中需要将tools/Environment Option/Type Library页中的Ignore Special CoClass Flags When Importing 选项选中,Can Create也选中。
然后再Component/Import Activex Control里注册该控件后,在面板上就可以看到该控件了。但是在D5是,tools/Environment Option/Type Library页中是没有Ignore Special CoClass Flags When Importing和Can Create选项的。所以在D5中用Component/Import Activex Control里注册该控件后,在面板上还是不能看到该控件!!!这怎么解决啊???
这是啥啊?
进去了,怎么没看到问题解决的相关信息啊?
和这个有关系么?
When you import an ActiveX Control, the type library importer only imports CoClasses that are not
ed as Hidden, Restricted, or Predefined, and ed as CanCreate (actually 'noncreatable?. These flags are supposed to be set if the object is intended for general use. However, if you want to create a control for an internal application only, you can override the flags to generate the CoClass wrappers. In this case, you would check Ignore special CoClass flags when importing, Hidden, Restricted, and uncheck CanCreate (noncreatable).Check the coclass flags you want to ignore when importing ActiveX controls:Predefined Client applications should automatically create a single instance of this object.
Restricted A coclass ed 'restricted' is supposed to be ignored by tools that access COM objects. It's exposed by the type library but restricted to those authorized to use it.
Hidden The interface exists but should not be displayed in a user-oriented browser.
Can Create The instance can be created with CoCreateInstance.
当你导入一个ActiveX控件的时候,类型库导入者只导入那些没有标记为Hidden,Restricted,或者Predefined和
标记为CanCreate(实际上是'不可创建',这些标记用来支持对象为了特定目的扩展。然而,如果你只是想为内部应用
而创建一个控件,你可以重载这些标记来产生对CoClass的一个包装类,如果要这么做,那么当导入类型库的时候你就应该忽略这些标记(Hidden,Restricted,CanCreate).
当你导入ActiveX控件想忽略coclass标记时,在相应复选框中选中
Predefined 客户程序应该自动创建一个单实例对象
Restricted 标记为'restricted'的coclass类会被访问COM对象的工具忽略,这个COM对象可以被类型库公布,但是
被静止使用
Hidden 存在接口,但是不能暴露给用户使用
CanCreate 实例可以被CoCreateInstance函数创建
不然也不会存在这种问题了。郁闷
但因为里面一些技术细节,特别是在类型库上的处理,不同开发工具之间多少存在点小别扭.看楼主情况,应该是
D5 对VB写ACTIVEX一些特别类型信息生成代码不够好.
D7改进了这个过程而已.楼主可以试试将D7生成的接口单元,替换D5生成的那个,并手工作一些修改.应该并无大碍.
我没试过,你可以试一下