Hi,
I am trying to update my application from vs2005 to vs2012. I am using CFiledialog with multiple file selection flag.
bVistaStyles is set to true. when i run my application on windows 7 system ,it gives access violation.
The problem occurs in the following line. GetParent()->m_hWnd shows null. Why?
UINT nfiles = CommDlg_OpenSave_GetSpec(GetParent()->m_hWnd, &dummy_buffer, 1);
CMultipleFileDialog is derived from CFileDialog
CMultipleFileDialog::CMultipleFileDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd,DWORD dwSize,BOOL m_bVistaStyle) :
CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd,dwSize,m_bVistaStyle)
CMultipleFileDialog dlg(TRUE,sDefExt,NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER ,filter,theApp.m_pMainWnd,NULL,TRUE);
void CMultipleFileDialog::OnFileNameChange()
{
TCHAR dummy_buffer;
// Get the required size for the 'files' buffer
UINT nfiles = CommDlg_OpenSave_GetSpec(GetParent()->m_hWnd, &dummy_buffer, 1);
// Get the required size for the 'folder' buffer
UINT nfolder = CommDlg_OpenSave_GetFolderPath(theMainFrame->m_hWnd, &dummy_buffer, 1);
// Check if lpstrFile and nMaxFile are large enough
if (nfiles + nfolder > m_ofn.nMaxFile)
{
bParsed = FALSE;
if (Files)
delete[] Files;
Files = new TCHAR[nfiles + 1];
CommDlg_OpenSave_GetSpec(theMainFrame->m_hWnd, Files, nfiles);
if (Folder)
delete[] Folder;
Folder = new TCHAR[nfolder + 1];
CommDlg_OpenSave_GetFolderPath(theMainFrame->m_hWnd, Folder, nfolder);
}