?
Solved

how to resize statusbar automatically in MFC

Posted on 2003-10-30
7
Medium Priority
?
2,594 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:jyotiweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9652099
In the onsize you need to set the pane size of each of the three panes individually

eg.
UINT nStyle = m_statusBar.GetPaneStyle(0);
m_statusBar.SetPaneInfo(0, ID_PANE1, nStyle, cx);  where cx is the new width you require

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.

0
 
LVL 7

Expert Comment

by:vijay_visana
ID: 9662453
try
WM_SIZEPARENT
message
0
 

Author Comment

by:jyotiweb
ID: 9665961
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|CBRS_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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Expert Comment

by:vijay_visana
ID: 9668801
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




0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 750 total points
ID: 9669751
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.


Call your Initstatusbar from the OnCreate NOT the constructor.
Use the SetParts member fn if you are using a CStatusBarCtrl to set the widths of the panes when resizing.

eg.
const int nParts = 4;
CRect rect;

m_wndStatusBarCtrl.GetClientRect(&rect);
int widths[nParts] = { rect.right-300, rect.right-200, rect.right-100, -1 };

VERIFY( m_wndStatusBarCtrl.SetParts(nParts, widths) );

0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 11849681
My comment would be a way to achieve the desired effect
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question