button-ocx library


This project contains a simple example that demonstrates using a DUIM gadget as an OLE Control (also known as an "OCX" or "ActiveX Control").

This example uses the DUIM-OLE-Control library which is documented in the Functional Developer "OLE, COM, ActiveX and DBMS" reference manual.

The file control.dylan defines a frame containing a single button and a dialog box that appears when the button is pressed. The dialog box has a text pane that can be edited. The file store.dylan implements persistent storage of the text in the container document file. The file run.dylan makes the frame into an OLE control and implements a "Text" property that can be used to access the dialog box text. Some additional properties will be created automatically for the button gadget.

Building this library produces a file named button-ocx.dll. You might want to manually rename it to button.ocx.

In order for the control to work when invoked from a container program, all of the libraries used by your control need to either be in the same directory as the control DLL file, or else in a directory which is in the system PATH (not the individual user's PATH on NT). The simplest way to accomplish this is to use the "Project > Build Release" command to create a release directory. If you wish, you can move that directory to any location you want, but you must do so before you attempt to register the control.

To register the control, use the regsvr32 command line utility like this:

regsvr32 button.ocx

(The complete pathname will need to be given if the file is in a different directory that is not in the PATH.) This will cause the appropriate entries to be made in the Windows System Registry. (For use in a batch script, the "/s" option may be used to suppress the dialog box reporting completion.) The full pathname of the control is recorded, so you must unregister the control before you move or delete it. You can unregister it by doing:

regsvr32 /u button.ocx

This invokes the control to unregister itself, so won't work if the control has been deleted first.

Now you should be able to insert the object into any OLE Control container program. For example, there is a "Test Container" application included with Visual C++ which can be used. Note that "View -> Properties" can be used to view and change the properties of the control, such as the button label and the dialog text. The control can also be embedded in an OLE document container, such as WordPad, but the properties will not be accessible. In the "Insert object" dialog, this program will be identified as "Dylan button gadget demo", which comes from the documentation option in the define coclass form in file run.dylan.