How to create a published procedure/function in activeX with Delphi? [duplicate] - delphi

This question already exists:
Closed 10 years ago.
Possible Duplicate:
Can't access public function in delphi ActiveX control?
I'm working with an ActiveX control implement by Delphi. In my main class, I have:
type
TezDICOMX = class(TActiveForm, IezDICOMX)
ToolBar1: TToolBar;
OpenBtn: TSpeedButton;
PreviousBtn: TSpeedButton;
....
I add these code to the class.
published
procedure abc; safecall;
After that, I build the project and register the ActiveX server. It generate the ezDICOMax.ocx. I open the visual studio, delete the remain ezDICOM activeX control I've embed before and embed the new one. I drag the activeX control to the design and name it the_ezdicom.
So as I think, I should can call the_ezdicom.abc(), but when I do that, the compiler complains
'AxezDICOMax.AxezDICOMX' does not contain a definition for 'abc' and no extension method 'abc' accepting a first argument of type 'AxezDICOMax.AxezDICOMX' could be found (are you missing a using directive or an assembly reference?)
What I did wrong? How to create a published procedure/function in ActiveX control with Delphi?
If I change an existing function/procedure in the class and do all the register, embed step, the result of that function/procedure when I call from C# change too, so I think that the activeX control is updated to my Delphi source, but I still can't add published procedure/function.

You need to:
Edit the type library (using the type library editor) to add the new method
Refresh the implementation (this can be done automatically by the type library editor, depending on your IDE settings), write your implementation code in the generated method body
Build and re-register your ActiveX server (in case you added new interfaces or data types); run regsvr32 as administrator because it needs access to protected registry branches.
The Delphi visibility of the implementor method is irrelevant in this case: the class is supposed to be used through an interface pointer, not through a Delphi class instance pointer. Therefore I would recommend to keep it protected, as generated by the type library editor.

I found that it is a problem with Visual Studio. Because I change the interface of my activeX control, so I have to delete the reference to activeX control in my project, add it again. If we do not change the interface, just unregister and register the activeX control is enough.

Related

Delphi desktop sharing

I want to provide desktop sharing from within my Delphi application (remote viewing essentially).
In my research I have found C# source that does exactly what I want: http://blogs.msdn.com/b/rds/archive/2007/03/23/writing-a-desktop-sharing-application.aspx
However I cannot find any reference to accessing rdpcomapi (rdpencom.dll) from Delphi.
Can anyone point me to a Delphi interface to this COM object?
You should be able to get the required Delphi interfaces by importing the COM type library for rdpencom.dll. In Delphi XE2, select the View | Registered Type Libraries menu, sort by "Description" and find the rdpcomapi 1.0 Type Library. Click Import on the toolbar to create the Delphi interface/type definitions.

creating a firemonkey component

I'm working with Firemonkey in Delphi XE4 and I'm unable to create a new component using the menu item Component -> New Component.
Whether the component is a VCL or Firemonkey component or whether I create a package first the result is the same.
The Tool Palette in Delphi appears to be searched and gradually it closes leaving it empty of components and a component dialog box that says "No Items available" when it comes to selecting an ancestor component.
I have two separate installations of Delphi XE4 and the same symptoms appear on both.
It appears that Delphi believes that there are no suitable base components on which to build a new component.
Creating components is fairly straightforward in code.
Create a unit.
Add code for your component.
Add a Register procedure.
procedure Register;
begin
RegisterComponents('NewPage', [TMyComponent]);
end;
Add a declaration for Register in the implements section.
Add a call to RegisterFMXClasses in your initialization section.
implementation
uses FMX.Types;
...
initialization
RegisterFMXClasses([TMyComponent]);
end.
Create a package.
Add the unit to the package.
Right-click the package (in the top-right panel) and select Install.
(Note: It's usually best to create your component at run time whilst testing. You only need to do the package stuff once it's fairly stable).

Can I instantiate an ActiveX Control directly in a Delphi app, either via TOleContainer or some other way?

The TOleContainer can of course, insert OLE Objects like Word Documents. But it doesn't seem to work for ActiveX. I know, of course, about Delphi's IDE ability to create an ActiveX wrapper. What if I want to create a control without creating a wrapper and installing it into the IDE, at runtime?
The control is registered, so unlike this question, I don't need registration-free com. I just need some idea, or some sample, of how dynamic ActiveX Containers are started.
The TOleContainer works with ActiveX controls, you only need pass the proper ProgID of the Activex control to the CreateObject method and then using late-binding access the properties of the ActiveX.
Check this sample which create a Windows Media Player ActiveX control inside of a TOleContainer in runtime.
OleContainer1.CreateObject('Wmplayer.OCX.7', False);
OleContainer1.OleObject.URL:='F:\Music\Iron Maiden - The number of the beast.mp3';
OleContainer1.OleObject.Controls.Play;

Adding new property to TMS control "TAdvSmoothDock" but it doesn't appear in the Object Inspector

I'm trying to add a new property (Images: TImageList) to the TMS Control "TAdvSmoothDock" but the property doesn't appear in the Object Inspector
I defined it under "Published" as following :
Published
property Images: TImageList read GetImages write SetImages;
I can compile it but the property doesn't appear in the Object Inspector.
it does appear in the delphi IDE when using the control in the code:
like :
AdvSmoothDock1.Images := ImageList1;
currently I'm using Delphi XE2 VCL.
Regards.
You need to rebuild the TMS packages that contain the component, not just change the source code.
The Object Inspector doesn't use the code source to figure out what to display. It uses RTTI (run-time type information) it gets from the compiled version in the runtime package that contains the component (or the designtime package if there is no runtime package available.
Figure out what package the TMS component is in, open that package's source in the IDE (the .dproj file for the package), and do a build of that package. Make sure it's seeing your version of the source instead of the normal TMS version, so your changes are used.
(Of course, the proper way to do this would be to create your own descendant of the TAdvSmoothDock, add the property, put it into your own package that uses the TMS one, and never touch the TMS source code.)

Double click on a non-visual component [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to invoke a property editor at design time
I'm creating a non-visual component, and I want the user to be able to double click on my component at design-time and have that open a design-time editor.
How can I do it?
Double-clicking a component at design time invokes a component editor. The default component editor is one that looks for event properties with certain names and creates a handler for what it finds. You can write your own component editor that does whatever you want.
Create a descendant of TComponentEditor (from the DesignEditors unit) and override the Edit method to handle double-clicks. You can also override the GetVerbCount, GetVerb, and ExecuteVerb methods to add context-menu items to your component. To get a reference to the component your editor is being asked to edit, check the Component property. Call Designer.Modified if your editor modifies the component.
Tell the IDE that your editor should be used with your component by calling RegisterComponentEditor (from DesignIntf) in your Register procedure.
You should put this code in a design-time package, separate from your component's code. Put your run-time package on the "requires" list of the design-time package. If you put everything in a single package, then consumers of your component won't be able to use run-time packages in their projects; they're not allowed to distribute the dependencies of your design-time package, which are only for use by the IDE.

Resources