|
-
May 27th, 1999, 03:10 AM
#1
GetTextExtent
I would like to display a progress bar in my status bar next to a string of text like
"Processing..." <here the progress bar>
For this reason I tried to calculate the width of the string using
m_wndStatusBar.GetDC()->GetTextExtent(str);
However, the font selected in the device context of the status bar doesn't seem to be the font of the displayed string. GetTextExtent returns a too large value.
Who can help???
-
May 27th, 1999, 04:51 AM
#2
Re: GetTextExtent
Hi Jan-Klaas,
if you call GetDC(), and then GetTextExtent() the length is calculated on the standard font. You need to select the font in the DC by yourself. To get the font you can use
NONCLIENTMETRICS ncm;
memset( &ncm, 0, sizeof( ncm );
ncm.cbSize = sizeof( ncm );
SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( ncm ), &ncm, FALSE );
CFont font;
font.CreateFontIndirect( &ncm.lfStatusFont );
After getting the font select it in the DC, and call GetTextExtent afterwards.
HTH
Martin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|