How to write Delphi ActiveX control which can be used in MS Word/Excel/Powerpoint? - delphi

[ToDo] (1) As indicated from NGLN's helpful answer, using simpler keywords such as "Delphi ActiveX control" to search. (2) Consuming the ActiveX control in Word/Excel/Powerpoint is yet another step. [/ToDo]
[Useful links]
Writing ActiveX Controls in Master Delphi 7
create non visual activex control with delphi
Error Could not load unit [unit] symbol information for [TClassName]
=======
Or what books and courses to learn if I want to write in Delphi a well-behaved ActiveX control which can be used in Microsoft Word/Excel/Powerpoint ?
Very sorry if this should be a bad question without programming details. However, when I search in the internet materials, almost all I get is about "how to manipulate/embed/host Word/Excel/Powerpoint in Delphi application". Is it because there are other languages/toolkits best suited for creating ActiveX controls which can be used in Microsoft Word/Excel/Powerpoint ?
The reason why I am trying:
What I do now : (1) A Delphi application is used to produce a image file. (2) This image file is pasted in a Excel report. (3) When different representation of the image is needed, one repeat (1) and (2). That is to say, one need to switch between applications.
My goal is to have : (1) A Delphi ActiveX is embeded/hosted in a Excel report. When different representation of the image is needed, one can thus manipulate through the Delphi ActiveX within the Excel report, and do not need to go elsewhere or switch between applications.

You can create an ActiveX control by following these steps:
Design your control as installable component, inherit from TWinControl or below
Publish properties you want to use, once as ActiveX control
Add it to a registerable package
Install that package into the Delphi IDE
Close all
Choose File > New > Other... > ActiveX > ActiveX Library
Choose File > New > Other... > ActiveX > ActiveX Control
Choose your component from the VCL Class Name combo box
Set the threading model you want to support. Apartment is the default and probably preferrable.
Build the project
Register the OLE Control Extension (.ocx) that Delphi created with regsvr32.exe
That is how I added a Delphi DXF control to an Access database:
Note that you will need a 64-bit ocx for a 64-bit MS Office installation (regardless of the Windows version).
For reference: the chapter in the documentation dealing with creating COM objects starts here.

Related

What is dclsmpedit?

