🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10970

Re: Fontsettings

#10970
From: Johan Elms�ter
Date: Mon, 08 Mar 2004 20:50
79 lines
3308 bytes
Thanks!
"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote in message
news:404a60f5$1@newsgroups.borland.com...
> Something like the code at the bottom should be able create a font of a
> certain point size.
>
> For TextOut use the SelectObject as Mr Gonder showed.  For a listbox send
it
> a message telling it to use the font.  Code to do that should look
something
> like this:
>
>     SendMessage(listbox_hwnd, WM_SETFONT,
>           reinterpret_cast<WPARAM>(font_hand), FALSE);
>
> Note that if you've only the control ID then you can get the HWND it needs
> with GetDlgItem(containing_hwnd, ID_NUMBER);
>
> Also note that in Mr Gonder's example he has the font being created and
then
> deleted on each pass through the TextOut.  You might consider doing it a
bit
> differently, creating the font when the program starts and deleting it
when
> the program ends.
>
> .  Ed
>
>   -------------------------
>   #include <windows.h>
>
>   // Create a fixed-width font of a given size in points
>   // Return the font handle (will be NULL if it couldn't create it)
>   // Call DeleteObject to delete the font handle
>   // at the end of the program
>
>   HFONT InitFont(int font_pts)
>     {
>     LOGFONT lf;
>     HFONT font_hand;
>
>     ZeroMemory(&lf, sizeof(lf));
>     lstrcpy(lf.lfFaceName, "Lucida Sans Typewriter Regular");
>     lf.lfWeight = FW_LIGHT;
>
>     HDC hdc = GetDC(GetDesktopWindow());
>
>     lf.lfHeight =
>         -MulDiv(font_pts, GetDeviceCaps(dc, LOGPIXELSY), 72);
>     ReleaseDC(hdc);
>     font_hand = CreateFontIndirect(&lf);
>
>     // if it couldn't find Lucida, try again with Courier New
>     if (!font_hand)
>         {
>         lstrcpy(lf.lfFaceName, "Courier New");
>         font_hand = CreateFontIndirect(&lf);
>         }
>
>     return font_hand;
>     }
>
>   -------------------------
>
>
> > Johan Elms�ter wrote in message
> > news:4049d1af@newsgroups.borland.com...
> >
> > I have made a little application, with one button a bitmap, a
> > listbox and I'm using the textout API to show some text in
> > the window.
> >
> > Now I wonder how I set the fontsize for the text drawn with
> > textout and the text added in the listbox.
> >
> > Does anyone know?
>
>
>
Technical Details
Message-ID: <404cdc86$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4049d1af@newsgroups.borland.com> <404a60f5$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,d1297fa599b5b2a3
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-03-08 13:10:27 PST
Reply-To: "Johan Elms�ter" <johan.elmsater@bulletinboard.nu>
From: "Johan Elms�ter" <johan.elmsater@bulletinboard.nu>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4049d1af@newsgroups.borland.com> <404a60f5$1@newsgroups.borland.com>
Subject: Re: Fontsettings
Date: Mon, 8 Mar 2004 21:50:11 +0100
Lines: 81
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 217.211.132.244
Message-ID: <404cdc86$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1078779014 217.211.132.244 (8 Mar 2004 12:50:14 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail