WinBatch Dynamic Dialog Tutorial

Started by Deana, June 13, 2013, 10:44:10 AM

Previous topic - Next topic


WinBatch supports both static dialogs and dynamic dialogs. Both types of dialog are usually drawn with the WinBatch Dialog Editor. When using a static dialog, the user fills in fields, checks various items and makes assorted selections. Then they press some sort of Submit button and the dialog exits and the WinBatch code continues. Outside of standard primitive responses, the dialog does not interact with the user very much outside of accepting the user input.

When using Dynamic Dialogs, there is the potential for a Dialog Procedure, written in a special WinBatch User Defined Function or User Defined Subroutine, to interact with the user and do any number of actions as the user is progressing through the dialog. Actions might include validating user input, reconfiguring the dialogs, disabling various choices based on prior input, or almost anything.

The Dialog Editor allows automatic code generation of a standard static dialog. This tutorial covers the steps in transforming such a static dialog into a Dynamic Dialog.

Note: You can easily generate the Dialog Callback Procedure code in WinBatch Studio.

Adding Dialog Procedure code
Basically, to do Dynamic Dialogs, you have to add code, either in a #DefineFunction or a #DefineSubroutine block to instruct WinBatch what to do while the user is interacting with the dialog. Although it is easily possible to write all the Dialog Procedure by hand, it gets exceedingly tedious very quickly. And, furthermore, most Dialog Procedure code has the same basic structure as other Dialog Procedure code. And, to carry on about this a bit more, most of the Dialog control functions have dozens of hard to remember request codes that give no readable hint as to what is going on when examining the code. Hence, an automatic Dialog Procedure code generator has been added to WinBatch Studio. It will define a WHOLE bunch of useful constants (many, many more than you will likely need) and it will also generate a useful block of template code based on your dialog.
To have WinBatch Studio generate the Dialog Procedure template code, you simply highlight your dialog code, top to bottom, starting with the line similar to..   
Code (winbatch) Select


all the way down to and including the line       
Code (winbatch) Select


Next, RIGHT-Click the WinBatch edit window, to get the WinBatch Popup menu to come up, Then select the menu item.

   Code Blocks
           Create Dialog Callbacks in Clipboard
                Function with Constants

When it is complete, usually just a second or two, paste the generated code into your script, usually above your original Dialog Definition code. 

Next, Locate the line similar to
Code (winbatch) Select

in the area at the bottom of the code you pasted (usually a block marked in red), and move it into the corresponding line at the top of your Dialog Definition code you made with the Dialog Editor. Then delete the explanatory lines in the generated code that tell you what to do this particular operation.

Now you are done. At this point you have to uncomment desired lines in the generated code and add your own code to make the Dialog Callback do what you need.

Deana F.
Technical Support
Wilson WindowWare Inc.