Font Style...

Just starting out? Need help? Post your questions and find answers here.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Font Style...

Post by DoubleDutch »

How do you set the default font style in a font requester?

Result = FontRequester(FontName$, FontSize, Flags [, Color])

There appears to be nowhere to set it as Flags is used for something else.

Any ideas?

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

Code: Select all

Result = FontRequester("arial", 12, #PB_FontRequester_Effects , #red) 
Is this what you're asking for?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I think he means bold and underlined and such.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Einhander: Thanks for the reply, but no. :(

Trond: Yep, thats what I'm after! :)

Also, how do you get the results from the #PB_FontRequester_Effects, such as underline and strikeout?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I am guessing that the Purebasic FontRequester() command is just a wrapper for the API Choosefont_() function which certainly allows you to achieve your desired results.
However, without direct access to the underlying 'CHOOSEFONT' structure, it would seem that you cannot do what you're after with the PB command.
Here is a simple example of using the Choosefont_() function in which I select the default colour to be red and also select the strikeout option as default. The results of the users choices are returned within the choosefont structure. Sorry I haven't time for a more in depth example.

Code: Select all

;Choose font common dialogue with default colours etc.
loadfont(1,"Arial", 16, #PB_Font_Bold|#PB_Font_Italic)

cf.CHOOSEFONT
lf.LOGFONT
GetObject_(usefont(1), SizeOf(lf), @lf)
lf\lfStrikeOut = #TRUE
cf\lStructSize = SizeOf(cf)
cf\lpLogFont = @lf
cf\Flags = #CF_INITTOLOGFONTSTRUCT | #CF_SCREENFONTS | #CF_EFFECTS
cf\rgbColors = #Red 
choosefont_(@cf)
Regards.
I may look like a mule, but I'm not a complete ass.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Thats really good, thanks :)

Fred:Pity the commands aren't native to PB...
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
MikeB
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Apr 27, 2003 8:39 pm
Location: Cornwall UK

Post by MikeB »

What's wrong with -

Code: Select all

MyFont=LoadFont(0,"arial black",10,#PB_Font_Underline)
MyWin = OpenWindow(0,200,200,200,50,#PB_Window_SystemMenu,"")
CreateGadgetList(MyWin)
MyGad=StringGadget(0,10,10,180,25,"Type something")
SetGadgetFont(0,MyFont)
Works for me,
MikeB
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

DoubleDutch's request was not for simply setting font styles etc. more a case of wanting to display to the user a more flexible 'FontRequester' so that the user could select the font styles etc.

Unfortunately, the PB implementation of the Font chooser common dialogue does not give us total control over the said common control. E.g. setting default styles and colours.
I may look like a mule, but I'm not a complete ass.
Post Reply