CUString COpenFileDlg::GetSubPath( POSITION pos ) { if ( !m_bKeepDirLayout ) { return _T( "" ); } CUString strRet = GetNextPathName( pos ); int nStartPos = strRet.Find( m_strDir ); int nLength = strRet.ReverseFind( _T( '\\' ) ) + 1; if ( nStartPos >= 0 ) { nStartPos += 1 + m_strDir.GetLength(); } nLength -= nStartPos; if ( nLength < 0 ) { nLength = 0; } strRet = strRet.Mid( nStartPos, nLength ); return strRet; }
CUString COpenFileDlg::GetFileName( POSITION pos ) { CUString strRet = GetNextPathName( pos ); int nPos = strRet.ReverseFind('\\'); if ( nPos >= 0 ) { strRet = strRet.Mid( nPos + 1 ); } return strRet; }
BOOL CFileEditCtrl::FECBrowseForFolder() { // Set up and call SHBrowseForFolder(). // return TRUE if user clicks OK, return FALSE otherwise BOOL bReturnValue = FALSE; BOOL bProcedure = TRUE; // assume user of this class has set a callback procedure BOOL bDisplay = TRUE; // assume user of this class has set a DisplayName TCHAR lpstrDisplay[_MAX_PATH]; if (!m_pBROWSEINFO->pszDisplayName) // user has not set a display name { // flag it, and use our own buffer bDisplay = FALSE; m_pBROWSEINFO->pszDisplayName = lpstrDisplay; } CString szPath; LPARAM oldLP = m_pBROWSEINFO->lParam; if (!m_pBROWSEINFO->lpfn) // user has not set a callback procedure { // flag it, and use the default procedure bProcedure = FALSE; POSITION pos = GetStartPosition(); if (pos) szPath = GetNextPathName(pos); // get the path in the edit control m_pBROWSEINFO->lParam = (LPARAM)(LPCTSTR)szPath; // set lParam to point to szPath m_pBROWSEINFO->lpfn = FECFolderProc; // set the callback procedure } ITEMIDLIST *idl = SHBrowseForFolder (m_pBROWSEINFO); if (idl) { if(SHGetPathFromIDList (idl, lpstrDisplay)) // get path string from ITEMIDLIST { SetWindowText(lpstrDisplay); // update edit control bReturnValue = TRUE; } LPMALLOC lpm; if (SHGetMalloc (&lpm) == NOERROR) lpm->Free(idl); // free memory returned by SHBrowseForFolder } if (!bDisplay) // reset m_pBROWSEINFO to clear the DisplayName m_pBROWSEINFO->pszDisplayName = NULL; if (!bProcedure) // reset m_pBROWSEINFO to clear the default callback proc. { m_pBROWSEINFO->lpfn = NULL; m_pBROWSEINFO->lParam = oldLP; } SetFocus(); // ensure focus returns to this control return bReturnValue; }
BOOL CFileEditCtrl::FECOpenFile() { // Set up the CFileDialog and call CFileDialog::DoModal(). // return TRUE if the user clicked the OK button, return FALSE otherwise BOOL bReturnValue = FALSE; BOOL bDirectory = TRUE; // assume user of this class has set the initial directory TCHAR lpstrDirectory[_MAX_PATH] = _T(""); if (m_pCFileDialog->m_ofn.lpstrInitialDir == NULL) // user has not set the initial directory { // flag it, set initial directory to bDirectory = FALSE; // directory in edit control POSITION pos = GetStartPosition(); if (pos) _tcscpy(lpstrDirectory, GetNextPathName(pos)); m_pCFileDialog->m_ofn.lpstrInitialDir = lpstrDirectory; } if (m_pCFileDialog->DoModal() == IDOK) // Start the CFileDialog { // user clicked OK, enter files selected into edit control CString szFileSeperator; #if defined FEC_NORESOURCESTRINGS szFileSeperator = (CString)FEC_IDS_SEPERATOR; #else szFileSeperator.LoadString(FEC_IDS_SEPERATOR); #endif ASSERT (_tcslen(szFileSeperator) == 1); // must be one character only szFileSeperator += _T(" "); CString szPath; POSITION pos = m_pCFileDialog->GetStartPosition(); if (pos) szPath = m_pCFileDialog->GetNextPathName(pos); // first file has complete path while (pos) { CString szTempPath = m_pCFileDialog->GetNextPathName(pos); TCHAR lpstrName[_MAX_PATH]; // remaining files are name and extension only TCHAR lpstrExt[_MAX_PATH]; _tsplitpath(szTempPath, NULL, NULL, lpstrName, lpstrExt); szPath += szFileSeperator + lpstrName + lpstrExt; } SetWindowText (szPath); bReturnValue = TRUE; } if (!bDirectory) // reset OPENFILENAME m_pCFileDialog->m_ofn.lpstrInitialDir = NULL; SetFocus(); // ensure focus returns to this control return bReturnValue; }
void CPictureCatalogDialog::do_print() { // Set our title so that the user will know what is being printed. m_pDoc->SetTitle(GET_PMWAPP()->GetResourceStringPointer (IDS_PICTURES)); CPrintInfo pInfo; CPrintDialog *dlg_save = pInfo.m_pPD; CCatalogPrint pdlg(m_pDoc); pInfo.m_pPD = &pdlg; // Bring over the list. if (AfxGetApp()->DoPrintDialog(&pdlg) == IDOK) { // get all the filenames they selected POSITION pos = GetStartPosition(); CStringArray files; while (pos != NULL) { CString file = GetNextPathName(pos); files.Add(file); } CString strDir = GetPathName(); CCatalogView view(files, strDir); m_pDoc->m_bAutoDelete = FALSE; // don't destroy document while closing views m_pDoc->size_to_paper(); // Hook the view into the document. ((CCatalogDoc *)m_pDoc)->add_hidden_view(&view); // Print the project. view.PrintProject(&pInfo); // Remove the view before its destructor happens. m_pDoc->RemoveView(&view); } pInfo.m_pPD = dlg_save; }
W64INT CMultiFileDlg::DoModal() { m_OwnTemplate = m_ExStyle & ES_SHOWPREVIEW; if (m_OwnTemplate) { m_ofn.Flags |= OFN_ENABLETEMPLATE; m_ofn.hInstance = AfxGetApp()->m_hInstance; m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_MULTI_FILE); } CString Buffer; if (m_ofn.Flags & OFN_ALLOWMULTISELECT) { const int BUFSIZE = 0x7fff; LPTSTR FileBuf = Buffer.GetBufferSetLength(BUFSIZE); ZeroMemory(FileBuf, BUFSIZE); m_ofn.lpstrFile = FileBuf; m_ofn.nMaxFile = BUFSIZE; m_ofn.nFileOffset = 0; } if (!m_Title.IsEmpty()) m_ofn.lpstrTitle = m_Title; if (m_psFolder != NULL) { m_ofn.lpstrInitialDir = *m_psFolder; m_ofn.Flags |= OFN_NOCHANGEDIR; // otherwise folder stays locked } W64INT retc = CFileDialog::DoModal(); if (retc == IDOK) { m_Path.RemoveAll(); if (m_ofn.Flags & OFN_ALLOWMULTISELECT) { POSITION FilePos = GetStartPosition(); while (FilePos != NULL) m_Path.Add(GetNextPathName(FilePos)); } else m_Path.Add(GetPathName()); if (m_psFolder != NULL) GetFolder(*m_psFolder); } return(retc); }