--- cedtorig/cedtAppFile.cpp Fri Nov 12 08:37:00 2004 +++ ./cedtAppFile.cpp Wed Jan 3 14:09:52 2007 @@ -12,12 +12,29 @@ CString szFilter = GetComposedFileFilter(); CFileDialog dlg(TRUE, NULL, NULL, dwFlags, szFilter); - TCHAR szCurrentDirectory[MAX_PATH]; - GetCurrentDirectory( MAX_PATH, szCurrentDirectory ); + + // CHANGE BY LARSP JAN 2007 + // + // NOW: File open defaults to selected file path, otherwise Windows gets to choose + TCHAR szBuffer[4096]; memset(szBuffer, 0x00, sizeof(szBuffer)); dlg.m_ofn.lpstrFile = szBuffer; dlg.m_ofn.nMaxFile = 4096; - dlg.m_ofn.lpstrInitialDir = szCurrentDirectory; + + // get active document + CMainFrame * pMainFrame = (CMainFrame *)AfxGetMainWnd(); ASSERT( pMainFrame ); + CCedtDoc * pDoc = (CCedtDoc *)pMainFrame->MDIGetActiveDocument(); + CString szFile; + + // if such exists, and if it has a path, use that as default + if (pDoc != NULL) { + szFile = pDoc->GetPathName(); + if (szFile.GetLength() > 0) { + szFile = GetFileDirectory(szFile); + dlg.m_ofn.lpstrInitialDir = szFile; + } + } + dlg.m_ofn.nFilterIndex = GetFilterIndexDialog() + 1; if( dlg.DoModal() != IDOK ) return;