![]() |
If you want to handle a color, font, etc. in a dialog, you need to present it to the user in its natural form. In standard Windows this means quite a lot of programming. In DLG all you need to do this is using one additional control type: Display.
The following sections will give you some insight into
| color-Display | |
| font-Display | |
| pattern-Display | |
| symbol-Display | |
| Scribble-Pad |
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.
| color-Display |
![]() |
DLG makes extensive use of colors. Computer-internally a color
is represented by a 24bit-value, the well-known "RGB-value". To the user, however,
this would be far too much abstract. By a Display you can transform an RGB-value
into the corresponding color.
To do that, you simply feed it into a Display - like in the following
code line:
| Control (stc1, "Display", 0, ..., ..., ..., ..., "\bIOdata=%p", &lColor, "Color", ...) |
| stc1 | identifier of this control |
| "Display" | window class of this control |
| 0 | placeholder for style indicator (A Display is style-invariant.) |
| \b | DLG-specific separator to introduce options |
| "IOdata=%p", &lColor | Option to declare variable lColor as the object to be displayed. |
| "Color" | Option to tell DLG that this variable is an
RGB-value, i.e. representing a color. (If the Display is the output of a custom operation, this option can be omitted.) |
| font-Display |
![]() |
In DLG you can use different fonts for different
meanings. (A very user-friendly way to get across some subtle information.)
In the computer a font is represented by a number, the "font handle". The user, however, wants to see how the font looks like.
This can be pictured simply by feeding the font handle into a Display - like in
the following code line:
| Control (stc2, "Display", 0, ..., ..., ..., ..., "\bIOdata=%p", &hFont, "Font", "IO=%p", szFont, "IOsize=%d", sizeof(szFont), ...), |
| stc2 | identifier of this control |
| "Display" | window class of this control |
| 0 | placeholder for style indicator (A Display is style-invariant.) |
| \b | DLG-specific separator to introduce options |
| "IOdata=%p", &hFont | Option to declare variable hFont as the object to be displayed. |
| "Font" | Option to tell DLG that this variable is a
font handle. (If the Display is the output of a custom operation, this option can be omitted.) |
| "IO=%p", szFont | Option to make the font name be stored to
char array szFont. (If you don't need the font name, this option can be omitted.) |
| "IOsize=%d", sizeof(szFont) | Option to tell DLG the maximum string size to be
stored at szFont. (If option "IO=%p", szFont is omitted, this option can be omitted, too.) |
| pattern-Display |
![]() |
If you want the user to select among various patterns, you
have a problem: Computer-internally a pattern is determined by an abstract numeric
value, the "brush handle". But to the average user this means nothing. You need to
transform it into its natural form.
To do that, you simply treat it by a Display - like the following code line:
| Control (stc3, "Display", 0, ..., ..., ..., ..., "\bIOdata=%p", &hPattern, "Pattern", "IO=%p", szPattern, "IOsize=%d", sizeof(szPattern), ...) |
| stc3 | identifier of this control |
| "Display" | window class of this control |
| 0 | placeholder for style indicator (A Display is style-invariant.) |
| \b | DLG-specific separator to introduce options |
| "IOdata=%p", &hPattern | Option to declare variable lColor as the object to be displayed. |
| "Pattern" | Option to tell DLG that this variable is a
brush handle, i.e. representing a pattern. (If the Display is the output of a custom operation, this option can be omitted.) |
| "IO=%p", szPattern | Option to make the name of the file holding the pattern bitmap
be stored to char array szPattern. (If you don't need the file name, this option can be omitted.) |
| "IOsize=%d", sizeof(szPattern) | Option to tell DLG the maximum string size to be
stored at szPattern. (If option "IO=%p", szPattern is omitted, this option can be omitted, too.) |
| symbol-Display |
![]() |
A symbol is, similar to a pattern, computer-internally represented
by an "icon-" or "bitmap-handle". To the user, however, such an abstract number would
mean nothing. Again you have the problem to present the symbol in its natural form.
To do that, in DLG there is a specific control type:
Display.
You can visualize a symbol by coding a line like the following:
| Control (stc4, "Display", 0, .., .., .., .., "\bIOdata=%p", &hSymbol, "Symbol", "IO=%p", szSymbol, "IOsize=%d", sizeof(szSymbol), ...) |
| stc4 | identifier of this control |
| "Display" | window class of this control |
| 0 | placeholder for style indicator (A Display is style-invariant.) |
| \b | DLG-specific separator to introduce options |
| "IOdata=%p", &hSymbol | Option to declare variable hSymbol as the object to be displayed. |
| "Symbol" | Option to tell DLG that this variable is a
symbol handle, i.e. representing an icon or a bitmap. (If the Display is the output of a custom operation, this option can be omitted.) |
| "IO=%p", szSymbol | Option to make the name of the file holding the icon/bitmap
be stored to char array szSymbol. (If you don't need the file name, this option can be omitted.) |
| "IOsize=%d", sizeof(szSymbol) | Option to tell DLG the maximum string size to be
stored at szPattern. (If option "IO=%p", szSymbol is omitted, this option can be omitted, too.) |
| Scribble-Pad |
![]() |
Up to now a Display was used for read-only. In many applications, however,
you want to present any graphic information to the users. They are prompted for clicking or
marking particular points in the image; based on these responses the application decides how to
proceed.
If you want additional user-friendliness, provide a "selection rectangle": a temporary rectangle
by which the user can encircle several points at once, instead of clicking on them individually.
Examples are applications of computer-aided-instructions (CAI), many edutainment
applications, etc.
You can do this by one option only:
| Control (stc5, "Display", 0, .., .., .., .., "#<name of bitmap-file>\bDrawProc=%p", DrawProc, ...) |
| or |
| Control (stc5, "Display", 0, .., .., .., .., "*%x", <bitmap-handle>, "\bDrawProc=%p", DrawProc, ...) |
| stc5 | identifier of this control |
| "Display" | window class of this control |
| 0 | placeholder for style indicator (A Display is style-invariant.) |
| #<name of bitmap-file> | name of .bmp-file holding the bitmap to be displayed (By default it is assumed to be stored in the DLG default directory. If it is stored somewhere else, the full path must be coded here. Details on DLG default directory see DLG Setup, Install.) |
| "*%x", <bitmap-handle> | handle of bitmap to be displayed (Just as well it could be displayed in any other way, e.g. by a custom operation - see Sample 1.11, CO_SYMBOL.) |
| \b | DLG-specific separator to introduce options |
| "DrawProc=%p", DrawProc | Option to link callback procedure DrawProc into the DLG application-framework. (Details see below.) |
The callback procedure to make the Display a Scribble-Pad basically looks like this:
void DrawProc (HWND hDB, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) // update application-specific representation here
{
case WM_LBUTTONDOWN: if ( ... ) freehand = ... ;
else freehand = ... ;
:
break;
case WM_MOUSEMOVE: :
break;
case WM_LBUTTONUP: :
break;
case WM_RBUTTONDOWN: :
break;
case WM_RBUTTONUP: :
break;
} // end of updating application-specific representation
RedrawSP (hDB, message, wParam, lParam, freehand);
} |
This is the callback procedure to handle the user's inputs. It separates the handling into application-specific operations and DLG's operations for handling the UIF:
| switch (message) { ... } | Within this switch the applier programs what to do when the user presses the left mouse button, the right mouse button, etc. In this context only the application-specific operations are relevant. Anything relating to UIF-handling can be left to DLG. |
| freehand | Boolean indicator telling RedrawSP how to display the user's operation on screen (no-drawing or freehand-drawing). |
| RedrawSP | DLG's auxiliary procedure for UIF-handling. With only one line of code you can implement a functionality worth several thousand lines. |
In detail, the user interaction is handled by the individual messages generated when clicking the left mouse button, the right mouse button, etc.:
| WM_LBUTTONDOWN | Message issued by Windows system when a point is clicked
by the left mouse button. Along comes information about the keys that were pressed at this time
(if any), and the coordinates of the point clicked. (By these coordinates you can determine how the application should proceed.) |
| WM_MOUSEMOVE | Message issued by Windows system when the user moves the mouse.
Along comes information about the keys that were pressed at this time
(if any), and the current coordinates of the mouse cursor. (These coordinates might give you further information as to what your application should do now.) |
| WM_LBUTTONUP | Message issued by Windows system when the left mouse button is released.
Along comes information about the keys pressed at the same time (if any), and the coordinates
of the point where the button was released. (Usually you will use these coordinates to determine the end-coordinates of the current user operation.) |
| WM_RBUTTONDOWN | Message issued by Windows system when a point is clicked
by the right mouse button. Along comes information about the keys that were pressed at this time
(if any), and the coordinates of the point clicked. (Usually these coordinates are interpreted as the starting point of a selection rectangle.) |
| WM_RBUTTONUP | Message issued by Windows system when the right mouse button is released.
Along comes information about the keys pressed at the same time (if any), and the coordinates
of the point where the button was released. (Usually these coordinates are interpreted as the end point of a selection rectangle.) |