سؤال

The declaration of my component is:

MyComponentX = class(TActiveXComponent, IspdInterfaceX)

TActivexComponent:

TActiveXComponent = class(TActiveXControl, IOleControl) 

When I open a new DataModule in any Delphi version, the component disappears from the Component Palette.

I try to change the ClassGroup in Delphi XE2, but this don't works.

هل كانت مفيدة؟

المحلول

Data modules can only host non-visual controls, and TActiveXControl is not a non-visual control.

You ask what is the definition of non-visual control. According to this article, the definition is that if the component is derived from TComponent and not derived from TControl, then it is a non-visual control.

That said, the inheritance hierarchy for TActiveXControl is: TObject, TComObject, TTypedComObject, TAutoObject, TActiveXControl. So I am at something of a loss at to why it ever appears on your component palette since it is not derived from TComponent. It would be interesting to know how you registered it. All the same, it's not a non-visual component in the meaning of the act.

نصائح أخرى

In this case, you can create a class wrapper to use your ActiveX in this data module.

TWrapper = class(TComponent)
private
    FYourActiveX: TYourActiveX;
public
    procedure Method;
end;

procedure TWrapper.Method;
begin
    FYourActiveX.Method;
end;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top