question

PMSherwood-3061 avatar image
0 Votes"
PMSherwood-3061 asked DavidLowndes-6766 commented

CFileDialog has empty view dropdown

The C++/MFC File Open dialog (CFileDialog) produces incorrect results on Windows 10. Namely, the View Menu dropdown (blud arrow) is empty. The same executable, run on Windows 7, produces the expected View Menu (red box). Another difference is the navigation pane on the left. The navigation pane difference is unimportant; I just showed it for completeness.

The C++ code producing this image is CFileDialog dlg(TRUE); dlg.DoModal();
This code is in a large project which has been ported successively from Visual C++ 6 (ca 1982). The same code in a new test project shows a normal Windows 10 File Open dialog, with the new-style view menu. So probably the failure is due to some setting in the large project.

The large project is built with MFC linked as a static library, using ANSI (not Unicode). All the libraries are from the current Windows 10 kit (10.0.18362.0); this is VS 2019 16.10.4. Both debug and release builds behave the same way, and the problem has existed for several years.

For large project, using the debugger to step thru the CFileDialog constructor shows that the call to CoCreateInstance returns CLASS_E_CLASSNOTAVAILABLE ClassFactory cannot supply requested class. In the new test project, this function does not return an error.

Both large project and test project have the same project properties.

The same symptom occurs on a different Windows 10 installation.

How can I fix the issue of the empty View Menu?

119120-file-open-dialog-windows-710.png



c++
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Addition: This seems to be caused by the following line:
SetThemeAppProperties(themeProp&(~STAP_ALLOW_CONTROLS)); // this disables visual styles for controls in dialogs, but keeps them for the buttons in title bars
Before this line is executed, themeProp = 3. After, themeProp = 1.

0 Votes 0 ·

Yes, if I do in a Win32 app SetThemeAppProperties(STAP_ALLOW_NONCLIENT);
before GetOpenFileName with OFN_ENABLEHOOK (to get this old look), I have the same behaviour on Windows 10


0 Votes 0 ·

Can you use the V5 version of the common controls instead of V6 (i.e., no manifest the v6 version)? If so, that would mean you could remove the call to SetThemeAppProperties since visual styles would not be applied.

0 Votes 0 ·

Unfortunately V6 is needed for other reasons.

0 Votes 0 ·
Show more comments

0 Answers