Re: Use of CFileDialog
From: TVR Fan (nosuch_at_address.com)
Date: 04/19/04
- Next message: Ram Baruch: "CreateInstance() works in VC6.0 but not in VC7.0"
- Previous message: Tom Junior: "Re: Drawing arcs"
- In reply to: TVR Fan: "Use of CFileDialog"
- Next in thread: Johan Rosengren: "Re: Use of CFileDialog"
- Reply: Johan Rosengren: "Re: Use of CFileDialog"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 19 Apr 2004 14:51:23 +0100
Ok, so if I had used "Flags |=" instead of "Flags =", I wouldn't have been
writing that message! I'm still getting an access violation though when the
CFileDialog goes out of scope. Presumably its destructor is trying to access
a null pointer somewhere?
--- Al.
"TVR Fan" <nosuch@address.com> wrote in message
news:enS3k9gJEHA.3040@TK2MSFTNGP09.phx.gbl...
> I'm trying to use CFileDialog to allow the user to select an existing
file,
> but it asserts in DoModal because (m_ofn.Flags & OFN_ENABLEHOOK) is ok. If
I
> set that flag, it'll assert because (m_ofn.lpfnHook != NULL) is false. I
> didn't think I needed to provide a hook function. If I do, how should I
> provide it and what should it do?
>
> If I bypass those two asserts, the dialog comes up but displays no files.
> Have I created the filter string incorrectly?
>
> Finally, it dies with an access violation in the destructor. I'm guessing
> this will stop if I fix the other two issues.
>
> I'm developing with VC++6 on Windows XP. Here's my code:
>
> void CWPSched10Task::OnBtnCmdfind()
> {
> CFileDialog dlgFileOpen ( TRUE ) ;
> const uiFilterStringLen = 256 ;
> TCHAR caFilter[uiFilterStringLen] ;
> CString strFilterString ;
> CString strDialogTitle ;
>
> int i = 0 ;
> for ( i=0 ; i<256 ; caFilter[i++]=0 ) {}
>
> strDialogTitle.LoadString ( IDS_SELECTFILETORUN ) ;
> strFilterString.LoadString ( IDS_CMD_FILES ) ; // Just the string
> "Command files"
> _tcscpy ( caFilter, (LPCTSTR)strFilterString ) ;
> _tcscpy ( &(caFilter[_tcslen(caFilter)+1]), _T("cmd") ) ; // Results
in
> "Command files\0cmd\0\0\0\0\0..."
>
> dlgFileOpen.m_ofn.lStructSize = sizeof( OPENFILENAME );
> dlgFileOpen.m_ofn.hwndOwner = this->m_hWnd ;
> dlgFileOpen.m_ofn.Flags = OFN_DONTADDTORECENT |
> OFN_FILEMUSTEXIST |
> OFN_HIDEREADONLY |
> OFN_PATHMUSTEXIST |
> OFN_NOCHANGEDIR ;
> dlgFileOpen.m_ofn.lpstrFilter = caFilter ;
> dlgFileOpen.m_ofn.nFilterIndex = 0 ;
> dlgFileOpen.m_ofn.lpstrInitialDir = _T("") ;
> dlgFileOpen.m_ofn.lpstrTitle = (LPCTSTR)strDialogTitle ;
>
> if ( dlgFileOpen.DoModal() == IDOK )
> {
> // Get the path & store it.
> MessageBox ( _T("Need to store the command"), _T("Development Note"),
> MB_OK ) ;
> }
> }
>
>
- Next message: Ram Baruch: "CreateInstance() works in VC6.0 but not in VC7.0"
- Previous message: Tom Junior: "Re: Drawing arcs"
- In reply to: TVR Fan: "Use of CFileDialog"
- Next in thread: Johan Rosengren: "Re: Use of CFileDialog"
- Reply: Johan Rosengren: "Re: Use of CFileDialog"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|