Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 959
  • Last Modified:

Selecting font files with CFileDialog

Hi,

I'm using VC++ 5.0 with Win95. I create a CFileDialog to select files. The CFileDialog does special
processing when the files displayed in the dialog are font files. In this case, the file name is not displayed, rather, the font name is displayed instead. When I select a font and click on the Open button, a font dialog pops up displaying a sample of the font.
I need to be able to select font files like any other file, without all this special extra processing
that the CFileDialog seems to be doing.

To see an example of what I am talking about, create a CFileDialog and select the
c:\windows\fonts directory on your system. Only the font names will be displayed, not the
font filenames. And selecting a font pops up a font dialog...

Thanks,
Ralph.
0
rakhras
Asked:
rakhras
1 Solution
 
Tommy HuiCommented:
At this point, why not make your own dialogs? It sounds like CFileDialog will only get in the way. You would probably be better off making your own dialogs. That way, you have complete control over what happens.

0
 
rakhrasAuthor Commented:
I want to avoid duplicating all the functionality that is already implemented in the CFileDialog. It seems like an overkill to reimplement CFileDialog just to handle font Files.
0
 
RONSLOWCommented:
I have tried this.  It doesn't happen unless I right click on the font and select 'open'.  Clicking on the open button does nothing (dialog stays up).  Guess it depends on the bits you select such as file must exist etc.

I suggest you turn off the explorer bit and therby use the old-style file open dialog.

0
 
kalaruCommented:
Did you try with the old style FileOpen dialog also (as suggested)?

If that doesn't work, then you may have to do your own dialog :-(

0
 
RONSLOWCommented:
thanks for your responses.

I have finally found a workaround to my problem that allows
me to display font files like any other file in a CFileDialog.

Here's a quick summary:

The Windows\Fonts folder behaves differently than other
folder because it is a so called "virtual name space".
Other folders like this one are the Recycle Bin, Temporary Internet files and so on.

You can make a folder a virtual name space by:

1. Making the folder read-only
2. Creating a Desktop.ini file in the folder

If you look (in a DOS box) at the Desktop.ini file in the
Windows\Font directory, you'll find that it defines a UICLSID.
I do not know the details as to how this IUCLSID modifies the
default behaviour of the CFileDialog.

The workaround consists in renaming the Desktop.ini
during the creation of the CFileDialog and restoring its
name when the CFileDialog is destroyed.
Note that there are some side effects to this workaround
since all applications will be temporarily affected.

Anyway, that's the summary.

I would like to close this question but there seems to be no way
to close it. So please do not answer this question anymore.

Thanks,
Ralph.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now