What is dclsmpedit package (Embarcadero Editor Script Enhancements)?
Do I need it?
I am not sure what 'Editor Script Enhancements' does.
It's a sample of adding key bindings (your own code editor keyboard assignments), the ability to save keyboard macros (keystrokes recorded for playback), and an edit buffer list to the IDE using the ToolsAPI. You only need it if you want to use it 's functionality. The source is useful if you want to extend the IDE via the parts of the ToolsAPI that they demonstrate. The key binding functionality in BufferList.pas implements the New IDE Classic key mapping in the IDE itself (as pointed out by #LURD in the comment below).
If you're using Delphi 2007, you can find the source in the Delphi Demos folder (by default on Windows 7 in C:\Users\Public\Documents\RAD Studio\5.0\Demos\DelphiWin32\VCLWin32\ToolsAPI\Edit Keybinding), and more easily found with the Start->CodeGear RAD Studio->Samples menu item. The source for the added functionality is there as well, so you can see what they do and how they are implemented.
In XE3, the source code can be found in C:\Users\Public\Documents\RAD Studio\10.0\Samples\Delphi\VCL\ToolsAPI\Editor KeyBinding, or via Start->All Programs->Embarcadero RAD Studio XE->Samples.

Import COM component: Difference c# vs. Delphi XE

I need to work with a COM component. Unfortunately its producer explicitly doesn't support Delphi and delivers only C# and VB.NET examples. There is no type library available for that component.
OTOH it's quite straightforward in VS2010 because the respective COM library (WinSig.exe) is listed as a reference.
In the VS2010 IDE this is in "Project - Add reference - COM tab". In Delphi XE I cannot find that entry in "Component - Import Component - ActiveX".
I have inspected the entries in the two IDEs and found that there are some COM components included in the Delphi IDE which are also in the VS IDE but there are a lot of COM components missing in the Delphi IDE.
See for screenshot file which shows that the first seven COM components are not displayed within the Delphi IDE.
Can one explain why this is so and maybe a help for that specific problem?
Did you checked Import a Type Library option in Import Component wizard (on the first page)? ActiveX is narrower thing than COM. Also, you can use Add button to choose a file if you know library location.

how to install Source Wizard for Delphi 7 in Delphi 2009

I have Source Wizard for Delphi 7 (a code formatter).
I'm switching to Delphi 2009. I tried loading *.pas (created with D2009) in Source Wizard in Delphi 7 and there were no problems processing them.
How can I make it to show like a menu item in D2009's menu..?
If you want to have an item in the tools menu, you can simply click on Tools->Configure Tools (or similar, I have a German Delphi version here).
If you are trying to port a Delphi 7 OTA (Open Tools API) wizard, you have to change the code to the new API, because it changed in the transition from the Aurora IDE (D1 - D7) to the Galileo IDE (D8+).
How do I write a Delphi Galileo IDE Expert?
Or are you asking for a specific tool that is called "Source Wizard"?
PS: It would not hurt to clarify your question a bit. A more specific question gets you better answers.
Edit: You may look at GExperts for the integrated source formatter that is based on DelForExp like the "Delphi Source Wizard" seems to be:
http://www.dummzeuch.de/delphi/gexperts/english.html

Delphi RTTI Over Executable Project

in C# you can easily open an assembly (just another word from an EXE) and then get reflection information from that assembly. I've been looking for something similar for Delphi where I can write a Delphi program that can point to a Delphi EXE then get me reflection information. How can I archive this? Thanks
There are a handful of programs that can extract RTTI from Delphi programs and DLLs. It's not as rich as what's available for .NET, but it can be done to a limited degree. There's a lot more RTTI available in Delphi 2010 and later versions, but as far as I know there's no program out yet that can extract info from them.
I was at the conference where this system was formally announced, and a bunch of people asked how this would affect security. Barry Kelly, who created the new RTTI, said that there would not be enough metadata available to create a "Delphi Reflector".
Well, sad news is, you probably can't. You can easily view .NET assemblies because they a) are compiled to what is called intermediate language (thus you can even get the code back using the likes of Reflector etc.), and b) contain metadata. Delphi, on the other hand, compiles to native code that and produces regular PE files that do not include rich metadata like a .NET assembly.
Delphi just doesn't work that way.
There are tools that can assist in reversing (Delphi written) executables but it will never be easy and it requires good x86 assembly knowledge.
Some examples of such tools are:
IDA Pro and/or Hex Rays
DeDe
Interactive Delphi Reconstructor
PE Explorer
The resource sections of a Delphi Executable also reveals usefull info like the form and it's components.
See also Is there a program to decompile Delphi?
If you have Delphi2010+ you can load a bpl and then use the rich rtti over it lik. e you do with c# and a .net assembly. If you need to do this in a .exe AFAIK you can't.
TestComplete seems to identify most objects in a running Delphi executable. You can extract this information with a script. A demo can be downloaded from http://www.automatedqa.com/downloads/testcomplete
This is maybe not the type of application you want as it is big and made for GUI-testing, but yes it can identify the objects.
As mentioned Remko, IDR (Interactive Delphi Reconstructor) can extract all RTTI information (if program contains it!) for Delphi version from 2 to 2009. Version 2010 will be available later. Moreover IDR can use all information that it finds in program to create a lot of comments to disassemled program code (this is a first step of analyses). You can also look forms and easy go to event hadlers associated with controls.

Is it possible to have Delphi auto-generate event-support code for an imported OLE/COM type library?

I'm trying to generate _TLB import units for Outlook 2003, 2007 and 2010 (and also other OLE servers) analogous to the ones bundled with Delphi for Outlook 2000 and 2002. However, I couldn't get the type library importer to also generate the code for capturing events from the OLE servers that is found in the bundled units. The option to "Generate component wrappers" only creates wrappers for servers that are directly instantiatable but not for objects that are only returned via methods of other objects like TInspector, TExplorer, etc.
I could of course create the event handling code myself but that would be really tedious work.
Does anyone know if the importer contained with Delphi 2010 (tlibimp.exe) can be tweaked to generate that code? I really doubt that back in the day Borland created the existing Outlook2000.pas and OutlookXP.pas units manually...
Are there maybe any other tools around that can do this?
Good question! I never noticed that those components were not created (I only use Word_TLB). After playing a bit with tlibimp I found out that you need the -Yc+ flag. Probably all ignore flags are default on.
NB: this is on Delphi 7 with tlibimp.exe version 7.0.4.453

Resources