Sample16: Operations 1

Building a user interface is not the most interesting part of an application developer's work. Well, it's inevitable. But if there is any shortcut to it, it will be welcomed.

Indeed, there is a shortcut. With DLG's  Operations  you can concentrate on what you can do best: those parts that are specific to your application. And keep the boring user interface programming to a minimum.

The most frequently needed operations are implemented in a number of DLG's. The basic ones are included in  Operations 1  .

The following sections will give you some insight into

Operation to emulate tabbing
Operation to display help files
Sub-dialog for file selection
Sub-dialog for directory selection
Operation for memorizing combo entries

After each section you will find a bookmark at the right edge of the screen (top). You can jump back to the top by clicking on it.


Operation
to emulate tabbing


Screenshot of Sample16.exe (tab 0) Screenshot of Sample16.exe (tab 1)

For a tabbed dialog in full DLG quality the standard Windows tab control proved to be insufficient. But there is something better: in DLG you can emulate tabbing by a button group.

To do that, all you need is to create a group of buttons showing the text labels (or graphic symbols) you want to use for the individual tabs. If you code it as in the following code line, the buttons behave exactly like tabs in standard Windows and they are compatible with all the other DLG features:

Control (..., "Button", DYN_BUTTON | BS_MULTISTABLE | ..., ..., "{Select File ... |Select Dir ... \bCustomOp=%d", CO_TAB, "}", ...),


"Button" window class of this control
DYN_BUTTON | BS_MULTISTABLE | ... style bit combination. Note that the buttons should have style BS_MULTISTABLE to reflect the tabbing state intuitively.
(Symbol '|' is part of the C++ syntax: "bitwise OR")
Select File ... |Select Dir ... text labels of the buttons (+ some details), corresponding to the tab labels. Note that they are separated by symbol '|', in order to create them in a group.
\b DLG-specific separator to introduce options
"CustomOp=%d", CO_TAB DLG operation to make the buttons behave like tabs.
"{" ... "}" for perfect emulation the button labels must be written in curly brackets.

top

Operation
to display help files


Screenshot (takeout): HELP button

If you want to make your application very user-friendly, it should offer a HELP-feature wherever the user might feel uncertain about what to do next. One major reason why so many applications lack of HELP-features is because it takes a certain programming effort to offer it to the user.

In DLG, however, you can easily handle this problem: just create a button "Help" as in the following code line.

Or you don't even need to create a button anew. Just declare it in your .rc-file and upgrade it to full DLG mode in your application:

UpgradeCtl (..., "Help ... \bCustomOp=%d", CO_HELP, " HelpFile=%s", <name of .hlp-file>">, ...),


"Help ... " text label of this button
\b DLG-specific separator to introduce options
"CustomOp=%d", CO_HELP option to display a help file when the button is activated
"HelpFile=%s", <name of .hlp-file> operation-specific option to use a certain .hlp-file for display

top

Sub-dialog
for file selection


Screenshot: Sub-dialog for file selection

One thing that's needed for the most part of applications is to prompt the user for the input of a file name. Reasonably this should be possible by selecting a file visually (optionally by entering the name of a new file, by selecting several files at once, etc.)

In DLG all of this is packed into a sub-dialog that appears temporarily when a button is activated.

Such a button can be created as in the following code line:

Control (... , "Button", DYN_BUTTON | ... , ... , " &*.* ... \bCustomOp=%d", CO_FILE, ...),


"Button" window class of this control
DYN_BUTTON | ... style bit combination needed for a push button
*.* text label of the button ("*.*" was chosen to indicate that all files are available for selection)
\b DLG-specific separator to introduce options
"CustomOp=%d", CO_FILE option to tell the button: "present 'file' sub-dialog when user activates you!"

top

Sub-dialog
for directory selection


Screenshot: Sub-dialog for dir selection

In a good deal of applications you need to prompt the user for selecting a directory, e.g. where to store a file to, which files to take into account for further processing, etc. Again, it would be good if this could be done visually, by a DLG control DirSelect (Dlg 1.5)

In DLG this is something that calls for a temporary sub-dialog. In the following code line you can see how a button is created for this job:

Control (..., "Button", DYN_BUTTON | ... , ... , "Dir&1 ... \bCustomOp=%d", CO_DIR, ...),


"Button" window class of this control
DYN_BUTTON | ... style bit combination needed for a push button
Dir 1 text label of the button, indicating that it launches a sub-dialog for directory selection
\b DLG-specific separator to introduce options
"CustomOp=%d", CO_DIR option to assign the button an operation to launch a sub-dialog for directory selection

top

Operation
for memorizing combo entries


Screenshot: Operation for memorizing combo entries

User-friendly applications do not only prompt the user for some inputs, they also memorize the inputs done so far and offer an easy way to reactivate recent entries. This is typically done by accepting user inputs in a combo box and memorizing them in the drop-down list, from which the user can easily retrieve it. (For details see ComboBox, type 2   Dlg 1.3, "... select-or-write ...")

In DLG there is a simple way to do it - just create a button as in the following code line:

Control (..., "Button", DYN_BUTTON | ... , ... , "&Memo"\bDest=%d", cmb1, " CustomOp=%d", CO_MEMO, ...),


"Button" window class of this control
DYN_BUTTON | ... style bit combination needed for a push button
Memo text label of the button, reminding the user that the input can be memorized to be retrieved later
\b DLG-specific separator to introduce options
"Dest=%d", cmb1 option to make the memorize operation refer to combo box 'cmb1'. (By default, an operation refers to the control preceding in Z-order. Sometimes, however, you need to direct it explicitly.)
Note that this option must be coded before the option "CustomOp=", for not to be taken as operation-specific option!
"CustomOp=%d", CO_MEMO option to associate a 'Memorize' operation with this button

top

Home | Outline | DLG