Example 2 - How to Pass Parameters to DLLs


Purpose of Example


Overview of Example Strictly speaking, passing parameters to DLLs is not a Visual CADD API question, but is a Visual Basic or Visual C++ programming question. Parameters are data or values which are passed to programs (DLLs or EXEs), which are then processed by the program in some way. The kind of data which could be passed to Visual CADD API applications includes text for text or leader entities, point locations, layer or line type numbers, and many others. There are a great number of occasions where your Visual CADD API applications would be much more powerful if they could accept parameters.

For instance, the ways to hide or display layers in Visual CADD, such as Hide Layer (YH), Display Layer (YD), and Layer Manager (MGL), each open a dialog (or ribalog) which prompts the user to enter additional input to control the layers. In the case of Hide Layer (YH) or Display Layer (YD), the user must enter the layer number to hide or display. This additional input cannot be put into a script or the CMDEXT.DEF file. Therefore, doing something as simple as 'hide layer 12' cannot be done in a script.

If we could pass a layer number to a DLL or OLE DLL, we should be able to create some flexible ways to manage layers from scripts, such as 'hide layer 10,' 'show layer 2,' and 'toggle layer 4.'

Bear in mind that the main purpose of this example is to show how your DLL or OLE DLL can accept and process parameters. Turning the display of layers on and off is not especially powerful by itself. However, by seeing how easy it is to create DLLs which handle parameters, you should be encouraged to think of how you might write powerful DLLs for a variety of tasks which may require some additional input into the program.

The Visual CADD API has two routines for getting and setting the display of layers - VCGetLayerDisplay and VCSetLayerDisplay. Writing a simple DLL with three functions, each of which accepts one parameter as input, allows you to create scripts or two-letter aliases which will:

Visual Basic Example 2 Code
Visual C++ Example 2 Code