Page 1 of 1
Font Style...
Posted: Sun Oct 09, 2005 3:50 pm
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
Posted: Sun Oct 09, 2005 4:35 pm
by einander
Code: Select all
Result = FontRequester("arial", 12, #PB_FontRequester_Effects , #red)
Is this what you're asking for?
Posted: Sun Oct 09, 2005 4:50 pm
by Trond
I think he means bold and underlined and such.
Posted: Sun Oct 09, 2005 5:48 pm
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?
Posted: Sun Oct 09, 2005 8:19 pm
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.
Posted: Sun Oct 09, 2005 8:50 pm
by DoubleDutch
Thats really good, thanks
Fred:Pity the commands aren't native to PB...
Posted: Mon Oct 10, 2005 11:56 pm
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
Posted: Tue Oct 11, 2005 12:06 am
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.