Font selector

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 selector

Post by rsts »

I can create the 'standard' windows font selector, but can't seem to find how to create a selector for the font name type only, as pictured.

Is there an API or must I create my own combobox list?

Hints and/or MSDN reference?

Image

Thanks
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Re: Font selector

Post by Fluid Byte »

rsts wrote:Is there an API or must I create my own combobox list?
Of course this ain't an API standard. This should get you started:

Code: Select all

OpenWindow(0,0,0,320,240,"EnumFonts",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
ComboBoxGadget(0,10,10,250,400,#CBS_SORT)

Global NewList	 FaceName.s()

Procedure EnumFontFamExProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
	FaceName$ = PeekS(@*lpelfe\elfFullName)
		
	Select FontType
		Case #TRUETYPE_FONTTYPE 
		Type$ + " [TT]"
	EndSelect
	
	ForEach FaceName()
		If FaceName() = FaceName$ + Type$ : Goto SkipFont : EndIf
	Next
	
	AddElement(FaceName())	
	FaceName() = FaceName$ + Type$ : Type$ = ""
	SkipFont:

	ProcedureReturn #True
EndProcedure

lf.LOGFONT
lf\lfCharset = #DEFAULT_CHARSET

hdc = GetDC_(WindowID(0))
EnumFontFamiliesEx_(hdc,lf,@EnumFontFamExProc(),0,0)
ReleaseDC_(WindowID(0),hdc)

ForEach FaceName()
	SendMessage_(GadgetID(0),#CB_ADDSTRING,0,FaceName())
Next

SetGadgetState(0,0)

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Font selector

Post by rsts »

Fluid Byte wrote:Of course this ain't an API standard. This should get you started: [snip]
And a nice start it is :)

gratz
Post Reply