Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CStatusBar, Setting the length of a pane to string size[Q]

39 views
Skip to first unread message

Andrew Kassell

unread,
Feb 25, 1997, 3:00:00 AM2/25/97
to

It doesn't set it to the right size - it's always bigger. Has anybody any
idea's?

CString Text = "Hello";
CDC *dc = m_wndStatusBar.GetDC();
CSize s = dc->GetTextExtent( Text );
m_wndStatusBar.SetPaneInfo(1, ID_MY_PANE, SBPS_POPOUT, s.cx);
m_wndStatusBar.ReleaseDC(dc);
m_wndStatusBar.SetPaneText( 1,Text );

Thanks,

Andy Kassell
Senior Project Engineer
Penny+Giles Instrumentation Ltd
http://www.p-ginst.co.uk

R. Vince

unread,
Mar 3, 1997, 3:00:00 AM3/3/97
to

Eric,
You have to devide s.cx by some constant - I don't know why, but, having
worked around the same problem myself, I found sometimes a constant of 5
worked, sometimes 10......anyhow, hyou have to kind of eyeball it and work
with it from there. -Ralph

Eric Jucker <er...@deltanet.com> wrote in article
<331AB0...@deltanet.com>...

> try this:
>
> UINT uID;
> UINT uStyle;
> int nWidth;
> CRect rect;
> CString Text = "Hello";
> m_wndStatusBar.GetPaneInfo( 1, uID, uStyle, nWidth );
> CDC *dc = m_wndStatusBar.GetDC();
> dc->SelectObject( m_wndStatusBar.GetFont( ));
> dc->DrawText( Text , -1, rect, DT_SINGLELINE | DT_CALCRECT );
> m_wndStatusBar.ReleaseDC( dc );
> m_wndStatusBar.SetPaneInfo( 1, uID, SBPS_POPOUT, rectArea.Width() );
>
> I remember having troubles also with SetPaneText(} and resolved it with
> m_wndStatusBar.GetStatusBarCtrl().SetText( Text, 0, SBT_NOBORDERS );
>
> Eric Jucker
> SimExel Corp.
> http://www.simexel.com
>

0 new messages