Link to home
Start Free TrialLog in
Avatar of bluefive
bluefive

asked on

How to show the Add Fonts window

I would like to know how I can show the 'Add Fonts' window (Control Panel/Fonts/Add Fonts) from my program and if possible at a predifined location (like e:\new fonts)
with the 'Copy fonts to Fonts folder' option ON.

API, Shell, regular or custom code, it doesn't matter.
I'm using VB6-SP1.

Note:
I know I can show the Fonts window from the Control Panel with the Shell command
rundll32.exe shell32.dll,Control_RunDLL main.cpl @3, but I realy need to trigger the 'Add Fonts' window.

Thank you!
ASKER CERTIFIED SOLUTION
Avatar of MikeP090797
MikeP090797

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 bluefive
bluefive

ASKER

Is AddFontResource all I need?
I thought this would make a font available to the system just temporarily...

Don't I have to do something like:
a. Copy the font to the fonts dir
b. Write to the registry
c. Call AddFontResource
d. Call CreateSccalableFontResource
e. Call SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0)

Or am I making things too complicated? Please tell me I do! ;-)


You will need to copy the font into the font dir, but you don't need CreateScallableFontResource. AddFontResource takes every type of fonts:

>>Pointer to a null-terminated character string that contains a valid font file filename. The filename may specify either a .FON font resource file, a .FNT raw bitmap font file, a .TTF raw TrueType file, or a .FOT TrueType resource file.

You will also have to notify with WM_FONTCHANGED, I forgot that part.
Thanks very much!