Font Requester - name and size only

Just starting out? Need help? Post your questions and find answers here.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Font Requester - name and size only

Post by rsts »

I would like to offer a font selector that only permits selection of fontname and size. Just a way to allow a default font selection and I would prefer they not be picking bold, underline, etc.

Is this possible without completely building my own? I've searched msdn but have not seen any combination of options that would accomplish this.

cheers
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Testted and working on XP.

Code: Select all

Procedure CFHookProc(hwnd, msg, wParam, lParam)
  ;- disable style combo
  hStyle = GetDlgItem_(hwnd, 1137)
  EnableWindow_(hStyle, 0)
  ;- Return 0 to process msg
  ;- Return 1 to ignore msg
  ProcedureReturn  0
EndProcedure
hdc = CreateDC_(@"DISPLAY", 0, 0, 0) 
logPixSY = GetDeviceCaps_(hdc, #LOGPIXELSY) 
DeleteDC_(hdc) 

cf.CHOOSEFONT
cf\lStructSize = SizeOf(cf) 

lf.LOGFONT 
;- Default font size
pointSize = 12
lf\lfHeight = (pointSize * logPixSY) / 72

;- Default font
FontName$ = "Courier New"
CopyMemory(@FontName$, @lf\lfFaceName, Len(FontName$))

cf\flags = #CF_INITTOLOGFONTSTRUCT | #CF_SCREENFONTS | #CF_ENABLEHOOK | #CF_USESTYLE

;- HookProc to disable choosing of styles
cf\lpfnHook = @CFHookProc()

;- lf.LOGFONT contains default font properties
cf\lpLogFont = @lf 

;- Get language text for various styles
hLib = OpenLibrary(0, "comdlg32.dll")
style$ = Space(260)

;- Regular
LoadString_(hLib, 1284, @style$, 64)

;- Bold
;LoadString_(hLib, 1285, @style$, 64)

;- Italic
;LoadString_(hLib, 1286, @style$, 64)

;- Bold Italic
;LoadString_(hLib, 1287, @style$, 64)

;-(none)
;LoadString_(hLib, 1288, @style$, 64)
CloseLibrary(0)

cf\lpszStyle = @style$


If ChooseFont_(@cf) 
  MessageRequester("Font chosen:", "Name: " + PeekS(@lf\lfFaceName) + #CRLF$ + "Size: " + Str(cf\iPointSize/10) + #CRLF$ + "Style: "  + style$, #PB_MessageRequester_Ok | #MB_ICONINFORMATION)
EndIf

Last edited by Sparkie on Sat Feb 28, 2009 9:08 pm, edited 1 time in total.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice one Sparks. :)
I may look like a mule, but I'm not a complete ass.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Never ceases to amaze me.

Now I have to explain to my partner, why I'm doing it when I had just told him it was impossible due to a windows limitation :)

I'll see if I can get kwai to send you a rose (or whatever).

(works on vista too)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Somebody call KCC SHIPMENT 24/24 hours at your service !!! :D

It's a little bit to late for the shipment of a rose :cry:
But KCC have always a good solution for his hero SPARKIE

KCC have found that

Image

Yes i know i know......it's not a rose :?
But this tongs is pink no ???? :roll:

And my hero is surelly very nice with this great shoes :D
I say at everybody that my hero know all to do, it's for that, that is the KCC hero 8)
And like all the true and great hero, he have a very good and devoted assistant, who be always behind him, i have nominate KCCSKIE.
It's a mystery, but nobody know who is he ???? because he is hidden behind a mask :?

Image

Perhaps a day KCCSKIE take off his mask ????
Surelly the day where his hero take off it too :D
Last edited by Kwai chang caine on Sun Mar 01, 2009 1:18 am, edited 5 times in total.
ImageThe happiness is a road...
Not a destination
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

umm - i leave that between you and sparkie. Have fun.

:D

I'm sure sparkie will LOVE the slippers.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Hello Kitty FTW or what?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Ayaaaai !!!! it's the day, it's good !!!!! ...the shop is open in france at this time :D
And a client is a client....and KCC don't want loose any client :?

Then KCC SHIPMENT 24/24 hours at your service, have run everywhere, and found the real command for his client.
And i'm sure that this time.....SPARKIE been proud of his devoted assistant

Image

If you have another command.....don't forget.... one name only :
KCC SHIPMENT 24/24 hours at your service :D
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Kind FLUID BYTE wrote:Hello Kitty FTW or what?
KCC SHIPMENT 24/24 hours at your service

No problem !!!!!
For my dear FLUID BYTE also

Image
ImageThe happiness is a road...
Not a destination
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

KCC, I'm proud to have you as my assistant but the pink footwear has got to go. :shock: Maybe something in bat black would be more of a fashion statement. :wink:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

KCC, I'm proud to have you as my assistant
Thank you very much, this is one of the more good day of my life 8)

I have at last, find somebody who want me in assistant :oops:
This sentence proof another time, that you are not only great for the knowledge....but also for the heart 8)
Don't worry....KCC have do all that is possible, for serve his master, for that, always my hero, as proud of the little KCC :D
Maybe something in bat black would be more of a fashion statement
Yes you are right, but i had an imperative, remember you the sentence of rsts
rsts wrote:I'll see if I can get kwai to send you a rose

And i don't know if you know that, but in france a rose it's the same word that the color pink (Rose the color = Rose the flower)
So when rsts call KCC SHIPMENT 24/24 hours at your service then it's to late for shopping because all the flower shop in france is closed :cry:
Then KCC have an idea :D offer like rsts want an object "Rose" so "pink"
This is the explain of this story :D

But don't worry....you don't put this shoes for do your dangerous mission of BATMAN.....no no no :roll:
And surelly the spectator of movie laugh if he see the pink shoes replace the black boots :lol:
And KCC don't want the spectator jeer of his hero :?
It's just when you are in your home or in vacancy with your nice dog :D
Oh... i have forgotten the other day to ask you, the name of your devoted assistant at four foot ??? :roll:
This mines is "PERLE" and "SOURIS" in english it's "PEARL" and "MOUSE".
But she don't know the english, if you call her like this "PEARL" and "MOUSE" perhaps she are unnerve :lol:
ImageThe happiness is a road...
Not a destination
Post Reply