|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Daniel Tiedy
|
Oct 27, 2003 - 12:20 PM
|
Is there a way to associate an icon with the panes in the statusbar. I would like a visual representation of what the panes are. Also how would I go about adding a progress control to a statusbar so I can activate it when a progress needs to be presented. I would imagine that when the progres control is active it would also have its own paints for the description of what is happening
|
|
Technical Support
|
Oct 28, 2003 - 9:59 AM
|
The CExtStatusControlBar class is derived from the standard CStatusBar . It just sets an appropriate background color for the status bar and redraws its border and gripper. So, the rule for inserting an icon into the status bar is the same:
1) Load a 16x16 icon
HICON hSmallIcon = (HICON)
::LoadImage(
::AfxGetInstanceHandle(),
MAKEINTRESOURCE( IDR_MAINFRAME ),
IMAGE_ICON,
16,
16,
LR_DEFAULTCOLOR
);
ASSERT( hSmallIcon != NULL );
2) Set the icon in pane 0
CStatusBarCtrl & _sbc =
m_wndStatusBar.GetStatusBarCtrl();
_sbc.SetIcon( 0, hSmallIcon );
The code below creates the progress control "inside" pane 1 (of course, you should have CProgressCtrl m_wndProgress as a property of your frame window first):
CRect rcItem;
_sbc.GetRect( 1, &rcItem );
rcItem.DeflateRect( 1, 1 );
VERIFY( m_wndProgress.Create(
WS_CHILD|WS_VISIBLE/*|PBS_SMOOTH*/,
rcItem, &m_wndStatusBar, 0 ) );
m_wndProgress.ModifyStyleEx(
WS_EX_STATICEDGE|WS_EX_CLIENTEDGE,
0,
SWP_FRAMECHANGED
);
m_wndProgress.SetRange( 0, 100 );
m_wndProgress.SetPos( 0 );
Besides you need to reposition the progress control when frame window size is changed:
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
if( m_wndStatusBar.GetSafeHwnd() != NULL
&& m_wndStatusBar.IsWindowVisible()
)
{
CStatusBarCtrl & _sbc =
m_wndStatusBar.GetStatusBarCtrl();
CRect rcItem;
_sbc.GetRect( 1, &rcItem );
rcItem.DeflateRect( 1, 1 );
m_wndProgress.MoveWindow( &rcItem );
} // if( m_wndStatusBar.GetSafeHwnd() != NULL )
}
|
|