Copyright: Copyright (c) 1995 by Intergraph Corporation


Step2 Select Type Library
Step 2.  Select Type Library

See Also

Macros can be written to operate in conjunction with the Imagination Engineer application.  In this case it is possible to use the constants and types which are present in that application’s type library.

Choose one or more type libraries by selecting a type library name from the Type Library Name list.  Remove your selection by selecting an already selected type library name from the Type Library Name list.

Once the macro is created, you can view the constants and types for the selected type libraries using the Object Browser.  You can add more type libraries using the References command.  You can also change the order in which type libraries are searched using the References command.

Navigating the MacroWizard


Step3 Select Project Name and Location
Step 3.  Select Project Name and Location

See Also

A macro is contained inside a project.  Choose the project name and location for your macro.  You can also locate your macro in a directory you create in this step.

Name

Choose a project name by entering a name into the Project Name edit box.   Other module names are derived from the project name you choose.  For example, if you type “MacroProject” for the project name, the MacroWizard chooses “clsMacroProject” for the macro name and “frmMacroProject” for the form name.  You can always choose different names for these modules.  See Step 4 Select Macro Name and Step 7 Form Name and Position for more information.

Location

Change the drive by selecting a drive from the Drives list.  Change the location by choosing directories in the Project Location list.

New Subdirectory

If you want to create a new subdirectory, type the directory name into the New Subdirectory Name edit box.

Navigating the MacroWizard


Step 4  Select Macro Name

See Also

A Macro has a name, a description and a tool tip.  The name is required while the description and tool tip are optional.

Choose the name by typing the name into the Macro Name edit box.

Choose the description by typing a description into the Macro Description edit box.  The description is displayed in the application status bar.

Choose the tool tip by typing a description into the Macro Tool Tip edit box.  The tool tip is displayed when you move the mouse cursor to a toolbar button and hesitate before moving the mouse to another control.

Navigating the MacroWizard


Step1 Macro Wizard Introduction
Step 1.  Macro Wizard Introduction

See Also

The Imagination Engineer MacroWizard is a tool that helps you develop macros written in Basic that can be made accessible from OLE Automation Clients.  The MacroWizard generates a class module, a main subroutine, and possibly a form for a macro.  The MacroWizard implements certain parts of the code that are typically the same for all macros.

Once the macro is created, you can make an EXE (executable) or a DLL (dynamic link library) and run the macro through Imagination Engineer’s Run Macro Command.

Navigating the MacroWizard


Step 5  Add Toolbar Bitmap

See Also

Many applications let users drag and drop macros to their toolbars so that users can run their macros from the toolbar.  The MacroWizard can add a resource containing a toolbar bitmap to the project.

Choose Add custom bitmap if you have a bitmap you would like to show on the application toolbar.  See Step 6 Choose Custom Bitmap for details about locating a custom bitmap.

Choose Add default bitmap if you want the MacroWizard to add a default bitmap and resource to the project as a place holder which you can edit later.

Choose Do not add any bitmap if you do not want any bitmap and resource added to the macro.  If you choose this option and you drag your macro to a toolbar, some applications will be prompt you to locate a bitmap to display on the toolbar button and give you a selection of bitmaps from which to choose.

Navigating the MacroWizard


Step 6  Choose Custom Bitmap

See Also

Choose the custom bitmap you want to be displayed on your macro’s toolbar button.

Look for the bitmap in the current drive or choose a different drive by selecting a drive in the Drives list.  Look for the bitmap in the current directory or choose a different directory by selecting a directory from the Directories list.

As you choose drives and directories, the MacroWizard locates bitmaps it finds and displays their names in the Files list.  Choose a bitmap from this list.

Navigating the MacroWizard


Step 7  Choose Form Name and Position

See Also

All macros must have a primary form on which the Imagination Engineer Command Control resides.  Choose the name of the form and how the form should be positioned when displayed to the user.

Choose the from name by typing the name in the Form Name edit box.

Choose the form position by selecting from the following Form Position options

•	Form is never shown to user

•	Form is centered in the Imagination Engineer application window

•	Form is centered in the screen

•	Form is displayed in the position in which it was designed

