User Position Input (ActiveX Control)

ActiveX Control applications will often require the user to input positions using the mouse as part of an application command or action. This will often be as a part of a set of a procedural actions, e.g. prompt the user for text, then get a position from the user, then create a Text item using the results.

This procedural paradigm conflicts with the Windows Graphical User Interface (GUI) model of dialog input, which allows the user to interact with many controls, in any order, before pressing the OK or Apply button. As a result the ActiveX Control uses Events to tell the application when the user has interacted with it. This approach conflicts with the procedural approach because the Events happen asynchronously.

In order to mimic a procedural approach, it is necessary to split the procedure into two parts: before a position or positions are required; and after the required position(s) have been supplied. The first part may be started by a button press on the application dialog, and would, in the example above, prompt the user for text. After the text is successfully entered, the application would set a flag that signified that a position was being requested. The application would then check for the flag in the Snap event, and if the flag were set would perform the second part of the procedural command, e.g. create a Text item using the previously entered text, before resetting the flag.

This approach does have drawbacks however: global flags are required to monitor the application state which other user actions can affect; and global variables are required, e.g. to remember the text. It is possible to ameliorate these drawbacks: e.g. eliminate a global variable by getting the position first then prompting the user; show another dialog to collect the details; or disable the rest of the dialog until a position is entered. However the dichotomy between the procedural- and event-based paradigms remains.

GetPos/GetPosEx

GisLink, which has the advantage of using SIS as an application, as opposed to the ActiveX Control that exists within a foreign environment, has the GetPos and GetPosEx methods to overcome the procedural versus event problem. The same techniques can be used with the ActiveX Control using Visual Basic and Visual C++, but are unsupported because other OLE Container applications may not have an equivalent, or their effects may be platform-dependent.

Both the Visual Basic and Visual C++ code fragments shown may be used to get more than one position from the user as outlined in User Position Input above.


Send comments on this topic.

Click to return to www.cadcorp.com

© Copyright 2000-2017 Computer Aided Development Corporation Limited (Cadcorp).