open a default fil by using the CFileDialog class
-
How to open a default fil by using the CFileDialog class I open the dialog box like this . I want to keep one file as default selection CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); dlg.DoModal (); Vikas Amin Embin Technology Bombay vikas.amin@embin.com
-
How to open a default fil by using the CFileDialog class I open the dialog box like this . I want to keep one file as default selection CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); dlg.DoModal (); Vikas Amin Embin Technology Bombay vikas.amin@embin.com
-
I need to open a file named "1.bmp" located as "c:\1.bmp" but i get assertion for invalid address ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile)); My code is somthing like this :--------
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); dlg.m_ofn.lpstrFile=TEXT("c:\\1.bmp"); dlg.DoModal ();
Vikas Amin Embin Technology Bombay vikas.amin@embin.com -
I need to open a file named "1.bmp" located as "c:\1.bmp" but i get assertion for invalid address ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile)); My code is somthing like this :--------
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); dlg.m_ofn.lpstrFile=TEXT("c:\\1.bmp"); dlg.DoModal ();
Vikas Amin Embin Technology Bombay vikas.amin@embin.com -
sorry (error), now try with this:
TCHAR str[100]=TEXT("c:\\1.bmp"); dlg.m_ofn.lpstrFile=str;
Have a nice code day ;)sorry there is some problem in the given code also some assertion at ASSERT(m_hFile != (UINT)hFileNull); I thing will have to go through the sturctre method i found some links will try from it http://eatworms.swmed.edu/~boris/B\_Player/VideoWnd.cpp http://www.codeproject.com/dialog/remove\_filters.asp Why simpe things are done so complicated in VC++ Vikas Amin Embin Technology Bombay vikas.amin@embin.com
-
sorry there is some problem in the given code also some assertion at ASSERT(m_hFile != (UINT)hFileNull); I thing will have to go through the sturctre method i found some links will try from it http://eatworms.swmed.edu/~boris/B\_Player/VideoWnd.cpp http://www.codeproject.com/dialog/remove\_filters.asp Why simpe things are done so complicated in VC++ Vikas Amin Embin Technology Bombay vikas.amin@embin.com
I don't know, it is strange! :( A good thing could be add the flag OFN_FILEMUSTEXIST here: CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); So you are sure that the file exist. And I don't like very much ...,"Only BMP (*.bmp)|*.bmp|" I prefere ...,"Only BMP (*.bmp)|*.bmp||" Let me know Have a nice code day ;)
-
I need to open a file named "1.bmp" located as "c:\1.bmp" but i get assertion for invalid address ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile)); My code is somthing like this :--------
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); dlg.m_ofn.lpstrFile=TEXT("c:\\1.bmp"); dlg.DoModal ();
Vikas Amin Embin Technology Bombay vikas.amin@embin.comvikas amin wrote:
How to open a default fil by using the CFileDialog class
That is what the third parameter of
CFileDialog
's constructor is for.vikas amin wrote:
I need to open a file named "1.bmp" located as "c:\1.bmp"
Then why bother with
CFileDialog
if you already know the name of the file? Also, the filter should end with two ‘|’ characters.
"Take only what you need and leave the land as you found it." - Native American Proverb
-
vikas amin wrote:
How to open a default fil by using the CFileDialog class
That is what the third parameter of
CFileDialog
's constructor is for.vikas amin wrote:
I need to open a file named "1.bmp" located as "c:\1.bmp"
Then why bother with
CFileDialog
if you already know the name of the file? Also, the filter should end with two ‘|’ characters.
"Take only what you need and leave the land as you found it." - Native American Proverb
:zzz: yep if he knows filename & location then why he is using
CFileDialog
. well i guess he wants to show his skills here.;) -
vikas amin wrote:
How to open a default fil by using the CFileDialog class
That is what the third parameter of
CFileDialog
's constructor is for.vikas amin wrote:
I need to open a file named "1.bmp" located as "c:\1.bmp"
Then why bother with
CFileDialog
if you already know the name of the file? Also, the filter should end with two ‘|’ characters.
"Take only what you need and leave the land as you found it." - Native American Proverb
vikas amin wrote: I need to open a file named "1.bmp" located as "c:\1.bmp" Then why bother with CFileDialog if you already know the name of the file? Yeh good qestion , i need this only for Testing purpose & when i cannot reach some thing in coding it makes me crazy to get it done . :cool: Vikas Amin Embin Technology Bombay vikas.amin@embin.com
-
I don't know, it is strange! :( A good thing could be add the flag OFN_FILEMUSTEXIST here: CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|"); So you are sure that the file exist. And I don't like very much ...,"Only BMP (*.bmp)|*.bmp|" I prefere ...,"Only BMP (*.bmp)|*.bmp||" Let me know Have a nice code day ;)
I will have to get the exact error if u have tested the code so u might be right , can be some error in my code . Vikas Amin Embin Technology Bombay vikas.amin@embin.com
-
sorry (error), now try with this:
TCHAR str[100]=TEXT("c:\\1.bmp"); dlg.m_ofn.lpstrFile=str;
Have a nice code day ;)_Russell_ wrote:
dlg.m_ofn.lpstrFile=str;
If
lpstrFile
is assigned a non-NULL
value, so mustnMaxFile
also be used to indicate the size of the buffer pointed to bylpstrFile
. Why do it this way, however, when the constructor already has provisions for such?
"Take only what you need and leave the land as you found it." - Native American Proverb