Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages
Started by Renald Yazmir
Tue, 01 May 2007 17:30
How to get current LOGFONT
Author: Renald Yazmir
Date: Tue, 01 May 2007 17:30
Date: Tue, 01 May 2007 17:30
36 lines
1447 bytes
1447 bytes
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.
Re: How to get current LOGFONT
Author: Alan Bellingham
Date: Tue, 01 May 2007 16:47
Date: Tue, 01 May 2007 16:47
52 lines
2597 bytes
2597 bytes
"Renald Yazmir" <renald@partmaker.com> wrote:
>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.
>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.
>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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads