Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MFC70, CFileDialog and WinNT

Posted on 2003-03-10
3
Medium Priority
?
291 Views
Last Modified: 2013-11-20
I have an app made in VC++.NET and MFC. It works fine in WinXP and Win2000, but in Win9X and WinNT CFileDialogs does not show. According to information on msdn.microsoft.com CFileDialog is changed in MFC 7.0 to use the new File Open and Save dialog boxes in Win2000 and WinXP. Obviously these new dialog boxes does not work in older Windows versions, but why don't I get the old dialog boxes instead? Does anyone have a solution how to get this working also in Win9X and WinNT?
0
Comment
Question by:P1R
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 8103832
How is the CFileDialog instance created? Are you using static or shared MFC DLL's?
0
 
LVL 1

Accepted Solution

by:
hoabeo earned 400 total points
ID: 8108444
This is a bug on MFC implementation. The bug happened when compiling project under Win2000/XP and running it under win9x, because of wrong size passed to OPENFILENAME struct when creating instance of CFileDialog (a fixed value will be assigned when compiled).

explicit CFileDialog(
   BOOL bOpenFileDialog,
   LPCTSTR lpszDefExt = NULL,
   LPCTSTR lpszFileName = NULL,
   DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
   LPCTSTR lpszFilter = NULL,
   CWnd* pParentWnd = NULL,
   DWORD dwSize = sizeof(
   OPENFILENAME )
);

if you change dwSize param to 0, CFileDialog will dynamically assigns the size of OPENFILENAME according to the current system.

The use of CFileDialog will be:
CFileDialog fileDlg (TRUE, "my", "*.my",
      OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this, 0);
   
// Display the file dialog.
if( fileDlg.DoModal ()==IDOK )
{
   CString pathName = fileDlg.GetPathName();
  // Implement opening and reading file in here.
  ...
}
0
 

Author Comment

by:P1R
ID: 8117809
Great, thanks!

(Isn't it amazing that a zero in the right place so often makes all the difference:)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question