jyotiweb
asked on
how to resize statusbar automatically in MFC
I have written one program in VC++ using MFC. In this program I have created statusbar using Create() function and I have divided that statusbar in three equal parts. I have put this Create() function in another used defined function named Initstatusbar() and called it from the constructor of my window class. Then, during run time when I resize my window, status bar doesn’t resize automatically. Then, I have tried to resize it manually by making a call to Initstatusbar() from the OnSize() message handler. But still it doesn’t resize.
Can you pl.help me.
Can you pl.help me.
try
WM_SIZEPARENT
message
WM_SIZEPARENT
message
ASKER
I have tried your solution. But statusbar is not displayed when I run my program even though value returned by Create() function is nonzero.
UINT a[3];
UINT *aa;
CstatusBar sb;
void CMainWin::Initstatusbar()
{
a[0]=ID_ONE;
a[1]=ID_TWO;
a[2]=ID_THREE;
aa=a;
sb.Create(this,WS_CHILD|WS _VISIBLE|C BRS_BOTTOM ,ID D_STATUS);
sb.SetIndicators(aa,3);
}
For above coding I have also created String Table control.
Also tell me how to do same thing using CstatusBarCtrl class because it doesn’t consist of SetPaneInfo() function.
UINT a[3];
UINT *aa;
CstatusBar sb;
void CMainWin::Initstatusbar()
{
a[0]=ID_ONE;
a[1]=ID_TWO;
a[2]=ID_THREE;
aa=a;
sb.Create(this,WS_CHILD|WS
sb.SetIndicators(aa,3);
}
For above coding I have also created String Table control.
Also tell me how to do same thing using CstatusBarCtrl class because it doesn’t consist of SetPaneInfo() function.
BOOL CStatusBarCtrl::SetText( LPCTSTR lpszText, int nPane, int nType );
use this function
here
nType
Type of drawing operation. It can be one of these values:
0 The text is drawn with a border to appear lower than the plane of the status bar.
SBT_NOBORDERS The text is drawn without borders.
SBT_OWNERDRAW The text is drawn by the parent window.
SBT_POPOUT The text is drawn with a border to appear higher than the plane of the status bar.
where
BOOL CStatusBarCtrl::SetParts( int nParts, int* pWidths );
will let you set width of each part
Threre are other interesting function too
like
GetTipText: Retrieves the tooltip text for a pane in a status bar.
SetTipText: Sets the tooltip text for a pane in a status bar.
SetBkColor: Sets the background color in a status bar.
SetIcon: Sets the icon for a pane in a status bar.
good luck
vijay
use this function
here
nType
Type of drawing operation. It can be one of these values:
0 The text is drawn with a border to appear lower than the plane of the status bar.
SBT_NOBORDERS The text is drawn without borders.
SBT_OWNERDRAW The text is drawn by the parent window.
SBT_POPOUT The text is drawn with a border to appear higher than the plane of the status bar.
where
BOOL CStatusBarCtrl::SetParts( int nParts, int* pWidths );
will let you set width of each part
Threre are other interesting function too
like
GetTipText: Retrieves the tooltip text for a pane in a status bar.
SetTipText: Sets the tooltip text for a pane in a status bar.
SetBkColor: Sets the background color in a status bar.
SetIcon: Sets the icon for a pane in a status bar.
good luck
vijay
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My comment would be a way to achieve the desired effect
eg.
UINT nStyle = m_statusBar.GetPaneStyle(0
m_statusBar.SetPaneInfo(0,
From the help files.
CStatusBar::SetPaneInfo
void SetPaneInfo( int nIndex, UINT nID, UINT nStyle, int cxWidth );
Parameters
nIndex
Index of the indicator pane whose style is to be set.
nID
New ID for the indicator pane.
nStyle
New style for the indicator pane.
cxWidth
New width for the indicator pane.