Note  If your form is centered in the Imagination Engineer application window or in the screen, be sure to size your form appropriately.

An example of a macro that does not display its form might include a macro that first searches a document for lines that are blue and then changes each line’s color to green.

Once the macro is created, the MacroWizard adds the Imagination Engineer Command Control to the form and to the tool box.  You can view the constants and types for the Command Control using the Object Browser.

Navigating the MacroWizard


Step 8  Mouse Interaction

See Also

Some macros require interaction with a mouse, for example, a macro might collect mouse coordinates.

You can allow your macro to interact with a mouse by selecting the Macro Requires Mouse Interaction check box.

An example of a macro that requires interaction with a mouse might include a macro that shows database information about document objects.  As the user moves the mouse and hesitates over document objects, you could show the database name.  If the user clicks the element and a database is attached, you could show the information from the database.

Once the macro is created, the MacroWizard adds the Imagination Engineer Mouse Control to the form and to the tool box.  You can view the constants and types for the Mouse Control using the Object Browser.

Navigating the MacroWizard


Step 9  Modeless Form

See Also

Some macros require that the user be able to interact with Imagination Engineer while the form is displayed.  Such a form is referred to as ‘modeless’.

If your macro requires a modeless form, choose the Macro Requires a Modeless Form check box.

Macros that require modeless forms are required to be built as an executable (EXE) and cannot be built as a dynamic link library (DLL).  See Step 10 How Is Macro Built? for more DLL details.  To move to Step 10, uncheck the Macro Requires a Modeless Form check box and press the Next button.

An example of a macro that requires a modeless form might include a macro that allows users to locate document objects and then displays properties about the located object in its form.

Navigating the MacroWizard


Step 10  How Is Macro Built?

See Also

Macros with a modal form or a form that is not shown can be built as a DLL or an EXE.  Macros that can be built as a DLL run in the same address space as the application and run faster than if they were built as an EXE.

If your macro should be built as a DLL, choose the Build Macro as Dynamic Link Library (DLL).

Navigating the MacroWizard


Step 11  Macro Type

See Also

Macros with a modal form can be treated like a wizard whereby the macro collects input and then terminates or can collect input and remain running when the form is dismissed.

If your macro is like a wizard, choose the Macro is Like a Wizard option.

If your macro collects input and remains running, choose the Macro Collects Input and Remains Running  option.

An example of a macro that remains running might include a form that allows a user to select a line style and when the user chooses OK the macro remains running and changes all lines in the document to the style the user chose.

Navigating the MacroWizard


Step 12  Stop Processing?

See Also

Macros with a modal form may let users interrupt processing while a compute intensive task is occurring.

If your macro has options that may take significant time to complete, you may want to include a stop processing button on your form.  The MacroWizard can add a button and sample comments to the form to allow users to interrupt processing.

An example of a task that may take significant time to complete might include finding all graphic elements in a document, changing the color, and repainting the screen.

Navigating the MacroWizard


Step 13  How Is Form Displayed?

See Also

Macros with a modal form can display their form as the macro is invoked or when a function key is pressed.

Choose the Macro Displays its Form as a Function Key is Pressed option if your macro should be displayed as a function is pressed.  Choose which function key causes your form to be displayed from the Choose Function Key list.

An example of a macro that displays its form as a function key is pressed might include a macro that helps a user create a graphical representation of an object stored in a database.  The macro form shows database information about the object in the database.  At times while creating the object, the user may need to refer to the database information and then return to creating the object.

Navigating the MacroWizard


Complete

See Also

The MacroWizard has all the information needed to create your macro.  Press the Finish button to create your macro.

Once the macro is written, the MacroWizard changes from the current project to the newly created macro project.  If any changes were included in the current project, you will be prompted to save those changes.

You can review Frequently Asked Questions or Visual Basic Online in this step.

Navigating the MacroWizard


Choose Resource Filename
Choose Resource Filenames

The Macro Wizard has found that the resource filenames that result from the custom bitmap chosen already exist on your system.

Choose another name by typing into the Resource Filename edit box.

Accept by pushing the OK button.

Cancel by pushing the Cancel button.


IntroSeeAlso

