running MFC on Windows 64bit and wanting to use CFileDialog to load/save
a file but not change the place where the main document File/Open+SAveAs
writes the files.
I've looked through the documentation and found reference to
CFileDialog fileDlg(TRUE,.....);
fileDlg.m_ofn.lpstrInitialDir="C:\\";
but a) is does not set the initial directory to C:\
and b) the next File:SaveAs takes to where I loaded that file
I'm sure I am missing something simple but cannot figure out what it is
Any help will be very much appreciated.
Regards
Phil
"phil oakleaf" <ne...@oakleafsoftware.co.uk> wrote in message
news:ucA4Hvb0...@TK2MSFTNGP05.phx.gbl...
Thanks for the tip - I am using Vista 64bit and building with VS-2005
There appear to be no methods called
UpdateOFNFromShellDialog
ApplyOFNToShellDialog
are these in a later version of MFC?
Thanks
Phil
I can see them using VS2008.
Giovanni
"phil oakleaf" <ne...@oakleafsoftware.co.uk> wrote in message
news:ueIrb8f0...@TK2MSFTNGP05.phx.gbl...
Upgrade time!!!!
Many thanks
Phil
To get the ApplyOFNToShellDialog methods visible I've had to change
WINVER from 0x0400 to 0X0600, which worries me.
Does this create compatability problems if the software is run on older
versions of Windows (we have some users on WIn95)
Anyway, having done all this when I do the following
m_myFileDialogPtr->UpdateOFNFromShellDialog();
m_myFileDialogPtr->m_ofn.lpstrTitle = L"New Dialog Title";
m_myFileDialogPtr->ApplyOFNToShellDialog();
m_myFileDialogPtr->DoModal();
as soon as DoModal is called, I get an assert
f:\dd\vctools......\dlgfil.cpp" - a file I dont have
followed by
"Encountered an improper argument"
All I am trying to do is get CFileDialog to not change folder on Vista :)
Any ideas?
Many thanks
Sorry, I meant to say that I want to set the initial folder that
CFileDialog displays
Yes, Visual C++ 2008 supports only Windows 2000 and up.
<http://msdn.microsoft.com/en-us/library/ms235435.aspx>
It's possible that particular programs generated with VC++ 2008 would run on
Windows 98 or earlier, but you would need to test them very carefully.
I must say I have mixed feelings about this backward compatibility for legacy
targets. Windows 2000 will be the next to go, but I doubt Microsoft would dare
remove support for XP any time soon.
--
David Wilkinson
Visual C++ MVP
I may be wrong, but I think that if you want to support Win95, you can't use
VS2008.
IIRC, the latest VC++ compiler that supports building code for Win95 is
Visual Studio .NET 2003 (a.k.a. VC++7.1).
(I'm not sure if VS2005 supports Win95... I recall that VS2005 supports
Win98.)
Moreover, I think that if you want to use the new Vista dialog, your code
can't run on Win95.
> Anyway, having done all this when I do the following
>
>
> m_myFileDialogPtr->UpdateOFNFromShellDialog();
> m_myFileDialogPtr->m_ofn.lpstrTitle = L"New Dialog Title";
> m_myFileDialogPtr->ApplyOFNToShellDialog();
>
> m_myFileDialogPtr->DoModal();
>
> as soon as DoModal is called, I get an assert
>
> f:\dd\vctools......\dlgfil.cpp" - a file I dont have
I have the file 'dlgfil.cpp' in this folder:
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc
I've tried this code on VS2008 and it works fine (you can build a
dialog-based app with MFC, and associate this code to the click of a button
on the dialog-box):
<code>
void CTest1Dlg::OnBnClickedButton1()
{
// Open file dialog
CFileDialog fileDlg(TRUE);
// Update the m_ofn variable
fileDlg.UpdateOFNFromShellDialog();
// Change the title
fileDlg.m_ofn.lpstrTitle = L"New Dialog Title";
// Apply the changes
fileDlg.ApplyOFNToShellDialog();
// Show the window
fileDlg.DoModal();
}
</code>
HTH,
Giovanni
> Sorry, I meant to say that I want to set the initial folder that
> CFileDialog displays
So, you can set the m_ofn.lpstrInitialDir field, like this:
<code>
void CTest1Dlg::OnBnClickedButton1()
{
CFileDialog fileDlg(TRUE);
// Update the m_ofn variable
fileDlg.UpdateOFNFromShellDialog();
// Change the title
fileDlg.m_ofn.lpstrTitle = L"New Dialog Title";
// Set initial folder
CString initialFolder = ... << initial folder path >>;
fileDlg.m_ofn.lpstrInitialDir = initialFolder;
// Apply the changes
fileDlg.ApplyOFNToShellDialog();
// Show the window
fileDlg.DoModal();
}
</code>
Giovanni
"phil oakleaf" <ne...@oakleafsoftware.co.uk> wrote in message
news:OTFo$Nt1JH...@TK2MSFTNGP06.phx.gbl...