PerfectScript Journal
 

June 1997: Creating Macro Dialog Code from Dialog Editor Dialogs 

This month we'll look at a new feature in WordPerfect 7 that allows you to generate macro dialog box code from a Dialog Editor dialog. This feature also exists in WPWin 8 for Windows 95. 

In WPWin 6.1, the Macro Dialog Editor was introduced. The Dialog Editor simplified the process of creating dialogs, allowing you to drag and size dialog controls to any location you wanted on the dialog. But if you needed to do some custom callback routines, or distribute the macro in an uncompiled state, or publish the source code, you were out of luck. 

WPWin 7 for Windows 95 has solved that problem. You can now create your dialog in the Dialog Editor, then paste the source code for the dialog right into the main macro code. Here's how: 

After typing your Application statement and saving a new macro, the Dialog Editor button on the macro toolbar becomes active. Click the button to open the Dialog Editor. Click File | new on the menu. A new dialog entry will appear. Type a descriptive name for the dialog and press (Enter). Double-click the entry and a new dialog will appear, complete with tool palette. 

Design your dialog as you would like it to appear, defining region names, variable names, etc. in the properties of each control and of the dialog itself. (See the online macro help for more info if you're not sure what you're doing here yet.) When you're done with your dialog box, click File | Save on the tool palette menu, then File | Close. 

Your dialog should still appear in the Dialog Editor list. With the dialog highlighted there, click Edit | Copy. Now click in your macro code where you'd like the code for the dialog to go. Click Edit | Paste. The dialog code will be copied to the position of the insertion point. 

Note: You now have two dialogs with the same name in the macro: one in the Dialog Editor and one in the macro code. You'll need to either delete or rename the one in the editor before you can use the macro. 

Now, say you started to create your dialog in the macro code but decided it might be easier to use the Dialog Editor. You can copy that dialog to the editor with the DialogSave command. 

Just before your DialogShow command, add the command DialogSave (dialog name; newname), whenre dialogname is the dialog ID of the dialog, and newname is the name you want to give the dialog in the Dialog Editor. Save and compile the macro, then exit the macro file. When you run the macro, the dialog will be placed in the Dialog Editor. The next time you open the macro, you'll be able to edit it there. 

Note: You'll need to change the dialog ID in the DialogShow command before the Dialog Editor version of the dialog can be displayed. 

With the new capabilities of the Dialog Editor, creating dialogs is easier and more flexible than ever. 
If you have topics you'd like to see covered in The PerfectScript Journal, email the author.

Copyright Notice: The information included in the PerfectScript Journal is protected by US Copyright. The author grants you the right to use the routines in your own macros as needed. You may not sell, distribute, or publish them in any form.
If you choose to use the information here, you do so entirely at your own risk. No representations are made regarding the fitness of this information for your   particular purpose, or for your ability or inability to use the information. You   are advised to make backups of all relevant files before implementing any suggestion  or technique.
© Copyright 1997 by J. Jeppson.