void COptionsSkinPP::OnOK() { // Enregistre ini UpdateData(TRUE); AfxGetApp()->WriteProfileString("Options", "Skin", strSkinFile); CPropertyPage::OnOK(); CancelToClose(); }
void CDownloadProperties_MirrorsPage::OnAddmirror() { CUrlWithLoginDlg dlg; _DlgMgr.OnDoModal (&dlg); UINT nRet = dlg.DoModal (); _DlgMgr.OnEndDialog (&dlg); if (nRet == IDCANCEL) return; m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->AddMirrorURL (dlg.m_strUrl, dlg.m_strUser, dlg.m_strPassword); FullUpdateMirrList (); CancelToClose (); }
void CDownloadProperties_MirrorsPage::OnRemove() { fs::list <int> v; POSITION pos = m_wndMirrs.GetFirstSelectedItemPosition (); while (pos) v.add (m_wndMirrs.GetNextSelectedItem (pos)); BOOL bAllWasDeleted = TRUE; for (int i = v.size ()-1; i >= 0; i--) { if (m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->RemoveMirror (v [i])) m_wndMirrs.DeleteItem (v [i]); else bAllWasDeleted = FALSE; } CancelToClose (); UpdateEnabled (); if (bAllWasDeleted == FALSE) MessageBox ("Failed to remove mirros(s).\nPlease try again later.", "Failed", MB_OK | MB_ICONEXCLAMATION); }
void CDownloadProperties_MirrorsPage::OnFindmirrors() { if (m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->IsMirrSearchPerformed ()) { MessageBox (LS (L_MIRRSEARCHPERFORMEDALREADY), LS (L_DONE), MB_ICONEXCLAMATION); return; } CWaitDlg dlg; dlg.StartWaiting (LS (L_SEARCHINGFORMIRRORS), _threadFindMirrors, TRUE, this); FullUpdateMirrList (); if (m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->GetFoundMirrorCount ()) { char sz [10000]; sprintf (sz, LS (L_NMIRRORSFOUND), m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->GetFoundMirrorCount ()); MessageBox (sz, LS (L_DONE)); CancelToClose (); } else MessageBox (LS (L_NOMIRRORSFOUND), LS (L_DONE)); }
BOOL FinishPage::OnSetActive () { try { pSheet->SetFinishText (T_(_T("Close"))); if (pSheet->GetErrorFlag()) { CString str; if (! str.LoadString(IDS_FINISH_ERROR)) { UNEXPECTED_CONDITION ("FinishPage::OnSetActive"); } status.SetWindowText (str); if (! str.LoadString(IDS_REMEDY)) { UNEXPECTED_CONDITION ("FinishPage::OnSetActive"); } message.SetWindowText (str); viewReleaseNotes = BST_CHECKED; UpdateData (FALSE); if (! str.LoadString(IDS_VIEW_LOG_FILE)) { UNEXPECTED_CONDITION ("FinishPage::OnSetActive"); } checkBox.SetWindowText (str); } else if (theApp.GetSetupTask() == SetupTask::Download) { CString str; if (! str.LoadString(IDS_DOWNLOAD_COMPLETE)) { UNEXPECTED_CONDITION ("FinishPage::OnSetActive"); } message.SetWindowText (str); viewReleaseNotes = BST_UNCHECKED; UpdateData (FALSE); checkBox.ShowWindow (SW_HIDE); } else { viewReleaseNotes = BST_UNCHECKED; UpdateData (FALSE); } CancelToClose (); return (CPropertyPage::OnSetActive()); } catch (const MiKTeXException & e) { pSheet->ReportError (e); return (FALSE); } catch (const exception & e) { pSheet->ReportError (e); return (FALSE); } }
void CGenPropertyPage::OnAddItem(CDialog & dlg) { // load dialog with default values InitDialog (&dlg); // display dialog, exit if cancelled if (dlg.DoModal () != IDOK) return; // create the object's lookup name (label converted to lower case, or generated) CObject * pItem; CString strObjectName; strObjectName = GetObjectName (&dlg); if (strObjectName.IsEmpty ()) strObjectName.Format ("*%s%s", // e.g. *trigger100 (LPCTSTR) m_strObjectType, (LPCTSTR) App.GetUniqueString ()); else strObjectName.MakeLower(); // if already there (presumably not possible with un-named objects), // then abort the add if (m_ObjectMap->Lookup (strObjectName, pItem)) { CString strMsg; strMsg = TFormat ("The %s named \"%s\" is already in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) GetObjectName (&dlg), (LPCTSTR) m_strObjectType); ::UMessageBox (strMsg); return; } // add new object to map m_ObjectMap->SetAt (strObjectName, pItem = MakeNewObject ()); // unload from dialog into object's properties UnloadDialog (&dlg, pItem); // They can no longer cancel the property sheet, the document has changed CancelToClose (); if (!CheckIfTemporary (pItem)) m_doc->SetModifiedFlag (TRUE); // create a CString for lookup purposes CString * pstrObjectName = new CString (strObjectName); // add this item to the list view add_item (pItem, pstrObjectName, 0, TRUE); SetInternalName (pItem, strObjectName); // set name so we can delete one-shot items // resort the list t_gen_sort_param sort_param (m_ObjectMap, m_last_col, m_reverse, m_CompareObjects); m_ctlList->SortItems (CompareFunc, (LPARAM) &sort_param); // redraw the list if (GetFilterFlag ()) LoadList (); // full reload because it may have changed filter requirements // get dispatch id from the script and put it into the item if (m_doc->m_ScriptEngine) { CString strMessage; SetDispatchID (pItem, m_doc->GetProcedureDispid (GetScriptName (pItem), m_strObjectType, GetLabel (pItem), strMessage)); if (!strMessage.IsEmpty ()) ::UMessageBox (strMessage, MB_ICONINFORMATION); } } // end of CGenPropertyPage::OnAddItem
void CGenPropertyPage::OnDeleteItem() { CUIntArray arySelected; int iCount = m_ctlList->GetSelectedCount (); int nItem, i, iIncluded = 0, iExecuting = 0; arySelected.SetSize (iCount); // first, remember selected items for (nItem = -1, i = 0; (nItem = m_ctlList->GetNextItem(nItem, LVNI_SELECTED)) != -1;) arySelected [i++] = nItem; if (iCount == 0) return; if (App.m_bTriggerRemoveCheck) { // mucking around to make it plural properly CString sName = m_strObjectType; if (iCount > 1) if (sName == "alias") sName += "es"; else sName += "s"; if (::UMessageBox (TFormat ("Delete %i %s - are you sure?", iCount, sName), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES ) return; } // end of wanting to confirm // we do it this way because deleting items buggers up the position in the array for (i = iCount - 1; i >= 0; i--) { nItem = arySelected [i]; // get the lower-case name of this item's object CString * pstrObjectName = (CString *) m_ctlList->GetItemData (nItem); ASSERT (pstrObjectName != NULL); CObject * pItem; // see if in the map if (!m_ObjectMap->Lookup (*pstrObjectName, pItem)) continue; // already deleted! ASSERT_VALID (pItem); ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CObject ) ) ); if (CheckIfIncluded (pItem)) { iIncluded++; // don't do message here in case hundreds of them continue; } if (CheckIfExecuting (pItem)) { iExecuting++; // don't do message here in case hundreds of them continue; } // They can no longer cancel the property sheet, the document has changed CancelToClose (); if (!CheckIfTemporary (pItem)) m_doc->SetModifiedFlag (TRUE); // delete from the map m_ObjectMap->RemoveKey (*pstrObjectName); // delete the item itself delete pItem; // and remove from the dialog list control m_ctlList->DeleteItem (nItem); // delete its item string delete pstrObjectName; } // end of dealing with each selected item if (iIncluded) { CString strMsg; strMsg = TFormat ("%i item%s %s included from an include file. You cannot delete %s here.", PLURAL (iIncluded), iIncluded == 1 ? "was" : "were", iIncluded == 1 ? "it" : "them"); ::UMessageBox (strMsg); } if (iExecuting) { CString strMsg; strMsg = TFormat ("%i item%s %s currently executing a script. You cannot delete %s now.", PLURAL (iExecuting), iExecuting == 1 ? "is" : "are", iExecuting == 1 ? "it" : "them"); ::UMessageBox (strMsg); } } // end of CGenPropertyPage::OnDeleteItem
void CGenPropertyPage::OnChangeItem(CDialog & dlg) { CString strMsg; // iterate through list in case we implement multiple selection one day for (int nItem = -1; (nItem = m_ctlList->GetNextItem(nItem, LVNI_SELECTED)) != -1;) { // get the lower-case name of this item's object CString * pstrObjectName = (CString *) m_ctlList->GetItemData (nItem); ASSERT (pstrObjectName != NULL); CObject * pItem; // check object is still there (it might have gone while we looked at the list box) if (!m_ObjectMap->Lookup (*pstrObjectName, pItem)) { m_ctlList->DeleteItem (nItem); // it's gone, so delete it from the list view m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list // in the case of one-shot timers, unnamed items might be removed from the list if (pstrObjectName->Left (1) == "*") strMsg = TFormat ("The %s you selected is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) m_strObjectType); else strMsg = TFormat ("The %s named \"%s\" is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName, (LPCTSTR) m_strObjectType); ::UMessageBox (strMsg); delete pstrObjectName; // and get rid of its name string continue; } ASSERT_VALID (pItem); ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CObject ) ) ); // load dialog with values from the found item LoadDialog (&dlg, pItem); // put up the dialog, give up if they cancel if (dlg.DoModal () != IDOK) continue; // lookup this object, to make sure it still exists if (!m_ObjectMap->Lookup (*pstrObjectName, pItem)) { m_ctlList->DeleteItem (nItem); // it's gone, so delete it from the list view m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list // in the case of one-shot timers, unnamed items might be removed from the list if (pstrObjectName->Left (1) == "*") strMsg = TFormat ("The %s you selected is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) m_strObjectType); else strMsg = TFormat ("The %s named \"%s\" is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName, (LPCTSTR) m_strObjectType); delete pstrObjectName; // and get rid of its name string ::UMessageBox (strMsg); continue; } ASSERT_VALID (pItem); ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CObject ) ) ); if (CheckIfIncluded (pItem)) { strMsg = TFormat ("The %s named \"%s\" has been included from an include file. You cannot modify it here.", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName); ::UMessageBox (strMsg); return; // can't modify included items } // check object still has the same modification number // (it might have been modified while we looked at the list box) if (GetModificationNumber (pItem) != m_nUpdateNumber) { strMsg = TFormat ("The %s named \"%s\" has already been modified by a script subroutine", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName); ::UMessageBox (strMsg); continue; } // check for name change CString strObjectName = GetObjectName (&dlg); if (strObjectName.IsEmpty ()) strObjectName.Format ("*%s%s", (LPCTSTR) m_strObjectType, (LPCTSTR) App.GetUniqueString ()); else strObjectName.MakeLower (); if (strObjectName != *pstrObjectName) // has name changed? { // here if label has changed CObject * new_pItem; if (m_ObjectMap->Lookup (strObjectName, new_pItem)) { strMsg = TFormat ("The %s named \"%s\" already exists in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) strObjectName, (LPCTSTR) m_strObjectType); ::UMessageBox (strMsg); continue; } // remove old entry and re-add under new name m_ObjectMap->RemoveKey (*pstrObjectName); // remove old entry m_ObjectMap->SetAt (strObjectName, pItem); // insert under new name // delete old name in the list delete pstrObjectName; // create a new CString for lookup purposes pstrObjectName = new CString (strObjectName); // record item's new name as the list object data m_ctlList->SetItemData(nItem, (DWORD) pstrObjectName); } // end of label changing // see if the user changed anything, anyway if (CheckIfChanged (&dlg, pItem)) { // unload from dialog into object's properties UnloadDialog (&dlg, pItem); // They can no longer cancel the property sheet, the document has changed CancelToClose (); if (!CheckIfTemporary (pItem)) m_doc->SetModifiedFlag (TRUE); // re-setup list with amended details int nNewItem = add_item (pItem, pstrObjectName, nItem, FALSE); m_ctlList->RedrawItems (nNewItem, nNewItem); } // end of item changing // Get dispatch id from the script and put it into the item. // We do this even if nothing has changed, so that we can force re-evaluation // of the dispatch ID, by just getting the item and pressing OK. if (m_doc->m_ScriptEngine) { CString strMessage; SetDispatchID (pItem, m_doc->GetProcedureDispid (GetScriptName (pItem), m_strObjectType, GetLabel (pItem), strMessage)); if (!strMessage.IsEmpty ()) ::UMessageBox (strMessage, MB_ICONINFORMATION); } } // end of dealing with each selected item // redraw the list if (GetFilterFlag ()) LoadList (); // full reload because it may have changed filter requirements // resort the list t_gen_sort_param sort_param (m_ObjectMap, m_last_col, m_reverse, m_CompareObjects); m_ctlList->SortItems (CompareFunc, (LPARAM) &sort_param); } // end of CGenPropertyPage::OnChangeItem
BOOL CRenameComplete::OnSetActive() { // TODO: Add your specialized code here and/or call the base class CWnd *parent = GetParent (); if (parent->IsKindOf ( RUNTIME_CLASS( CPropertySheet )) ) { ((CPropertySheet*)parent)->SetWizardButtons (PSWIZB_FINISH); } if (m_fromList && m_toList) { m_comTrol.SetExtendedStyle (LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_FLATSB); m_comTrol.InsertColumn(0, "Renamed?", LVCFMT_LEFT, 80, 1); m_comTrol.InsertColumn(1, "From Files", LVCFMT_LEFT, 260, 2); m_comTrol.InsertColumn(2, "To Files", LVCFMT_LEFT, 260, 3); int i = 0; POSITION fromPos = m_fromList->GetHeadPosition (); POSITION toPos = m_toList->GetHeadPosition (); while (fromPos && toPos) { m_comTrol.InsertItem (i, (LPCTSTR) m_fromList->GetAt (fromPos)); m_comTrol.SetItemText (i, 0, _T("")); m_comTrol.SetItemText (i, 1, (LPCTSTR) m_fromList->GetAt (fromPos)); m_comTrol.SetItemText(i, 2, (LPCTSTR) m_toList->GetAt (toPos)); m_fromList->GetNext (fromPos); m_toList->GetNext (toPos); i++; } i = 0; CWaitCursor waitc; fromPos = m_fromList->GetHeadPosition (); toPos = m_toList->GetHeadPosition (); while (fromPos && toPos) { int rstat = _trename ((LPCTSTR) m_fromList->GetAt (fromPos), (LPCTSTR) m_toList->GetAt (toPos)); switch (rstat) { case 0: m_comTrol.SetItemText (i, 0, _T("X")); break; case EACCES : m_comTrol.SetItemText (i, 0, _T("AD")); break; case ENOENT : m_comTrol.SetItemText (i, 0, _T("NF")); break; case EINVAL: m_comTrol.SetItemText (i, 0, _T("IV")); break; default: m_comTrol.SetItemText (i, 0, _T("?")); break; } m_comTrol.RedrawWindow (); m_fromList->GetNext (fromPos); m_toList->GetNext (toPos); i++; } } if (parent->IsKindOf ( RUNTIME_CLASS( CPropertySheet )) ) { ((CPropertySheet*)parent)->SetFinishText ("All Done."); } CancelToClose (); return CPropertyPage::OnSetActive(); }