From: Hector Santos on
How do I set the text alignment to the right in a CStatusBar panel cell?


For example, in this case I am using it for a online timer, the width
is set like so, in the dialog OnCreate() override:

UINT style, id;
int width;

m_wndStatusBar.GetPaneInfo(4, id, style, width);
m_wndStatusBar.SetPaneInfo(4, id, style, 70);

where 70 is enough for 8 * 8 characters (64) pixels to display a
formatted time string:

hh:mm:ss

The style parameter from I see in MSDN does not cover alignment
properties.

The reason I would like to right align its is because I am making it a
"smart timer" for humans:

"XX secs" for the first minute
"YY mins XX secs" for the first 10 minutes

and then its just uses HH:MM:SS.

So I'm extending the width to about 8*16 pixels and would to right
align it.

I can probably left pad it, and that would probably gbe ood enough but
if can be done with a style, that would be better.

TIA

--
HLS
From: Hector Santos on
I'm sure the coding logic is there to access the panel CWnd, but I
picked up an cool CStatusBar subclass that provided plug and play
flexibility of adding more controls to the status bar.

http://www.codeproject.com/KB/statusbar/ExtStatusControlBar.aspx

Easy method to a label control and hence easy preparation for the
alignment, font, coloring, etc.

--
HLS

Hector Santos wrote:

> How do I set the text alignment to the right in a CStatusBar panel cell?
>
>
> For example, in this case I am using it for a online timer, the width is
> set like so, in the dialog OnCreate() override:
>
> UINT style, id;
> int width;
>
> m_wndStatusBar.GetPaneInfo(4, id, style, width);
> m_wndStatusBar.SetPaneInfo(4, id, style, 70);
>
> where 70 is enough for 8 * 8 characters (64) pixels to display a
> formatted time string:
>
> hh:mm:ss
>
> The style parameter from I see in MSDN does not cover alignment properties.
>
> The reason I would like to right align its is because I am making it a
> "smart timer" for humans:
>
> "XX secs" for the first minute
> "YY mins XX secs" for the first 10 minutes
>
> and then its just uses HH:MM:SS.
>
> So I'm extending the width to about 8*16 pixels and would to right align
> it.
>
> I can probably left pad it, and that would probably gbe ood enough but
> if can be done with a style, that would be better.
>
> TIA
>

From: Hector Santos on
I need some MFC expert guidance here.

This 3rd party class at codeproject didn't provide the override for
the CStatusBar::SetPaneText().

While I dug into the code to this:

BOOL CExtStatusControlBar::SetPaneText(int nIndex, LPCTSTR
lpszNewText, BOOL bUpdate)
{
if( nIndex < m_nCount && nIndex >= 0 ){
_STATUSBAR_PANE_ pane;
if (PaneInfoGet(nIndex, &pane)) {
for ( int i = 0; i < m_arrPaneControls.GetSize(); i++ ){
if (m_arrPaneControls[i]->nID == pane.nID) {
_STATUSBAR_PANE_CTRL_ *pc = m_arrPaneControls[i];
if( pc ) {
::SetWindowText(pc->hWnd,lpszNewText);
return TRUE;
}
return FALSE;
}
}
// regular CStatusBar pane
return CStatusBar::SetPaneText( nIndex, lpszNewText, bUpdate);
}
}
return FALSE;
}

I would like to simplify this by getting the specific CStatusBar pane
window handle so I can take control of the attributes. I just don't
see any public members in its in CStatusBar or its base CControlBar
class to access the pane windows.

Do you see how without duplicating this class?

--
HLS

Hector Santos wrote:

> I'm sure the coding logic is there to access the panel CWnd, but I
> picked up an cool CStatusBar subclass that provided plug and play
> flexibility of adding more controls to the status bar.
>
> http://www.codeproject.com/KB/statusbar/ExtStatusControlBar.aspx
>
> Easy method to a label control and hence easy preparation for the
> alignment, font, coloring, etc.
>