Database Solutions - Hints & Tips

Tip 30:
OCXs and the UNIFACE Development Environment

Problem:

You have incorporated an OCX into your UNIFACE form, to provide some new whizzy user interface. But when you test it within the development environment, the OCX does not work properly. Some of the methods that you use work and some don’t, but if you test it in your application it works ok, or even if you test it using the command line, i.e. idf /tst.

When the methods are invoked, they perform statement returns a $status value of -1. No further information is given in the IDF transcript window.

It may even be the case, that some other, possibly simpler OCXs work fine in the IDF, whereas the one you are using does not.

So what is going on?

Solution:

UNIFACE has a setting (USERMODE) to control OCX behaviour in the INI file, in the [OCX] section.

Valid values are:

[OCX]
USERMODE=DESIGN

or

[OCX]
USERMODE=RUN

If USERMODE=DESIGN, the UserMode for all OCXs is set to off, this means that is possible to change the Native properties of the OCX in the development environment, but prevents some of the OCX methods functioning.

If USERMODE=RUN, the UserMode for all OCXs is set to on, this means that it is not possible to change the Native properties of the OCX within the IDF, but does mean that the OCX methods should operate correctly.

If the setting is absent, the default value is determined by how the form is run. If the form is run using the File->Test option of the development environment, then UserMode is off, i.e. some of the methods might not work. If the form is run in any other way, i.e. from the command line (/tst), or from a separate start-up shell, then UserMode is On.

So, if you are changing the values of the native properties of the OCX, then you need to use the USERMODE=DESIGN option, but this means you cannot test your form using the IDF.

Once you are happy with the values of the native properties, then you can set the value back to USERMODE=RUN

compuware_01.gif (3977 bytes)


Copyright ©2000 OCS Consulting plc

dbs_block_logo.gif (2150 bytes)
Refresh Frames