See Also

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step2SeeAlso

See Also

Step 1. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step3SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step4SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step5SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step6SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step7SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step8SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step9SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step10SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step11SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 12. Stop Processing?

Step 13. How Is Form Displayed?

Complete


Step12SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 13. How Is Form Displayed?

Complete


Step13SeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Complete


FinishSeeAlso

See Also

Step 1. Select Type Library

Step 2. Select Type Library

Step 3. Choose Project Name and Location

Step 4. Choose Macro Name

Step 5. Add Toolbar Bitmap

Step 6. Choose Custom Bitmap

Step 7. Choose Form Name and Position

Step 8. Mouse Interaction

Step 9. Modeless Form

Step 10. How Is Macro Built?

Step 11. Macro Type

Step 12. Stop Processing?

Step 13. How Is Form Displayed?


Navigating

Navigating the MacroWizard

Cancel the MacroWizard by pressing the Cancel button.

Move to the next step by pressing the Next button.

Move to the previous step by pressing the Back button

The Finish button is enabled in the last step when you

have answered all questions needed to generate the macro.

Press this button when you are ready to create the project

and code for your macro.

Certain steps are skipped depending on the options

you select, for example, Step 6 Choose Custom Bitmap is

skipped if you choose Add default bitmap in

Step 5 Add Toolbar Bitmap.


Frequently Asked Questions

Question	I’ve already built my macro and didn’t choose to include a bitmap.  How can I change my macro to include a bitmap without running the Macro Wizard again?
Answer	Create a resource source file with a text editor.  Insert a line into the file like:     MacroProj.clsMacroProj BITMAP DISCARDABLE   C:\temp\macro.bmp The first string (MacroProj.clsMacroProj) is the Programmatic ID for your macro.  This ID is your macro project name and your macro class name separated by a period.  The last string is the complete path to the bitmap you want to use for your macro. Save this file with an extension of .RC. Compile the source file using Visual Basic’s Tools Resource Compiler.  The resource compiler produces another file with the same name as you used above but with a .RES extension. Insert the resulting resource file (.RES) into the project using the File-Add File command. Then build your macro using File-Make OLE DLL File or File-Make EXE File.
Question	I’ve already built my macro and didn’t enter a macro description or tool tip.  How can I change my macro to include these without running the Macro Wizard again?
Answer	Using the Object Browser, select the exposed class for your macro.  Choose the Options button and a dialog is displayed.  Enter your macro description and tool tip in the description edit box on this dialog.  The description and tool tip should be separated by ‘\n’.  Here is an example,  “This macro draws a line\nDraw Line”, but don’t include the double quotes.
Question	When I try to run macro "A" the system runs macro "B" instead.
Answer	This problem is likely caused by automation server “A” and “B” having the same server name.  Server names must be system unique and are expressed as project_name.class_name.  The project name is set via “Tools/Options.../Project/Project Name” and the class name is the name of the exported class, a.k.a., ClassModule.Name.
Question	When I run my Exe macro, I notice that I get lot's of new processes in the Task List.
Answer	This likely means that you did not unload your form during Class_Terminate and because of the existence of the form the VB application process cannot exit.
Question	When I run my Dll macro I get the error "This property can only be set once.".
Answer	This means that either you are trying to set the Command property on the command control more than once -or- you did not unload your form during Class_Terminate.
Question	When should I display my form?
Answer	Don't display your form until the command control fires the Activate event.  Correspondingly, you need to hide your form on Deactivate.
Question	Is there some way I can make my VB forms come to the front?
Answer	Yes.  The main VB form is the one on which the command control is placed. Imagination Engineer will ensure that this form remains on top.  If you are using another form then you need to set the hWndForm property on the command control to the hWnd of your VB form.  This will ensure that your form, if visible, will always be on top.
Question	Are there any restrictions when building a VB DLL automation server?
Answer	Yes.  Your automation server must be flagged as "Creatable MultiUse" and you cannot display a modeless form.  There are other restrictions as well.  The best thing to do is the read about MultiUse servers in VB Online.
Question	I cannot get the DLL stuff to work.
Answer	You can't debug VB DLL's so it is critical that your code works perfectly before building a DLL. First build your project as an Exe with "Tools/Options.../Advanced/Use OLE DLL Restrictions".  Next, run your project from VB and thoroughly test it.  Note that it appears that some restriction violations are only reported at runtime when the project is being debugged in VB.
Question	When I try to run a VB macro I get an error dialog which says "Can't load file".
Answer	The Path variable in Control Panel/System is probably not properly set.  You need to have the application's bin or program directory in your Path under System Environment Variables.
Question	When I run my macro it locks up the application.
Answer	The system is probably not locked up but rather VB is displaying a dialog/msgbox and the window is behind the application. Alt-Tab through the task list and select the running  VB project to bring it to the front.
Question	I'm having difficulties understanding the difference between SingleUse and MultiUse classes and when to use global variables.  Any hints?
Answer	Classes in an Exe can be marked as either single use or multiple use.  Single use means that another instance of the process (Exe) is launched each time an instance of the class is constructed.  Multiple use means that if an instance of the process is already running then a new instance of the class will be constructed in that process.  Building multiple use Exe's requires a bit of care with respect to global variables.  For DLL servers you have to use multiple use classes.  Watch those global variables!!  See the application samples for examples of each.
Question	When my DLL automation server encounters an error it crashes the host application.  What can I do?
Answer	When VB encounters an unhandled error in an event procedure it calls the Win32 function ExitProcess.  This is all fine and good for an Exe server but in the case of a DLL server it crashes the host application (admittedly in an orderly fashion).  This is most hideous. The only course of action that is to either code with out mistakes or to make sure that you have an error handler declared for each function.
Question	Are there any coding standards I should be using for VB macros?
Answer	Variables and code the wizard automatically generate follows the standard Microsoft VB coding convention which can be found on MSDN under: Product Documentation, Office Developer's Kit, Office Programming Resources, Programming Integrated Solutions with Microsoft Office, Visual Basic Variable Naming and Coding Guidelines. In addition to these standards the wizard uses the "igm" and "igc" prefixes for Imagination Engineer Mouse and Command controls respectively.  Also class names should have the Class or Cls suffix.


