Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select fonts from a combobox 1

Status
Not open for further replies.

Koen Piller

Programmer
Jun 30, 2005
841
0
0
NL
Hi,
I would like to make a combobox showing all the available fonts to pick one. Easy job with afont(), however I would also have the individual fontnames to be displayed in there own font. Just like in MSWord. However I dont seem to be able to make the font dynamically in a combobox. What would I need to do to achieve this?
Regards,
Jockey2
 
As far as I know, you cannot do it in a combobox, Even MS Word does not use one, more like a grid.

But it can be done:
Use a textbox, a button with a "Down" bmp and a grid. Make the Grid invisible, When User clicks the down button, make the grid Visible, user makes a selection, make the grid invisible again.

Its a PIA. If the Textbox is too low on the form, the grid has to move above the Textbox...
Code:
***Grid:
1 column
=Afonts(temp) 
Create Cursor fontcursor (cfontname c(50))
****populate the cursor from temp
****make the cursor the recordsource
****set the column1 controlsource
****Refresh the grid

****** Grid Refresh
SELECT fontcursor
this.SetAll("DynamicFontName", "", "Column")
This.setall("DynamicFontName","IIF(!EMPTY(fontcursor.cfontname), ALLTRIM(cfontname), 'Arial')","column")

****** Grid Afterrowcolchange()
Thisform.grid1.text1.value = fontcursor.cfontname

*************
Grids Mouseup: you can make the Grid invisible

You will have to fine tune...
 
Imaginecorp,
Thanks for the response, as you noticed it is indeed a PIA to move the textbox and more GUI minorities to manage - seems like a lot of code for a combo. Anyway if the universalthread link does not show a workable solution will have to go for it.
Chris,
Will check this link tonight, rightnow it seems that I am blocked for this link, I will check back to you asap.
Thanks,
Jockey2
 
The problem with showing fonts in their own names is that it can actually make it harder for a user to select the best font for a particular job.

Fonts with short names, like Bell, don't show enough characters to depict the font. With others, it can be quite hard to discern the name. This is especially true of script fonts like Blackadder and Freestyle. And, of course, fonts like Wingdings and Dingbats are impossible to distinguish if you use the font itself for the name.

Could I suggest a better solution: within the combo, show the fonts in the standard system font, but also provide a "preview" box. This would be an edit box, containing a couple of sentences of typical text, formatted in the selected font.

All you need to do is to write code in the combo's InteractiveChage to change the edit box's Fontname. That way, the user has the best of both worlds.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Chris,
a very nice utility indeed. Exactly what I was looking for.
Thanks.
Jockey2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top