Link to home
Start Free TrialLog in
Avatar of redbrad0
redbrad0

asked on

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?
Avatar of Erick37
Erick37
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of redbrad0
redbrad0

ASKER

Is VBAccelerator a component to add into visual basic 6?
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)
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.
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
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!
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 :(
"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
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.
Do you have a paypal address that I can donate some money to you for being so helpful?
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 :)
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 :-)
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"
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
nevermind looks like i figured that part out
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?
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
Thanks for all your help