Displays Help for this step.


Cancels the Macro Wizard without saving any selections.


Advances to the next step.


Returns to the previous step.


Generates the source for your macro.


Displays questions and answers about writing macros.


Displays Visual Basic Online if available.


Displays available type libraries that may be attached to the macro project file.


Selection lets the macro interact with a mouse.


Choose the macro project name.


Choose the disk drive where the macro will be saved.


Choose the directory where the macro will be saved.


Key in a new directory name and the Macro Wizard will create this directory.


Selection lets the macro add a custom bitmap to the project for use on a tool bar button.


Selection lets the macro add the default bitmap to the project for use on a tool bar button.  This bitmap is added as a place holder.


Selection lets the macro add no bitmap to the project.


Displays the bitmap name chosen.


Displays a list of available bitmaps in the selected drive and location.


Choose the directory where the custom bitmap is stored.


Choose the drive where the custom bitmap is stored.


Selection lets the macro include a stop processing button on the macro form.


Selection lets the macro act like a wizard, that is, it collects input and terminates.


Selection lets the macro remain running after the macro’s form is dismissed.


Choose the macro form name.


Selection tells the Macro Wizard that the macro’s form is not shown to the user.


Selection tells the Macro Wizard that the macro’s form is centered within the application.


Selection tells the Macro Wizard that the macro’s form is centered on the screen.


Selection tells the Macro Wizard that the macro’s form is shown in the location in which it was designed.


Choose the macro name.


Choose the macro description.


Choose the macro tool tip.


Selection lets the macro display its form as a function key is pressed.


Choose the function key that will display the macro form.


Selection lets the macro include a modeless form.


Selection tells the Macro Wizard that the macro is built as a DLL.


Choose the resource filename.


Displays the files located in the bitmap and resource directory.


Accepts the selected resource filename and dismisses the form.


Cancels the selected resource filename and dismisses the form.


Cancels the selected bitmap filename and dismisses the form.


Accepts the selected bitmap filename and dismisses the form.


Choose a new name for the default bitmap filename.