![]() |
"Not the cursor should have to be moved to the tool. The tool should pop up
where the cursor is!" That's the main idea behind DLG's Floating UIF :
Compared to conventional menu technique, a Floating UIF provides a big step
forward in terms of user friendliness.
The following sections will show you some examples of
| Items-only Menu | |
| Menu Manipulations | |
| Toolbar: Menu of Controls [+ Items] | |
| Detaching a Sub-menu | |
| Horizontal Menu with Graphic Items |
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.
| Items-only Menu |
![]() |
Just like a conventional menu, in DLG's Floating UIF
a menu can have items only. Each one of the items can have different dimensions, font,
letter size, foreground and background color / brush / pattern. So, the layout of a menu can
be varied just as needed. (In a conventional menu you can have only black letters in the
system font, uniformly on gray background.)
This is vital for an application's use not only in an office environment. With computer
hardware becoming more and more an everyday utensil, software development just has to keep
up with the development of palm computers, touch-sensitive screens, etc. With DLG you can
do that.
In DLG, a menu with different items is created by something like the following code lines:
HBITMAP hbmpWater = LoadBitmap (hInstance, "IDB_WATER"); |
HWND hTb11 = CreateDlgMenu (hDlg, "Sub-Submenu\bId=1200", "|Item11\bColor=%x", RGB_BLUE, "Height=60 Center", "BkBrush=%x", CreateHatchBrush (HS_DIAGCROSS, RGB_RED), "|Item12\bColor=%x", RGB_GREEN, "BkColor=%x", RGB_YELLOW, "Font=Impact", "Size=36", "Height=60", "|Item13\bSize=24 Height=40 BkPattern=*IDB_STRIPES", "|Item14\bFont='Arial Italic' Size=18 Center BkBrush=%x", CreatePatternBrush (hbmpWater), 0) |
| hTb11 | window handle of this sub-menu (will be needed later to associate an item in the parent menu with this sub-menu) |
| CreateDlgMenu | DLG main procedure to create a DlgMenu in a Floating UIF |
| hDlg | handle of application window |
| "Sub-Submenu" | title of this sub-menu |
| "Id=1200" | start identifier (so, "Item11" = 1200, "Item12" = 1201, etc.) |
| "|Item11", "|Item12", "|Item13", "|Item14" | item texts (note the separator char | introducing each text!) |
| "Height=60" | height of this item will be 60 pixels (by default, an item's height is determined by the letter size in the current font) |
| "Center" | item text will be centered horizontally + vertically (default for all items in a horizontal menu) |
| Font='Arial Italic' | name of letters' font - (default: system font - a multi-word name like 'Arial Italic' must be enclosed in apostrophes) |
| "Size=18" | letter size (default: 10) |
| "Color=%x", RGB_BLUE | foreground (= text) color of this item will be blue (default: black) |
| "BkColor=%x", RGB_YELLOW | background color of this item will be yellow |
| BkPattern=*IDB_STRIPES" | name of bitmap resource determining the background pattern (the leading * defines the following text as being the name of a resource) |
| "BkBrush=%x", CreateXXXBrush (...) | background brush of this item will be XXX (XXX can be Solid, Hatch or Pattern) |
The code lines in the application's callback procedure handling the messages from this menu are looking as follows:
CmdProc (HWND hDlg, WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam))
{
:
case 1200: MsgBox ("message from Sub-Submenu", MB_OK,
"\titem11 clicked", 0);
break;
case 1201: MsgBox ("message from Sub-Submenu", MB_OK,
"\titem12 clicked", 0);
break;
case 1202: MsgBox ("message from Sub-Submenu", MB_OK,
"\titem13 clicked", 0);
break;
:
case 1203: MsgBox ("message from Sub-Submenu", MB_OK,
"\titem14 clicked", 0);
break;
:
}
}
|
| Menu Manipulations |
![]() |
Many of the manipulations needed in a conventional menu can easily be
avoided in DLG, i.e. they are unnecessary. Only three of them are left: tracking of a pop-up menu,
and enabling / disabling a menu item.
In DLG you can create such a menu by something like the following coding scheme:
HWND hTb1 = CreateDlgMenu (hDlg, "Submenu\bId=1000 Indent=60 Cursor=*...", : "|disable \"line\"\bBkColor=%x", RGB_LIGHT_BLUE, "|enable \"line\"\bBkColor=%x", RGB_LIGHT_BLUE, : 0) |
| "Indent=60" | sub-menu associated with the items of this sub-menu
will pop up indented by 60 pixels (for more efficient user handling: sub-menus/toolbars will pop up under the cursor) |
| "Cursor=*..." | for all items, cursor will be set to resource given by '...' (cursor can be set by a cursor handle, a cursor resource, or from a cursor file) |
| "|disable \"line\"", "|enable \"line\"" | item texts (C/C++ syntax: quotation marks within a string must be coded as \") |
In the application's callback procedure the menu manipulations are implemented as follows:
CmdProc (HWND hDlg, WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam))
{
:
case 1004: DlgMenu ("Disable Menu=%x", hTb1, "Id=1002", 0);
break;
case 1005: DlgMenu ("Enable Menu=%x", hTb1, "Id=1002", 0);
break;
:
}
}
|
| DlgMenu | DLG's auxiliary procedure for menu manipulations (see Sample33, e.g. Button Menu) |
| "Disable" | option to disable the menu item given by additional options |
| "Enable" | option to enable the menu item given by additional options |
| "Menu=%x", hTb1 | window handle of menu comprising the item to manipulate |
| "Id=1002" | identifier of item to manipulate |
| Toolbar: Menu of Controls [+ Items] |
![]() |
![]() |
![]() |
In DLG's Floating UIF there can be not only
items, but any other Control as well. They can be integrated in the menu; for an example, see the
basic menu (leftmost screenshot above). Or they can be part of a pop-up toolbar, turning up when the cursor is moved over
the item associated with it.
Any number and any type of Controls can be comprised in a Floating UIF .
However, for more clarity to the user there will usually be only one
Control per pop-up toolbar, which might be combined with an item for further detail selection.
(When selecting by keyboard, the arrow-right key must be pressed first, to have
the sub-menu associated with it popping up.)
Look at the sub-menu popping up when the cursor is moved over the item other combined with
the ListBox offering the style choices
(middle screenshot above). It is the same as the sub-menu associated with the type
item in the basic menu.
The rightmost screenshot shows the Slider popping up when the cursor is moved over the width
item in the basic menu.
For combining items + controls, the menu is created as follows. (Only main-menu shown here;
the other menus are created quite the same. Note that Controls are created just like normal items.)
HWND hPopup = CreateDlgMenu (hDlg, "DlgMenu","\bIndent=20 Delay=50" " Transit Cursor=*IDC_CURSOR1", : "|&width\t->\bBkColor=%x", RGB_YELLOW, "Sub=%x", hTb3, : Control (1006, "Spin", 0, 40, 24, 79, 8, "\bIO=%p", &layer, "Storeback", 0), "|OK\bId=1", "BkColor=%x", RGB_GREEN, : 0) |
| "Delay=50" | wait for 50 milliseconds till responding to a mouse move (so the user does not have to move the cursor too exactly) |
| "Transit" | remove this menu when cursor is moved into a sub-menu or toolbar (for even more user-friendliness) |
| "Cursor=*IDC_CURSOR1" | display cursor as IDC_CURSOR1
when cursor is on this menu (cursor is defined as IDC_CURSOR1 in application's .rc-file) |
| "Sub=%x", hTb3 | associate sub-menu/toolbar (window handle hTb3 ) with this item |
| Control (...) | combine a normal Control with the items of this menu (the Control is created in the usual way, see e.g. Sample22, "Simple Modeless Dialog") |
| "Storeback" | option to tell a Control to store-back user inputs right away |
In the application's callback procedure handling right-click messages the pop-up of this Floating UIF is handled as follows:
DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
:
case WM_RBUTTONDOWN:
DlgMenu ("Track Menu=%x", hPopup,
"Window=%x", hDlg, "lParam=%x", lParam, 0);
break;
:
}
}
|
This is very much the same code as in Sample33, Pop-up Menu.
| Detaching a Sub-menu |
![]() |
![]() |
A sub-menu can be detached
from the menu hierarchy by clicking it somewhere in the title bar and dragging it to some other
place on the screen (left screenshot above). The item in the parent menu it was associated with
is being disabled, to remind the user that this sub-menu is detached now.
When the detached menu is in place, the title line can be removed by double-clicking in it. Later,
when the menu is closed, it becomes a normal part of the menu hierarchy again, popping up with a fresh
title line. The title line can be restored by right-clicking somewhere in menu.
Once detached, the sub-menu becomes the root of a new, autonomous menu hierarchy: it stays
on screen permanently, even if the former parent menu is removed altogether. If it has a sub-menu
of its own, it will pop up when the item associated with it is
selected (such as the bottom item of the detached sub-menu, right screenshot above). Or it
can be detached in turn, forming another menu hierarchy.
Try it with the sample program:
Detach a sub-menu and remove the basic menu. In the detached sub-menu click any of the items,
drag it in the title bar, etc. Double-click somewhere in the title line, and any of the items.
Look at the statusbar: the moment you are clicking, the corresponding field will change.
(Unless it was changed already; then you should click another item first.)
A detached sub-menu can be closed by clicking the "x"-button in its title bar. (If the title is hidden currently,
right-click somewhere on the menu. The title will re-appear.) When closed, the formerly detached sub-menu is
part of the full menu hierarchy again. The associated item in the parent menu is being re-enabled.
The associated sub-menu pops up temporarily again when this item is selected. If desired,
eventually it can be detached once more.
By detaching sub-menus and toolbars, just as needed, the users are completely free to re-arrange
the user interface any way they like, any time they like, how often they like. Still, they can
get out any feature with a minimum of cursor movements.
If a menu is needed no longer, they can close it at any time and detach any other menu. Thus,
with DLG's Floating UIF an application can have a fully flexible user
interface.
In programming, a detachable menu can be created very simply, such as follows:
HWND hTb1 = CreateDlgMenu (..., "... \bDetach ...", : : 0) |
| "Detach" | option to make a menu detachable (the rest of coding is the same as above) |
| Horizontal Menu with Graphic Items |
![]() |
One thing that's needed in many consumer applications is, avoiding anything
appearing "purely technical". So, most UIF-elements should have not simple text labels
but rather graphic symbols. In particular, all menu items should be visually appealing.
With conventional menus that can be done only in some roundabout way. With DLG however,
a menu can be created fully graphically, by just a few code lines.
In DLG, a menu of graphic items is created simply as a group of buttons, like in the following
example. (Compare Sample 1.1, especially group
of bistable/multistable buttons.)
HWND hTb21 = CreateDlgMenu (..., "...\bHorizontal ...",
Control (..., "Button", ..., ..., ..., ..., ...,
"{...|...|...|...\bImages=...}", 0),
0);
|
| "Horizontal" | option to make the menu items being arranged horizontally (all items form a control group, see Sample 1.1, "group of bistable/multistable buttons") |
| "Button" | menu items are emulated by a group of buttons |
| "Images=..." | option to make a series of bitmaps being painted as the graphic faces of all items |
| { ... } | for more ease of keyboard handling, the items should be coded in curly brackets |
The bitmap series determining the graphic items looks like this:
