BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get current LOGFONT

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Renald Yazmir
Guest





PostPosted: Tue May 01, 2007 10:30 pm    Post subject: How to get current LOGFONT Reply with quote



Hi,



1) How can I get current LOGFONT?

I want to inquire the current font without displaying any dialog and without
asking to select the font.





2) If I want to rotate the text can I set only sub set of LOGFONT
parameters. For example:

....

log_font.lfHeight = font_height;
log_font.lfWeight = FW_SEMIBOLD;
log_font.lfEscapement = (LONG_T)(angle*10);
....

hfnt = CreateFontIndirect(&log_font);


Do I need to worry about the rest of parameters or I can just call:

memset(&log_font, 0, sizeof(LOGFONT));




Thank you.

Rony.
Back to top
Alan Bellingham
Guest





PostPosted: Tue May 01, 2007 10:30 pm    Post subject: Re: How to get current LOGFONT Reply with quote



"Renald Yazmir" <renald (AT) partmaker (DOT) com> wrote:

Quote:
1) How can I get current LOGFONT?

I want to inquire the current font without displaying any dialog and without
asking to select the font.

Use GetObject() on an HFONT handle. Check the documentation for this. To
get the current font HFONT, if you've never actually selected one,
you'll probably find that GetStockObject() with a suitable parameter
does the job. Or perhaps the WM_GETFONT message will work.

Quote:
2) If I want to rotate the text can I set only sub set of LOGFONT
parameters. For example:

log_font.lfHeight = font_height;
log_font.lfWeight = FW_SEMIBOLD;
log_font.lfEscapement = (LONG_T)(angle*10);
...

hfnt = CreateFontIndirect(&log_font);

Surely.

Quote:
Do I need to worry about the rest of parameters or I can just call:

memset(&log_font, 0, sizeof(LOGFONT));

If you do, you'll get defaults for all the other values. This may or may
not be what you want.

BTW, it's often considered good practice to avoid memset() when it's not
necessary. In this case

LOGFONT log_font = { 0 };
log_font.lfHeight = font_height;
log_font.lfWeight = FW_SEMIBOLD;
log_font.lfEscapement = (LONG_T)(angle*10);

would do fine. On the other hand, given you've been asking about getting
the current font details, then something like (untested)

LOGFONT log_font = { 0 };
HFONT Font = reinterpret_cast<::SendMessage(hWnd, WM_GETFONT, 0, 0));
GetObject(HFont, sizeof log_font, &log_font);
log_font.lfEscapement = (LONG_T)(angle*10);

looks like the right way to go.

Alan Bellingham
--
ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.