// prompt for file name - used for open and save as // static function called from app BOOL CWordPadApp::PromptForFileName(CString& fileName, UINT nIDSTitle, DWORD dwFlags, BOOL bOpenFileDialog, int* pType) { ScanForConverters(); CFileDialog dlgFile(bOpenFileDialog); CString title; VERIFY(title.LoadString(nIDSTitle)); dlgFile.m_ofn.Flags |= dwFlags; // dlgFile.m_ofn.Flags &= ~OFN_SHOWHELP; int nIndex = m_nFilterIndex; if (!bOpenFileDialog) { int nDocType = (pType != NULL) ? *pType : RD_DEFAULT; nIndex = GetIndexFromType(nDocType, bOpenFileDialog); if (nIndex == -1) nIndex = GetIndexFromType(RD_DEFAULT, bOpenFileDialog); if (nIndex == -1) nIndex = GetIndexFromType(RD_NATIVE, bOpenFileDialog); ASSERT(nIndex != -1); nIndex++; } dlgFile.m_ofn.nFilterIndex = nIndex; // strDefExt is necessary to hold onto the memory from GetExtFromType CString strDefExt = GetExtFromType(GetTypeFromIndex(nIndex-1, bOpenFileDialog)); dlgFile.m_ofn.lpstrDefExt = strDefExt; CString strFilter = GetFileTypes(bOpenFileDialog); dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); BOOL bRet = (dlgFile.DoModal() == IDOK) ? TRUE : FALSE; fileName.ReleaseBuffer(); if (bRet) { if (bOpenFileDialog) m_nFilterIndex = dlgFile.m_ofn.nFilterIndex; if (pType != NULL) { int nIndex2 = (int)dlgFile.m_ofn.nFilterIndex - 1; ASSERT(nIndex2 >= 0); *pType = GetTypeFromIndex(nIndex2, bOpenFileDialog); } } return bRet; }
BOOL ntCommonDlg::PromptForFileName(CString& fileName, UINT, DWORD dwFlags, BOOL bOpenFileDialog, int* pType) { CFileDialog dlgFile(bOpenFileDialog); CString title; if (bOpenFileDialog) { title=_T("Open image file"); } else { title=_T("Save image file"); } dlgFile.m_ofn.Flags |= dwFlags; int nDocType = (pType != NULL) ? *pType : CXIMAGE_FORMAT_BMP; if (nDocType==0) { nDocType=1; } int nIndex = GetIndexFromType(nDocType, bOpenFileDialog); if (nIndex == -1) { nIndex = 0; } dlgFile.m_ofn.nFilterIndex = nIndex +1; CString strDefExt = GetExtFromType(nDocType).Mid(2,3); dlgFile.m_ofn.lpstrDefExt = strDefExt; CString strFilter = GetFileTypes(bOpenFileDialog); dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); BOOL bRet = (dlgFile.DoModal() == IDOK) ? TRUE : FALSE; fileName.ReleaseBuffer(); if (bRet) { if (pType != NULL) { int nIndex = (int)dlgFile.m_ofn.nFilterIndex - 1; ASSERT(nIndex >= 0); *pType = GetTypeFromIndex(nIndex, bOpenFileDialog); } } return bRet; }
void CSourcesListBox::AddMissing( const wxArrayString & playlists ,EMUSIK_SOURCES_TYPE t) { wxString sExt, sName, sAdd,sTypeExt; sTypeExt = GetExtFromType(t); GetTypeAsString( t, sAdd); for ( size_t i = 0; i < playlists.GetCount(); i++ ) { sName = playlists.Item( i ); sExt = sName.Right( 3 ); sExt.MakeLower(); if ( sExt != sTypeExt ) { continue; } sName = sName.Left( sName.Length() - 4 ); sName.Replace( wxT( "_" ), wxT( " " ), true ); if ( FindInSources( sName, t ) == -1 ) m_SourcesList.Add( sAdd + sName); } }
BOOL CWordPadDoc::DoSave(LPCTSTR pszPathName, BOOL bReplace /*=TRUE*/) // Save the document data to a file // pszPathName = path name where to save document file // if pszPathName is NULL then the user will be prompted (SaveAs) // note: pszPathName can be different than 'm_strPathName' // if 'bReplace' is TRUE will change file name if successful (SaveAs) // if 'bReplace' is FALSE will not change path name (SaveCopyAs) { CString newName = pszPathName; int nOrigDocType = m_nDocType; //saved in case of SaveCopyAs or failure // newName bWrite type result // empty TRUE - SaveAs dialog // empty FALSE - SaveAs dialog // notempty TRUE - nothing // notempty FALSE W6 warn (change to wordpad, save as, cancel) // notempty FALSE other warn (save as, cancel) BOOL bModified = IsModified(); ScanForConverters(); BOOL bSaveAs = FALSE; if (newName.IsEmpty()) bSaveAs = TRUE; else if (!doctypes[m_nDocType].bWrite) { if (m_nDocType == RD_WINWORD6) { // DWORD nHelpIDs[] = // { // 0, 0 // }; int nRes = CButtonDialog::DisplayMessageBox( MAKEINTRESOURCE(IDS_WORD6_WARNING), AfxGetAppName(), MAKEINTRESOURCE(IDS_WORD6_WARNING_BUTTONS), MB_ICONQUESTION, 1, 2); if (nRes == 0) // Save SetDocType(RD_WORDPAD, TRUE); else if (nRes == 2) // Cancel return FALSE; else bSaveAs = TRUE; // else save as } else // { if (AfxMessageBox(IDS_SAVE_UNSUPPORTED, MB_YESNO | MB_ICONQUESTION) != IDYES) { return FALSE; } else bSaveAs = TRUE; } } if (m_lpRootStg == NULL && IsTextType(m_nDocType) && !GetView()->IsFormatText()) { // formatting changed in plain old text file DWORD nHelpIDs[] = { 0, IDH_WORDPAD_WORD6FILE, 0, IDH_WORDPAD_FORMATTED, 0, IDH_WORDPAD_TEXTFILE, 0, 0 }; CString str; AfxFormatString1(str, IDS_SAVE_FORMAT_TEXT, GetTitle()); int nRes = CButtonDialog::DisplayMessageBox(str, MAKEINTRESOURCE(AFX_IDS_APP_TITLE), MAKEINTRESOURCE(IDS_TF_BUTTONS), MB_ICONQUESTION, 0, 3, nHelpIDs); if (nRes == 3) return FALSE; int nDocType = (nRes == 0) ? RD_DEFAULT: //Word 6 (nRes == 1) ? RD_RICHTEXT : //RTF RD_TEXT; //text if (IsTextType(m_nDocType) && nDocType != RD_TEXT) SetDocType(nDocType, TRUE); if (nDocType != RD_TEXT) bSaveAs = TRUE; } GetView()->GetParentFrame()->RecalcLayout(); if (bSaveAs) { newName = m_strPathName; if (bReplace && newName.IsEmpty()) { newName = m_strTitle; int iBad = newName.FindOneOf(_T(" #%;/\\")); // dubious filename if (iBad != -1) newName.ReleaseBuffer(iBad); // append the default suffix if there is one newName += GetExtFromType(m_nDocType); } int nDocType = m_nDocType; if (!theApp.PromptForFileName(newName, bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, &nDocType)) { SetDocType(nOrigDocType, TRUE); return FALSE; // don't even try to save } SetDocType(nDocType, TRUE); } BeginWaitCursor(); if (!OnSaveDocument(newName)) { if (pszPathName == NULL) { // be sure to delete the file TRY { CFile::Remove(newName); } CATCH_ALL(e) { TRACE0("Warning: failed to delete file after failed SaveAs\n"); } END_CATCH_ALL } // restore orginal document type SetDocType(nOrigDocType, TRUE); EndWaitCursor(); return FALSE; }
BOOL CReportPictureProperties::OnInitDialog() /* ============================================================ Function : CReportPictureProperties::OnInitDialog Description : Handler for the "WM_INITDIALOG" messag Access : Protected Return : BOOL - Always "TRUE" Parameters : none Usage : Called from MFC ============================================================*/ { CDialog::OnInitDialog(); COptionTreeItem *otiRoot = NULL; COptionTreeItem *otiItem = NULL; CRect rcClient; DWORD dwStyle, dwOptions; LOGFONT lfFont, lfDefaultFont; // Get log fonts GetFont()->GetLogFont(&lfFont); GetFont()->GetLogFont(&lfDefaultFont); //strcpy(lfDefaultFont.lfFaceName, _T("Arial"));#OBSOLETE strcpy_s(lfDefaultFont.lfFaceName,sizeof(lfDefaultFont.lfFaceName), _T("Arial")); // Get the clients rectangle GetClientRect(rcClient); // Setup the window style dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Setup the tree options // OT_OPTIONS_SHOWINFOWINDOW dwOptions = OT_OPTIONS_SHADEEXPANDCOLUMN | OT_OPTIONS_SHADEROOTITEMS | OT_OPTIONS_SHOWINFOWINDOW; int trBot=rcClient.bottom; if (GetDlgItem(IDOK)) { CRect rrrr; GetDlgItem(IDOK)->GetWindowRect(rrrr); ScreenToClient(rrrr); trBot = rrrr.top -4; } // Create tree options CRect trR = rcClient; trR.bottom = trBot; if (m_otTree.Create(dwStyle, trR, this, dwOptions, 1004) == FALSE) { TRACE0("Failed to create options control.\r\n"); return FALSE; } // Want to be notified m_otTree.SetNotify(TRUE, this); // -- Edit Items CString resStr; otiRoot = m_otTree.InsertItem(new COptionTreeItem()); resStr.LoadString(IDS_REP_COMMON_PROPS); otiRoot->SetLabelText(resStr); resStr.LoadString(IDS_REP_FULL_COMMON_PROPS); otiRoot->SetInfoText(resStr); m_otiFile = (COptionTreeItemFile*)m_otTree.InsertItem(new COptionTreeItemFile(), otiRoot); resStr.LoadString(IDS_REP_PR_FILE); m_otiFile->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_FULL_FILE); m_otiFile->SetInfoText(resStr); if (m_otiFile->CreateFileItem("",GetExtFromType(0).Mid(2,3),GetFileTypes(TRUE), OT_FILE_OPENDIALOG | OT_FILE_SHOWFULLPATH, OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY | OFN_FILEMUSTEXIST) == TRUE) { } otiRoot->Expand(); otiRoot = m_otTree.InsertItem(new COptionTreeItem()); resStr.LoadString(IDS_REP_PR_DL_FRAME); otiRoot->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_FRAME); otiRoot->SetInfoText(resStr); CString yesS; yesS.LoadString(IDS_YES); CString noS; noS.LoadString(IDS_NO); m_otiExistLeft = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_LEFT); m_otiExistLeft->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_LEFT); m_otiExistLeft->SetInfoText(resStr); if (m_otiExistLeft->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_LEFT, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistLeft->SetCheckText(yesS, noS); } m_otiExistRight = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_RIGHT); m_otiExistRight->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_RIGHT); m_otiExistRight->SetInfoText(resStr); if (m_otiExistRight->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_RIGHT, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistRight->SetCheckText(yesS, noS); } m_otiExistTop = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_TOP); m_otiExistTop->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_TOP); m_otiExistTop->SetInfoText(resStr); if (m_otiExistTop->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_TOP, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistTop->SetCheckText(yesS, noS); } m_otiExistBottom = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_BOTTOM); m_otiExistBottom->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_BOTTOM); m_otiExistBottom->SetInfoText(resStr); if (m_otiExistBottom->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_BOTTOM, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistBottom->SetCheckText(yesS, noS); } m_otiFrameColorCombo = (COptionTreeItemColorComboBox*)m_otTree.InsertItem(new COptionTreeItemColorComboBox(), otiRoot); resStr.LoadString(IDS_PER_PR_DL_COL_FR); m_otiFrameColorCombo->SetLabelText(resStr); resStr.LoadString(IDS_PER_PR_DL_FULL_COL_FR); m_otiFrameColorCombo->SetInfoText(resStr); if (m_otiFrameColorCombo->CreateComboItem(NULL) == TRUE) { m_otiFrameColorCombo->SetCurColor(m_borderColor); } m_otiFrameThicknessCombo = (COptionTreeItemLineThikComboBox*)m_otTree.InsertItem(new COptionTreeItemLineThikComboBox(), otiRoot); resStr.LoadString(IDS_PER_PR_DL_TH_FR); m_otiFrameThicknessCombo->SetLabelText(resStr); resStr.LoadString(IDS_PER_PR_DL_FULL_TH_FR); m_otiFrameThicknessCombo->SetInfoText(resStr); if (m_otiFrameThicknessCombo->CreateComboItem(NULL) == TRUE) { m_otiFrameThicknessCombo->SetLineThickness(m_borderThickness); } otiRoot->Expand(); return TRUE; }