![]() |
Desktop Development »
Toolbars & Docking windows »
Libraries
Advanced
Professional User Interface SuiteBy Sergiy Lavrynenko of Foss Software, Inc.MFC extension library enabling software to be provided with a professional UI |
VC6, VC7, VC7.1Win2K, MFC, VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Prof-UIS is an easy-to-use MFC extension library that enables you to deliver
Windows applications with a professional and user-friendly interface. Prof-UIS
is specially designed to help Visual C++ developers implement advanced UI
facilities in the most effective and easy way: In most cases, to replace the
proper MFC class name with that of Prof-UIS in your code is enough to take full
advantage of Prof-UIS functionality, i.e. CComboBox ->
CExtComboBox. That, combined with an impressive list of key
features, makes Prof-UIS an invaluable tool for GUI development.
Prof-UIS is designed to help Visual C++ programmers save hundreds of hours in implementing today's most demanded GUI facilities in their applications. This makes Prof-UIS an invaluable tool for GUI development.
The CExtPopupMenuWnd class implements a popup menu. To use it is
no more difficult than the standard CMenu class.
1. Create the CExtPopupMenuWnd object dynamically:
CExtPopupMenuWnd *pPopupWnd = new CExtPopupMenuWnd;
2. Initialize menu items by either loading the menu resource
VERIFY(
pPopupWnd->LoadMenu(
hWnd,
IDR_TEST_POPUP_MENU
)
);
or performing a set of calls to
CExtPopupMenuWnd::ItemInsert()
3. Let us now look at how a new popup submenu can be inserted.
First, create and initialize it by going through Step 1 and Step 2. Then,
call ItemInsertSpecPopup() for inserting a new popup at the
specified position in the existing CExtPopupMenuWnd object. The code below
inserts a color picker menu to the existing menu:
pPopupWnd->ItemInsertSpecPopup(
new CExtPopupColorMenuWnd,
-1,
_T( "test color menu" )
);
4. Track the created and initialized popup menu:
VERIFY( pPopupWnd->TrackPopupMenu( 0, x, y ) );
Please note that the popup menu's tracking position is set in screen coordinates.
The CExtPopupMenuWnd objects are auto-destroyed, so do not call
the delete operator for these objects.
Popup menu class CExtPopupMenuWnd has the following
properties:
| Property | Default Value | Meaning |
static bool g_bMenuWithShadows; |
true |
Allow displaying shadows |
static bool g_bMenuExpanding; |
true |
Allow hiding rarely used menu items in initial state |
static bool g_bMenuHighlightRarely; |
true |
Display rarely used menu items in a different style |
static bool g_bMenuShowCoolTips; |
true |
Allow displaying cool tooltips |
static bool g_bMenuExpandAnimation; |
true |
Turn on animation when expanding rarely used menu items |
static bool g_bUseDesktopWorkArea; |
true |
If true, align to desktop work area, otherwise - to screen area |
static e_animation_type_t g_DefAnimationType; |
__AT_FADE |
Default animation during menu activation. Acceptable values are:
|
The frequently used or basic commands are those that do not depend on usage
statistics or a number of clicks. All application commands are registered in the
command manager (CExtCmdManager), whose members and methods can be
accessed via the global smart pointer variable g_CmdManager with
operator ->. The SetBasicCommands() method allows
you to replenish the basic commands list. The system commands (from the window's
system menu), OLE commands and the commands relating to MRU files and to MDI
windows are automatically considered to be basic.
|
|
In the DRAWCLI sample expandable menus are used. When you open any drop down menu from the menu bar, the items corresponding to basic commands are only visible at first. Other items appear only when you click on the Expand button at the bottom of the menu or when you press CTLT+DOWN_ARROW.
There are two ways to do this:
CExtPopupColorMenuWnd::g_bMenuExpanding = false;
CExtPopupColorMenuWnd::g_bMenuHighlightRarely = false;
g_CmdManager->SetBasicCommands(...) to make all your
commands basic i.e. initially visible in your menus. This part of the article describes how Prof-UIS implements the mechanism responsible for docking its control bars. It also explains the most important operations on the dockable control bar including how its position is set in a frame window.
There are several terms that may have different meanings to different people. Brief descriptions of some important terms are given below.
An overlapped/popup window with one child window in the center area and a set of child windows (control bars) that can be fixed to its borders.
A popup frame window that contains a set of control bars in its either docked or floating state.
A special kind of the frame window that encloses only one child docking bar
window with the AFX_IDW_DOCKBAR_FLOAT dialog control identifier.
The docking bar window encloses one or more control bars. Floating containers
are created and destroyed automatically with the control bar�s drag-and-drop
algorithm.
The generalized MFC implementation of the window that can be either fixed to any of the borders of its parent frame window or floated in the floating container.
A fixed-size control bar (e.g. toolbars or menu bars). The size of the fixed bar in its docked state could not be changed by dragging its borders.
A control bar that can be resized by dragging its borders and docked in the dynamic control bar containers.
A kind of an MFC control bar which is used as a parent window for all the
control bars with the re-docking feature turned on
(CControlBar::EnableDocking() is used for this). Basically MFC
provides two types of docking bars, which are implemented as the internal class
(CDockBar): floating bar (with the dialog control identifier set to
AFX_IDW_DOCKBAR_FLOAT) and docking bar fixed to the sides of the
docking site (with the dialog control identifiers set to
AFX_IDW_DOCKBAR_LEFT, AFX_IDW_DOCKBAR_RIGHT,
AFX_IDW_DOCKBAR_TOP, or AFX_IDW_DOCKBAR_BOTTOM). MFC
supports only four docking bars for one docking site at the time (these bars are
marked with red in the below). In Prof-UIS these bars are called "circle 0" or
"outer docking bar circle". Both fixed and resizable bars can be docked into
"circle 0", but the drag-and-drop algorithm for resizable bars docks them only
into the Prof-UIS-specific inner docking bar "circles" with numbers starting
from 1. In the figure below, "circle 1" is marked with blue, "circle 2" - with
green. Inner circles are created and destroyed dynamically with the
drag-and-drop algorithm for the resizable bar. These inner circles "allow"
resizable bars to be docked to each other in a nested way. The fixed-size
control bars could be docked only into "circle 0" marked with red.
The area that is free of any bars. It is marked with yellow in the figure and used by MDI client windows in MDI applications and the view window in SDI applications.
A special kind of the resizable control bar, which is created dynamically and used for docking other resizable bars to horizontal rows inside vertical rows and vice versa. The dynamic control bar container like any resizable control bar can take up part of the docking site or part of the floating container.
The MFC implementation of the status line. The status bar cannot be re-docked by dragging any its area. It takes up part of the docking site under the lowest docking bar (i.e. under the red "circle 0").
* Prof-UIS - specific term
To set a certain fixed docking bar location, just call your
CMainFrame::DockControlBar() method with the appropriate parameter
values. The following example arranges two toolbars into one horizontal image at
the bottom of a frame window:
DockControlBar(
&m_wndToolBar1,
AFX_IDW_DOCKBAR_BOTTOM
);
CRect wrAlreadyDockedToolBar;
m_wndToolBar1.GetWindowRect( &wrAlreadyDockedToolBar );
wrAlreadyDockedToolBar.OffsetRect( 0, 1 );
DockControlBar(
&m_wndToolBar2,
AFX_IDW_DOCKBAR_BOTTOM,
&wrAlreadyDockedToolBar
);
Use the CExtControlBar::DockControlBar() methods (two overloaded
functions) to set the relative positions of the control bars. In the sample
below, the first method docks the m_wndResourceViewBar resizable
bar to the newly created row in the left part of "docking circle 1". The second
one is applied to the already docked m_wndResourceViewBar bar, with
its parameters specifying the position of the
m_wndServerExplorerBar bar relatively to the
m_wndResourceViewBar one.
m_wndResourceViewBar.DockControlBar(
AFX_IDW_DOCKBAR_LEFT,
1,
this,
false
);
m_wndResourceViewBar.DockControlBar(
&m_wndServerExplorerBar,
true,
true,
this,
false
);
To make both fixed-size bars and resizable bars visible/invisible, the
CFrameWnd::ShowControlBar() method should be used. The
CControlBar::ShowWindow() cannot be used here, because it does not
affect the positions of other bars in the same frame window (i.e. the method
does not perform the frame layout recalculation).
For this purpose, use either CExtControlBar::FloatControlBar(),
or CFrameWnd::FloatControlBar(). Both methods produce the same
results.
The CExtControlBar::FloatControlBar() method should be used. The
CFrameWnd::FloatControlBar() method is not allowed.
Usually all the control bars (but the status bar) in any docking site are
enabled to be re-dockable. This feature is turned on by performing the following
two steps. First, call the static
CExtControlBar::FrameEnableDocking( pDockSite )CExtControlBar::EnableDocking() method of the bar.
If a bar is not re-dockable, its parent window is the docking site. In case of a dockable bar, the parent window is always a docking bar window (even for a floating palette).
IMPORTANT: CExtControlBar::FrameEnableDocking( pDockSite
)CFrameWnd::EnableDocking().
The call of the static CExtControlBar::DoFrameBarCheckCmd(
pDockSite, nReisizableBarDlgCtrlID, false )
Use the three methods below to initialize the desired size of a bar that is either in the docked state (vertical/horizontal) or in the floating state:
SetInitDesiredSizeVertical( CSize )
SetInitDesiredSizeHorizontal( CSize )
SetInitDesiredSizeFloating( CSize ) The real sizes of docked bars are adjusted proportionally between all the resizable bars in one row.
Please note that the bar can be in the floating state only when it itself is the single bar in its floating container. In any other case, the bar is in the docked state.
Call the CExtControlBar::GetParentFrame() method to get the
pointer to the parent CFrameWnd-based window. If this returned
object is kind of CMiniFrameWnd, the bar is docked inside a
floating container. Otherwise the bar is docked in the docking site.
Retrieve the bar window style flags by calling the GetStyle()
method. The bar window is visible if its window style flags have the
WS_VISIBLE flag. The CControlBar::IsVisible() method
can additionally detect whether the bar is temporarily invisible.
These commands make each control bar visible/invisible. They are usually marked with check marks, which indicates visibility of the bars. Every docking bar has its own unique dialog control identifier and the corresponding menu command in the docking site. In this case, the context menu with the list of all the docking bars can be activated on every frame point. So, to set the correct check mark for the "Show/Hide" command of the bar, you should add the following two lines to the frame�s message map:
ON_COMMAND_EX( ID_BAR_... , OnBarCheck )
ON_UPDATE_COMMAND_UI( ID_BAR_... , OnUpdateControlBarMenu )
First, see the previous answer. The difference is in the command
handling/updating for the resizable bars. These commands have no check marks and
are only used to activate resizable control bars. They never hide bars.
Implement the new OnBarCheck() and
OnUpdateControlBarMenu() methods in the docking site:
BOOL CMainFrame::OnBarCheck( UINT nID )
{
return CExtControlBar::DoFrameBarCheckCmd(
this,
nID,
false
);
}
void CMainFrame::OnUpdateControlBarMenu( CCmdUI * pCmdUI )
{
CExtControlBar::DoFrameBarCheckUpdate(
this,
pCmdUI,
false
);
}
The state persistence is usually implemented in your
CMainFrame's OnCreate() and
DestroyWindow() methods.
To load bars' state:
CExtControlBar::ProfileBarStateLoad(
this, // some kind of CFrameWnd
pApp->m_pszRegistryKey,
// application registry key (usually company name)
pApp->m_pszProfileName,
// application profile name (usually product name)
pApp->m_pszProfileName // Prof-UIS profile name
);
To save bars' state:
CExtControlBar::ProfileBarStateSave(
this, // some kind of CFrameWnd
pApp->m_pszRegistryKey,
// application registry key (usually company name)
pApp->m_pszProfileName,
// application profile name (usually product name)
pApp->m_pszProfileName // Prof-UIS profile name
);
You should add the CExtControlBar member in the frame window
class declaration. Creating a resizable control bar is similar to that of
toolbar.
When creating such a child window, pass a pointer to
CExtControlBar instance in the "parent window" parameter to the
child window Create() method. After that, the control bar will
automatically adjust the child window to its client area. So far, the resizable
control bar allows only one child window
The docking menu bar is implemented just as an ordinary toolbar. Any needed
initialization should be performed in your CMainFrame's
OnCreate() handler. Moreover, you need to add a frame window class
member of CExtMenuControlBar class.
...
if( !m_wndMenuBar.Create(
_T( "Menubar name" ),
this,
ID_VIEW_MENUBAR) ||
!m_wndMenuBar.LoadMenuBar( IDR_MAINFRAME ))
{
TRACE0( _T( "Failed to create menubar\n" ) );
return -1;
}
...
m_wndMenuBar.EnableDocking( CBRS_ALIGN_ANY );
...
CExtControlBar::FrameEnableDocking( this );
...
DockControlBar( &m_wndMenuBar );
...
By default, CExtMenuControlBar does not activate menu on
pressing the ALT key. To enable this, you should override the
PreTranslateMessage() virtual function in a frame window class and
add the following lines before the parent
PreTranslateMessage():
if( m_wndMenuBar.TranslateMainFrameMessage( pMsg ) )
return TRUE;
In case of MDI, repeat the same in the child frame window class.
Painting of all the Prof-UIS windows is performed with the global paint
manager (the g_PaintManager variable). It is a smart container for
the CExtPaintManager-like object. You can install your own paint
manager classes derived from CExtPaintManager or
CExtPaintManagerXP/CExtPaintManagerOffice2003 to
re-paint anything you wish. So, create your own class derived from
CExtPaintManager. Then override the PaintGripper()
method. Please consult the code of CExtPaintManager::PaintGripper()
for details. If m_bSideBar is true, we are painting the gripper of the resizable
bar, which is a caption. If m_bFloating is true, we are painting the caption of
any floating mini-frame window.
You should use your own class derived from CExtControlBar (or
CExtToolControlBar, or CExtMenuControlBar) and
override the OnNcAreaButtonsReinitialize() virtual method. This is
the source code of CExtControlBar::OnNcAreaButtonsReinitialize():
void CExtControlBar::OnNcAreaButtonsReinitialize()
{
INT nCountOfNcButtons = NcButtons_GetCount();
if( nCountOfNcButtons > 0 )
return;
NcButtons_Add( new CExtBarNcAreaButtonClose(this) );
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
NcButtons_Add( new CExtBarNcAreaButtonAutoHide(this) );
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
NcButtons_Add( new CExtBarNcAreaButtonMenu(this) );
}If you remove this line NcButtons_Add( new
CExtBarNcAreaButtonClose(this) ); the "X" button will disappear.
When the control bar window is in the floating state, it is inside a miniframe
window which is created and destroyed automatically by Prof-UIS. The "X" on this
frame just hides the window. All the non-client area buttons are instances of
the classes which are derived from CExtBarNcAreaButton. You can
write your own buttons and initialize them in
OnNcAreaButtonsReinitialize().
All the Prof-UIS LIB and DLL files can be found in
...\Prof-UIS\Bin6 or ...\Prof-UIS\Bin7 folder (for
VC++ 6 or 7). You should add the ...\Prof-UIS\Include folder into
the "Include folders list" in your VC++ environment settings. Also, you should
add the ...\Prof-UIS\Bin6 or ...\Prof-UIS\Bin7 folder
into the "Library folders list". In your projects precompiled header file
(usually named StdAfx.h) you should add this line:
#include <Prof-UIS.h>
Now your program will be linked together with appropriate Prof-UIS library
(depending on your project settings). To allow your program run, you may need
copy required Prof-UIS DLL (if any required) into the same folder with your
program EXE file.
CExtComboBox, CExtButton, etc.)?Just replace the standard MFC classes in your code with the corresponding ones of Prof-UIS. Do not forget to include the appropriate header files.
Command Manager solves this problem with the
g_CmdManager->SerializeState() method.
First, include ExtToolControlBar.h in the header file a frame
window. Second, replace CToolBar class name with
CExtToolBar. Finally, modify the frame window handler code in
OnCreate():
if( !m_wndToolBar.Create(
_T( "Toolbar name" ),
this,
AFX_IDW_TOOLBAR)
|| !m_wndToolBar.LoadToolBar( IDR_MAINFRAME ))
{
TRACE0( "Failed to create toolbar" );
return -1;
}
You should get the command specifier from the command manager and, then, set
the text attributes m_sToolbarText and m_sMenuText. If
you have to set/change the text after the frame window has been created, call
the RecalcLayout() method of the frame.
CExtCmdManager::cmd_t * p_cmd;
p_cmd = g_CmdManager->CmdGetPtr( ID_... );
ASSERT( p_cmd != NULL );
p_cmd->m_sMenuText = _T( "Menu text" );
p_cmd->m_sToolbarText = _T( "Toolbar text" );
![]()
Create a control with Dialog Control ID value equal to the ID of an existing
button on the toolbar. Then, set then control to the button by calling
CExtToolControlBar::SetButtonCtrl() method.
If there is no command with such ID in the application menu, then it is recommended to set a menu text for this command. That allows the button/control to be displayed correctly in case there is no space in the toolbar for it.
if( !m_wndComboFindText.Create(
WS_CHILD|WS_VISIBLE|CBS_HASSTRINGS|CBS_DROPDOWN,
CRect(0,0,180,200),
&m_wndToolBarStandard,
ID_HELP_SEARCH_COMBO))
{
TRACE0( _T( "Failed to create ID_HELP_SEARCH_COMBO\n" ) );
return -1; // fail to create
}
m_wndToolBarStandard.SetButtonCtrl(
m_wndToolBarStandard.CommandToIndex(ID_EDIT_FIND),
&m_wndComboFindText
);
m_wndComboFindText.SetFont(
CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)) );
m_wndComboFindText.SetItemHeight(
-1, m_wndComboFindText.GetItemHeight(-1) - 1 );
g_CmdManager->CmdGetPtr( m_wndComboFindText.GetDlgCtrlID() )->
m_sMenuText = _T( "Search help system" );
CZoomBarSliderButton *pZoomSliderTBB = new CZoomBarSliderButton(
&m_wndToolBarZoom,
ID_MYEXTBTN_SLIDER,
0,
11, 4, 0, // scroll total/pos/page
0, 0,
// button extent horz(left/right)/vert(up/down) in pixels
// (if zeros - use slider-like layout instead of scrollbar-like)
100, 100 // total slider control extent horz/vert in pixels
);
VERIFY(m_wndToolBarZoom.InsertSpecButton(-1,pZoomSliderTBB,FALSE));
CSeekBarSliderButton *pSeekScrollerTBB = new CSeekBarSliderButton(
&m_wndToolBarSeek,
ID_MYEXTBTN_SCROLLER,
0,
0, 0, 0, // scroll total/pos/page
10, 10, // button extent horz(left/right)/vert(up/down) in pixels
// (if zeros - use slider-like layout instead of scrollbar-like)
300, 300 // total slider control extent horz/vert in pixels
);
VERIFY(m_wndToolBarSeek.InsertSpecButton(-1,pSeekScrollerTBB,FALSE));
|
|
Prof-UIS supports multi profile UI state persistence. Each profile has unique name and a set of window handles.
g_CmdManager->ProfileSetup( _T( "ProfileSectionName" ), hWnd );
The CExtToolControlBar class stores the HMENU
attribute for every button. You can set it by activating
CExtToolControlBar::SetButtonMenu().
CExtCmdManager::cmd_t * p_cmd;
CMenu _menu;
p_cmd = g_CmdManager->CmdGetPtr( ID_CMD_... );
ASSERT( p_cmd != NULL );
VERIFY( _menu.LoadMenu( ID_MENU_... ) );
VERIFY(
m_wndToolBarMain.SetButtonMenu(
m_wndToolBarMain.CommandToIndex( ID_CMD_... ),
_menu.Detach(),
TRUE
)
);
Prof-UIS provides an advanced color selection dialog with a set of color
navigation modes. Just declare the CExtColorDlg object and call
DoModal(). Use m_strCaption member to set a custom
dialog caption. To set initial colors, use m_clrInit and
m_clrNew members. Some modes are demonstrated below:
User interface Manager is an instance of CExtPaintManager or the
one derived from it and is stored in a global smart pointer variable
g_PaintManager. CExtPaintManager methods are used for
drawing all supported interface components as provided by the Office 98/2K/2003
appearance. Prof-UIS also includes CExtPaintManagerXP and
CExtPaintManagerOffice2003 classes used for drawing in the Office
XP and Office 2003 styles. The following lines describe how to set the Office
98/2K/2003 interface style.
VERIFY(
g_PaintManager.InstallPaintManager( new CExtPaintManager )
);
VERIFY(
g_PaintManager.InstallPaintManager( new CExtPaintManagerXP )
);
VERIFY(
g_PaintManager.InstallPaintManager(
new CExtPaintManagerOffice2003 )
);
This sample application based on the Microsoft's sample with OLE Server-Container technology support illustrates the use of OLE-verb menus, OLE Client-Server compatible control bars, color picker menus both in menu bar and in toolbar, toolbar buttons with dynamically generated icons, owner-draw menu, and more.
Demonstrates how to output rendered images (OpenGL animation) both to the main view and to the dockable views resided in resizable control bars. This multithreaded application allows you to select an active camera in each view, set up its parameters and perform 6 DOF simulation of camera maneuvers. GLViews also illustrates playing an AVI file on a 3D surface, OpenGL stencil buffer-based reflection, and frame image rendering during animation.
Shows how to work with the slider button built into the Prof-UIS toolbar. The slider features optional scroll arrow buttons like those in the standard scroll bar. The Zoom and Seek slider buttons represented in the sample demonstrate how to control the playing of AVI files.
Demonstrates the features of the Prof-UIS status bar. This control, which is an enhanced version of the standard MFC status bar, enables you to easily add or remove panes on-the-fly. Its panes may contain almost any control you need: buttons, edits, animations, progress bars, and etc.
Shows how to use icons of different sizes and different color depths in toolbars. It also demonstrates how, for the toolbar buttons, to change the font, font size and font style of the caption as well as the button image on-the-fly.
Illustrates the primary controls including toolbar and menu bar in dialog window, user-defined toolbar buttons and labels, pop-up menu with owner-draw items and left area, pop-up menu in system tray, menu animation effects, powerful color picker menu and dialog, and more.
A simple resizable property sheet based application. Illustrates the usage of the resizable property sheet window as an application's main window.
Demonstrates how to use CExtResizablePropertySheet as a child window of the resizable control bar and MDI child frame.
A simple single document interface application without DOC/VIEW architecture support demonstrates how to save the current state of control bars in a file.
A simple multiply document interface application without DOC/VIEW architecture support demonstrates how to use control bars both in the MDI frame window and in the MDI child window.
Illustrates full state persistence of control bars when switching between windowed and full screen modes.
Demonstrates how to implement different kinds of bars with fixed size including dialog bars, palette bars, custom-drawn panels.
Shows multithreaded output to rich edit controls placed in resizable control bars and MDI child frames.
Released on January 15, 2004.
Released on September 25, 2003.
Released on July 8, 2003.
Released on September 15, 2002.
Released on July 8, 2002.
CExtColorCtrl
CExtComboBox in
toolbars
CExtComboBox editor popup menu Released on April 13, 2002. First public release.
The Prof-UIS library presented in this article is freeware software.
Thanks to all those whose names appear in the library source code, and to anybody who have been forgotten to mention. Many thanks to people who submitted bug information.
Your questions, suggestions and bug reports may be posted either to the forum below or to the forum at the Prof-UIS website.
Any additional information on Prof-UIS as well as its latest versions can be obtained at http://www.prof-uis.com/.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 13 Jan 2004 Editor: Nishant Sivakumar |
Copyright 2002 by Sergiy Lavrynenko of Foss Software, Inc. Everything else Copyright © CodeProject, 1999-2009 Web13 | Advertise on the Code Project |