Delphi Runtime ActiveX Viewer

Delphi Runtime ActiveX Viewer Here's some Delphi code that allows you to create any ActiveX control at runtime. You can also set and get properties and call methods. I originally got this idea and some of the code from a magazine article, but I can't remember which magazine. A guy called Jay Cherrabi has also helped out with the code and got me motivated to actually upload it here.

TRegAxCtrlList class

This class provides a list of the ActiveX controls that the registry says are installed on your system. There are properties providing the ClassID, ProgID, description and filename of each control. In some cases, your registry will contain entries for non-existent controls, so this list may be incorrect.

TActiveXHost class

This class acts as the host for the ActiveX control. It provides a list of the available properties, methods and events. It allows you to get and set properties, call methods and sink events via the OnEvent event handler. Now will also allow you to create a control that isn't registered via the filename and the GUID.

TTypeLibViewer class

This class acts as a wrapper around the WinAPI functions for accessing type libraries

Download

This ZIP file contains these three classes and an example application

Delphi 5

I wrote this using Delphi 7 and it won't compile in Delphi 5. This is because the methods StandardEvent and InvokeEvent are private in TOleControl in Delphi 5. In Delphi 7, these are now protected and virtual. So you have two options if you want to compile this in Delphi 5. You can copy OleCtrls.pas to your project directory and make the two methods protected and virtual. Alternatively, if you don't care about events, then comment out the code

To Do

  • Parameterised properties