Re: Use of CFileDialog
From: Johan Rosengren (johan.rosengren_at_telia.com)
Date: 04/20/04
- Next message: Jeff Partch [MVP]: "Re: Accessing/Navigating Tab control of other desktop application using its window Handle"
- Previous message: Jussi Jumppanen: "ANN: zOxygen Documenting Utility"
- In reply to: TVR Fan: "Re: Use of CFileDialog"
- Next in thread: TVR Fan: "Re: Use of CFileDialog"
- Reply: TVR Fan: "Re: Use of CFileDialog"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 20 Apr 2004 12:59:55 +0200
Al,
Can you see the call stack after the crash? Also, the stuff you set, filter,
title and flags can be set in the constructor of the CFileDialog,
simplifying your code a bit (which always helps when tracking down a bug
:-)))
Johan Rosengren
Abstrakt Mekanik AB
"TVR Fan" <nosuch@address.com> a écrit dans le message de
news:Oc9UNWhJEHA.3292@TK2MSFTNGP11.phx.gbl...
> 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: Jeff Partch [MVP]: "Re: Accessing/Navigating Tab control of other desktop application using its window Handle"
- Previous message: Jussi Jumppanen: "ANN: zOxygen Documenting Utility"
- In reply to: TVR Fan: "Re: Use of CFileDialog"
- Next in thread: TVR Fan: "Re: Use of CFileDialog"
- Reply: TVR Fan: "Re: Use of CFileDialog"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|