Listing out items (fonts) displaying them in the correct format.

I have 3397 fonts installed on my computer and have a hard time trying to find the font I am looking for. I wrote a simple program where I can quickly go thru all the fonts installed by clicking down on the drop down menu. It all works fine but I want to improve it some. Right now it looks like this....
http://www.eznetideas.com/brad/fonts-1.gif

and I want it to look like this..
http://www.eznetideas.com/brad/fonts-2.gif

This way it will list out all the fonts in a row where I can scroll down and see more then one font per a page. I am not sure how this would be done so can you help me get started?
redbrad0Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
You could use an owner drawn listbox to show the fonts:

Change the Style of a Control / Owner Drawn Controls
http://www.thescarms.com/vbasic/OwnerDrawn.asp
0
Erick37Commented:
0
Erick37Commented:
The control from VBAccelerator is actually pretty easy to use.  Set the style to ecsListBox and the work is done!

Option Explicit

Private Sub Form_Load()

Dim f As StdFont
Dim i As Long
Dim height As Single

Set f = Me.Font

For i = 0 To Screen.FontCount - 1

    f.Size = 12
    f.Name = Screen.Fonts(i)
    f.Bold = False
    f.Italic = False
   
    height = TextHeight("|_^") / Screen.TwipsPerPixelY
   
    OwnerDrawComboList1.AddItemAndData f.Name, , , , , , , height, , , f

Next


End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

redbrad0Author Commented:
Is VBAccelerator a component to add into visual basic 6?
0
redbrad0Author Commented:
Sorry for being such a idiot but I am not a VB6 programmer just a ASP one. I added the vbalODCL6.ocx (VBAccelerator) component but was unsure what I needed to do with that additional file that is needed to run (the .dll file)
0
Erick37Commented:
Ok, place vbalODCL6.ocx and ssubtmr6.dll  into your Windows\system32 directory.

Open the command window (Start->Run "cmd")

Then register the components at the command prompt, one at a time with the following commands:

regsvr32 vbalODCL6.ocx

=and then=

regsvr32 ssubtmr6.dll

if all goes well, you can then add the component to your VB form.  Project->Components then check "vbaccelerator Owner Draw Combo..."

That's it!  Let me know if you have any questions.
0
redbrad0Author Commented:
Erick,

Thanks a ton that helped so much.... Can you just let me know what this line of code is doing?

height = TextHeight("|_^") / Screen.TwipsPerPixelY
0
Erick37Commented:
That's a good question.

TextHeight is a member function of the form which returns the height of the string passed in in Scale units.  The default scalemode for the form is Twips, so to convert to pixels we need to divide by Screen.TwipsPerPixelY (usually 15).

The string can be anything, "abc", "XYZ", "|_^", etc...

There is a problem with my code and I'm glad you asked the question.  The function uses the font currently selected in the form, so in the example above it does not get the height of each font in the loop.  To correct this, you need to set the form's font:

For i = 0 To Screen.FontCount - 1

    f.Size = 12
    f.Name = Screen.Fonts(i)
    f.Bold = False
    f.Italic = False
   
    Set Me.Font = f '<<---  Set the form font before calling TextHeight    

    height = TextHeight("abc") / Screen.TwipsPerPixelY
   
    OwnerDrawComboList1.AddItemAndData f.Name, , , , , , , height, , , f

Next

This is all optional, you can just hardcode the value of height if you like, and it will probably run a bit faster as well.

Hupe it helps!
0
redbrad0Author Commented:
Well it works exactly as I wanted it to except I can not figure out just a few things..... When the item is selected it does not show in the correct font, size or style. I really want it listed out like the previous list shows where you can see them without having to use a drop down menu. Then I want to be able to change the font size or make all the fonts bold if I want to. Sorry I am making this such a pain :(
0
Erick37Commented:
"I really want it listed out... " 

Set the style to ecsListBox.

"I want to be able to change the font size or make all the fonts bold ..."

Change the font properties in the loop before adding the fonts to the list:

f.Size = 12
f.Name = Screen.Fonts(i)
f.Bold = False
f.Italic = False
0
redbrad0Author Commented:
perfect on the listing out... sorry i should of been more clear but changing the font size after it is all loaded up with my fonts without having to reload them.
0
redbrad0Author Commented:
Do you have a paypal address that I can donate some money to you for being so helpful?
0
Erick37Commented:
You cannot change the size or style without reloading them.  Perhaps you can use a preview window to display variations of the font currently selected from the list.

Points will suffice :)
0
redbrad0Author Commented:
Ok I think I almost have it then......
I read the two pages you put on here and it did not say anything about columns. I tried to set the property to 2 columns and then nothing would display. Is there a different content to add items into column1 & column2?

More points added for you :-)
0
Erick37Commented:
To use columns, set the Column property to 2 and you also have to set the column widths in code:

OwnerDrawComboList1.ColWidth(1) = 100 'pixels
OwnerDrawComboList1.ColWidth(2) = 200
OwnerDrawComboList1.ColType(1) = ectTextString
OwnerDrawComboList1.ColType(2) = ectTextString

when you add the data, the tab character splits the text into the columns:

OwnerDrawComboList1.AddItemAndData "Column 1 Text" & vbTab & "Column 2 Text"
0
redbrad0Author Commented:
I tried to do this but I am trying to have it where its in one column and then becomes two. So what I did was add two boxes and just hide the 1 column when I need the two column. I know its showing the two column box but it just is still only adding one column and not the second one. Here is a link to the zip file if it helps (source code)

Brad

http://www.eznetideas.com/brad/ShowFont.zip
0
redbrad0Author Commented:
nevermind looks like i figured that part out
0
redbrad0Author Commented:
I tried to run the exe file on another PC and the ocx file was not registered. Is there a way to have it included in the VB Project?
0
Erick37Commented:
You have to run Package and Deployment Wizard to make a Setup for your program.  That way, all the dependencies that your program needs are distributed and installed properly on the target machine.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/setpwz98/html/vbconsetupwizardoverview.asp
0
redbrad0Author Commented:
Thanks for all your help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.