Bubbai
asked on
Dynamic StatusBar pane...
I have status bar and I need to display various information on a pane.
I need to set the pane's size according to the displayed string's length.
How can I know which size to give to the pane in the "SetPaneInfo" function, so it will fit exactly to the displayed string's length.
I need to set the pane's size according to the displayed string's length.
How can I know which size to give to the pane in the "SetPaneInfo" function, so it will fit exactly to the displayed string's length.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is One More Method.
//Get the DC
CClientDC dc(this);
//Have the string
CString str("xwiz");
//Get the length of string
int Len = str.GetLength();
int PaneWidth = 0;
//Calculate pane width from each char width
for(int Index = 0; Index < Len; Index++)
{
char ch = str[Index];
int Temp = 0;
dc.GetCharWidth(ch,ch,&Tem
PaneWidth += Temp;
}
CMainFrame *p_main = (CMainFrame *)AfxGetMainWnd();
//Set The Width
p_main->m_wndStatusBar.Set
//Make it Upper To Fit the Pane
str.MakeUpper();
//Set The Text
p_main->m_wndStatusBar.Set
To achive from both the methods from any class other than CMainFrame, u may have to include mainfrm.h(if not included) and go to mainframe.h and declare m_wndStatusBar as public.
Try it out.
VinExpert