ocx-scribble library


This project contains an example that demonstrates a program written using DUIM which can be used 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.

This is a simple drawing program, where the user can do arbitrary free-hand line drawing by dragging the mouse. The file scribble.dylan has only a couple of modifications from the original non-OLE version (in the DUIM example scribble in Examples\duim\scribble\): the scribble frame inherits from <ocx-frame> instead of <simple-frame>, and a couple of calls to note-embedded-data-changed have been inserted. The file storage.dylan implements persistent storage and the file run.dylan adds some additional support for use as an OLE Control. This control defines one read-only property, which is the number of lines drawn, and one method, which erases the drawing.

Building this library produces a file named ocx-scribble.dll. You might want to manually rename it to scribble.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 scribble.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 scribble.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. It 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 DUIM OCX Scribble", which comes from the documentation option in the define coclass form in file run.dylan.