When I saw Nish's article
with a status bar in dialog window I finally decided to publish my
classes with support for status bar, toolbar and tool tips. I had similar problem a while ago, when I needed to develop
simple application, but with not too ugly interface.
It is not complicated task to have a status bar or toolbar at the dialog window. It becomes little bit more tricky,
when you want to do it right way - show tool tips and corresponding status bar messages to these tool tips -
and that's the reason, why there is usually status bar, isn't it?. Fortunately I found some information in MSND
and got it working.
There is sample DLGCBR32
with description how to add control bars to
CDialog. My classes are based on this sample and are extended
to keep usage of its functionality as simple as possible.
Description of solution
CPropertySheet do not contain similar function to
where all the processing of messages related to control bars is done. It is necessary duplicated this functionality
for windows not derived from
CFrameWnd. However, this task is more difficult, if you want support modal
and modeless dialog windows, where not all messages are sent as you might expect.
As you can see from following message map:
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
there is the handler for
WM_ENTERIDLE message, where
to update status bar. The same scenario is working for
CDialog only when it is modal and it is not main application window.
Workaround for different situations is handling
Rest of message map is for handling messages for tool tips and updating user interface (menu and status bar).
CDialogEx is as simple as deriving your dialog class from
You can use class wizard to derive your dialog from
CDialog and then just replace all references
CDialogEx. You have to implement
and call function
InitDialogEx() from within it.
BOOL InitDialogEx(BOOL btool tips = FALSE, BOOL bStatusBar = FALSE,
UINT *pIndicators = NULL,
UINT nIndicators = 0, UINT uiToolBar = 0,
DWORD dwToolBarStyle = TBSTYLE_FLAT | WS_CHILD |
WS_VISIBLE | CBRS_TOP |
CBRS_GRIPPER | CBRS_TOOLTIPS |
CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
btool tips to
TRUE if you want to use tool tips. Set
if you want to show status bar. If you will not specify
will show default status bar with indicators for Num Lock, Caps Lock and Scroll Lock.
Otherwise you can provide definition for you own status bar in these parameters. Parameter
uiToolBar is resource ID of
your toolbar with styles specified in
Last thing to do is to add string
AFX_IDS_IDLEMESSAGE to your resources. Its ID has to be 57345. This string is shown in the status bar when application
is in idle state, usually you can use string like 'Ready'.
The same setup applies for using
CPropertySheetEx2. Only function to call from
InitDialogEx() has name
and one parameter more for resource ID of menu to show. And, off course, you have to derive your pages from
Demo program CDialogExDemo and CPropertySheetEx2Demo demonstrate using
CDialogEx in the different scenarios, as a modal
or modeless main application window, or as a child window.
- 24 Sep 2002 - couple of bugs removed, new demo program for CPropertySheetEx2 - credits to Cyril Boutamine and Jonathan de Halleux