void TestRunnerDlg::OnSelchangeComboTest() { CComboBox *testsSelection = (CComboBox *)GetDlgItem (IDC_COMBO_TEST); int currentSelection = testsSelection->GetCurSel (); if (currentSelection >= 0 && currentSelection < _tests.size ()) { _selectedTest = (_tests.begin () + currentSelection)->pTest; beIdle (); CWinApp* pApp = AfxGetApp(); pApp->WriteProfileString("Tests", "lastTest", _selectedTest->toString().c_str()); } else { _selectedTest = 0; beRunDisabled (); } freeState (); reset (); }
LRESULT CNewProj::OnWizardNext() { CString st,stp=""; char tempo[8192]; GetDlgItemText(IDC_projpath,stp); if (st.GetLength() > MAX_PATH) { return -1; } strcpybuff(tempo,stp); if ((tempo[strlen(tempo)-1]=='/') || (tempo[strlen(tempo)-1]=='\\')) tempo[strlen(tempo)-1]='\0'; stp=tempo; // ecrire CString strSection = "DefaultValues"; CWinApp* pApp = AfxGetApp(); pApp->WriteProfileString(strSection,"BasePath",stp); GetDlgItemText(IDC_projname,st); if (st.GetLength() > MAX_PATH) { return -1; } st.TrimLeft(); st.TrimRight(); strcpybuff(tempo,st); // caractères interdits { int i; char* a=NULL; for(i=0;i<9;i++) while(a=strchr(tempo,("\\/:*?\"<>|")[i])) *a=' '; } // //while(a=strchr(tempo,' ')) *a='_'; // PAS de _ SetDlgItemTextCP(this, IDC_projname,tempo); // Modifié et sauvable GetDlgItemText(IDC_projpath,stp); if (stp.GetLength() > MAX_PATH) { return -1; } if ((stp.Right(1)!="\\") && (stp.Right(1)!="/")) // ajouter / stp+="\\"; GetDlgItemText(IDC_projname,st); if (st.GetLength() > MAX_PATH) { return -1; } this_CSplitterFrame->SetNewName(stp+st+".whtt"); //GetDlgItemText(IDC_projpath,st); //this_CSplitterFrame->GetActiveDocument()->SetPathName(st); // Hack { CString st; GetDlgItemText(IDC_projcateg, st); if (st.GetLength() > MAX_PATH) { return -1; } this_CSplitterFrame->SetCurrentCategory(st); } if (can_click_next) return 0; else return -1; }
void CDlgSetStockAndTime::OnOK() { // TODO: Add extra validation here if( m_curSelStockCondition != NULL ) { // 日期范围 // 计算终止日期 CString str; CTime timeEnd; if (m_curSelStockCondition->m_dStyle & SelectStock_HisDate) { m_wndEndDate.GetTime( timeEnd ); str.Format("%04d%02d%02d",timeEnd.GetYear(),timeEnd.GetMonth(),timeEnd.GetDay()); } else//yulx add 20091207 { SYSTEMTIME tm; GetLocalTime(&tm); str.Format("%04d%02d%02d",tm.wYear,tm.wMonth,tm.wDay); } m_curSelStockCondition->m_lEndDate = atol(str); // 计算日期长度 if( m_curSelStockCondition->m_dStyle & SelectStock_HisDate ) { CTime timeBegin; m_wndBeginDate.GetTime( timeBegin ); CTimeSpan nSpan = timeEnd - timeBegin; if( (nSpan.GetDays() + 1) <= 0 ) { //AfxMessageBox(CDlgSetStockAndTime_Begin_End_Date_Error); MessageBox(CDlgSetStockAndTime_Begin_End_Date_Error,_T(" 提示 "), MB_OK); m_wndBeginDate.SetFocus(); return; } str.Format("%04d%02d%02d",timeBegin.GetYear(),timeBegin.GetMonth(),timeBegin.GetDay()); m_curSelStockCondition->m_lDateCount = atol(str);//nSpan.GetDays(); } else { m_curSelStockCondition->m_lDateCount = 0; } } // save - begin CWinApp* pApp = AfxGetApp(); // 时间 CString str; if( m_curSelStockCondition ) { str.Format("%i;%i",m_curSelStockCondition->m_lDateCount,m_curSelStockCondition->m_lEndDate); } pApp->WriteProfileString(CDlgSetStockAndTime_Section, CDlgSetStockAndTime_Time,str); // 股票范围 str = ""; CString strTemp; StockArea* pCheckData; for( int i = 0; m_ayCheck && i < m_ayCheck->GetSize(); i++ ) { pCheckData = m_ayCheck->GetAt(i); strTemp.Format("%i,%s",pCheckData->lData,pCheckData->strText); str += strTemp; str += ";"; } pApp->WriteProfileString(CDlgSetStockAndTime_Section, CDlgSetStockAndTime_Stock,str); // 选项 if( m_curSelStockCondition ) { pApp->WriteProfileInt(CDlgSetStockAndTime_Section, CDlgSetStockAndTime_Option,m_curSelStockCondition->m_dStyle); } // save - end CDialog::OnOK(); }
BOOL CProgramSettings::SaveToRegistry() { // Save Class Members To Registry int k; char szKey[32]; char szValue[256]; CWinApp* pApp = AfxGetApp(); SaveServerToRegistry("Settings"); pApp->WriteProfileInt ("Settings","Disclaimer", m_Disclaimer); pApp->WriteProfileInt ("Settings","BandwidthCap", m_nBandwidthCap); pApp->WriteProfileInt ("Settings","MaxLines", m_nMaxLines); pApp->WriteProfileInt ("Settings","HL_Last", m_bHighlightCurrentFile); pApp->WriteProfileInt ("Settings","SortOnAdd", m_bSortFilesOnAdd); pApp->WriteProfileInt ("Settings","SysTray", m_bSysTrayIcon); pApp->WriteProfileInt ("Settings","AutoRetry", m_bAutoRetry); pApp->WriteProfileInt ("Settings","DetectPAR2", m_bDetectPAR2); pApp->WriteProfileInt ("Settings","AutoShowProgress", m_bShowProgressDialogOnStart); pApp->WriteProfileInt ("Settings","XNoArchiveHeader", m_bXNoArchiveHeader); pApp->WriteProfileInt ("Settings","XServerDate", m_bXServerDate); pApp->WriteProfileInt ("Settings","HeaderPartial", m_bHeaderPartial); pApp->WriteProfileInt ("Settings","FileThread", m_bFileThread); pApp->WriteProfileString("Settings","H_From", m_szFrom); pApp->WriteProfileString("Settings","H_FromNick", m_szFromNick); pApp->WriteProfileString("Settings","H_ReplyTo", m_szReplyTo); pApp->WriteProfileString("Settings","H_Org", m_szOrganization); pApp->WriteProfileString("Settings","H_Followup", m_szFollowupTo); pApp->WriteProfileString("Settings","H_DomainID", m_szDomainID); pApp->WriteProfileString("Settings","LastDir", m_szLastAddDir); pApp->WriteProfileString("Settings","LastTempl_yEnc", m_szLastSubjectTemplate); pApp->WriteProfileInt ("Settings","CheckStop", m_nCheckStop); pApp->WriteProfileString("Settings","Skin", m_szSkin); sprintf(szValue, "%d:%d:%d:%d", m_nViewColWid[0], m_nViewColWid[1], m_nViewColWid[2], m_nViewColWid[3]); pApp->WriteProfileString("Settings","ViewColWid", szValue); sprintf(szValue, "%d:%d:%d", m_nStartTimeSel[0], m_nStartTimeSel[1], m_nStartTimeSel[2]); pApp->WriteProfileString("Settings","StartTime", szValue); sprintf(szValue, "%d:%d:%d", m_nStopTimeSel[0], m_nStopTimeSel[1], m_nStopTimeSel[2]); pApp->WriteProfileString("Settings","StopTime", szValue); pApp->WriteProfileInt("Settings","GrpListSize", m_GroupList.GetSize()); for(k = 0; k < m_GroupList.GetSize(); k++) { sprintf(szKey, "GrpList_%04d", k); pApp->WriteProfileString("Settings", szKey, (LPCTSTR) m_GroupList.GetAt(k)); } for (k = 0; k < NSERVERS; k++) { sprintf(szKey,"Server%d",k); servers[k].SaveServerToRegistry(szKey); } return TRUE; }
void CLogin::OnLoginRemove() { int count = m_ListBox.GetSelectedCount(); //someone hit remove without selecting something to remove. if(0 == count) return; ASSERT(1 == count); if(AfxMessageBox("Do you want to delete the selected login data?", MB_YESNO) != IDYES) return; POSITION POS = m_ListBox.GetFirstSelectedItemPosition(); int i = m_ListBox.GetNextSelectedItem(POS); CWinApp* pApp = AfxGetApp(); UINT latest = pApp->GetProfileInt("History", "Latest", 0); //latest should never be 0 if there was something to remove. //nevertheless, if it is 0 we should return and do nothing. if(0 == latest) { ASSERT(1); return; } CString name, host, zone, port; char buf[256]; char buf2[256]; //i is the listbox id for the profile to be removed. //the registry id for the profile is always i+1. //latest is always a valid entry, but latest+1 is not - hence no reason to move for(UINT j = i + 1; j < latest; j++) { sprintf(buf, "History\\%d", j); sprintf(buf2, "History\\%d", j+1); name = pApp->GetProfileString(buf2, "Name"); host = pApp->GetProfileString(buf2, "Host"); zone = pApp->GetProfileString(buf2, "Zone"); port = pApp->GetProfileString(buf2, "Port"); pApp->WriteProfileString(buf, "Name", name); pApp->WriteProfileString(buf, "Host", host); pApp->WriteProfileString(buf, "Zone", zone); pApp->WriteProfileString(buf, "Port", port); } //reflect that we're now one-less a profile and remove the last one. sprintf(buf, "History\\%d", latest); //erase all the child values pApp->WriteProfileString(buf, "Name", NULL); pApp->WriteProfileString(buf, "Host", NULL); pApp->WriteProfileString(buf, "Zone", NULL); pApp->WriteProfileString(buf, "Port", NULL); //erase the history key itself HKEY hKey; sprintf(buf, "%d", latest); ::RegOpenKey(HKEY_CURRENT_USER, "Software\\San Diego Supercomputer Center\\WINI\\History", &hKey); ::RegDeleteKey(hKey, buf); if(--latest < 0) latest = 0; pApp->WriteProfileInt("History", "Latest", latest); //finally, update the GUI m_ListBox.DeleteItem(i); //fills the left-hand boxes with the profile following the removed one. //don't fill up the right-hand listbox. it should handle case where i //is an illegal value safely. //remember, the parameter is i+1 not to find the subsequent value. //the subsequent value is now i, we are feeding fillboxes i+1 because //it works in registry range, not listbox range! FillBoxes(i+1, false); }
void CCrystalEditView::OnEditReplace() { if (! QueryEditable()) return; CWinApp *pApp = AfxGetApp(); ASSERT(pApp != NULL); CEditReplaceDlg dlg(this); // Take search parameters from registry dlg.m_bMatchCase = pApp->GetProfileInt(REG_REPLACE_SUBKEY, REG_MATCH_CASE, FALSE); dlg.m_bWholeWord = pApp->GetProfileInt(REG_REPLACE_SUBKEY, REG_WHOLE_WORD, FALSE); dlg.m_sText = pApp->GetProfileString(REG_REPLACE_SUBKEY, REG_FIND_WHAT, _T("")); dlg.m_sNewText = pApp->GetProfileString(REG_REPLACE_SUBKEY, REG_REPLACE_WITH, _T("")); /* if (IsSelection()) { GetSelection(m_ptSavedSelStart, m_ptSavedSelEnd); m_bSelectionPushed = TRUE; dlg.m_nScope = 0; // Replace in current selection dlg.m_ptCurrentPos = m_ptSavedSelStart; dlg.m_bEnableScopeSelection = TRUE; dlg.m_ptBlockBegin = m_ptSavedSelStart; dlg.m_ptBlockEnd = m_ptSavedSelEnd; } else { dlg.m_nScope = 1; // Replace in whole text dlg.m_ptCurrentPos = GetCursorPos(); dlg.m_bEnableScopeSelection = FALSE; }*/ // Take the current selection, if any if (IsSelection()) { CPoint ptSelStart, ptSelEnd; GetSelection(ptSelStart, ptSelEnd); if (ptSelStart.y == ptSelEnd.y) { LPCTSTR pszChars = GetLineChars(ptSelStart.y); int nChars = ptSelEnd.x - ptSelStart.x; lstrcpyn(dlg.m_sText.GetBuffer(nChars + 1), pszChars + ptSelStart.x, nChars + 1); dlg.m_sText.ReleaseBuffer(); } dlg.m_nScope = 1; // Replace in whole text dlg.m_ptCurrentPos = ptSelStart; dlg.m_bEnableScopeSelection = FALSE; } // Execute Replace dialog m_bShowInactiveSelection = TRUE; dlg.DoModal(); m_bShowInactiveSelection = FALSE; // Restore selection if (m_bSelectionPushed) { SetSelection(m_ptSavedSelStart, m_ptSavedSelEnd); m_bSelectionPushed = FALSE; } // Save search parameters to registry pApp->WriteProfileInt(REG_REPLACE_SUBKEY, REG_MATCH_CASE, dlg.m_bMatchCase); pApp->WriteProfileInt(REG_REPLACE_SUBKEY, REG_WHOLE_WORD, dlg.m_bWholeWord); pApp->WriteProfileString(REG_REPLACE_SUBKEY, REG_FIND_WHAT, dlg.m_sText); pApp->WriteProfileString(REG_REPLACE_SUBKEY, REG_REPLACE_WITH, dlg.m_sNewText); }
void CPGPFoneFrame::DoPrefs(short save) { CString csPhoneOpts = "Phone"; CString csSerialOpts = "Serial"; CString csSystemOpts = "System"; CString csFileOpts = "File"; CString csPIdentity = "Identity", csPEncryptor = "Encryptor", csPAEncryptor = "AltEncryptor", csPCoder = "Coder", csPACoder = "AltCoder", csPPrime = "Prime", csPPrimeMask = "AllowedPrimes", csPListen = "Listen", csPRing = "Ring", csPFullDuplex = "FullDuplex", csPIncoming = "IDIncoming", csPOutgoing = "IDOutgoing", csPUnencrypted = "IDUnencrypted", csPConnection = "Connect", csPCryptMask = "AllowedCryptors", csPsiGain = "Gain", csPsiThreshold = "Threshold"; CString csSModemInit = "ModemInit", csSBaud = "Baud", csSPort = "Port", csSDTR = "DTR", csSMaxBaud = "MaxBaud"; CString csWindowPosX = "WindowPosX", csWindowPosY = "WindowPosY", csViewStatusInfo = "ViewStatusInfo", csViewEncodingDetails = "ViewEncodingDetails"; CString csRecvDir = "RecvDir"; CString csT; CWinApp* pa = AfxGetApp(); if(save) { pa->WriteProfileString(csPhoneOpts, csPIdentity, gPGFOpts.popt.identity); pa->WriteProfileInt(csPhoneOpts, csPEncryptor, gPGFOpts.popt.prefEncryptor); pa->WriteProfileInt(csPhoneOpts, csPCryptMask, gPGFOpts.popt.cryptorMask); pa->WriteProfileInt(csPhoneOpts, csPCoder, gPGFOpts.popt.prefCoder); pa->WriteProfileInt(csPhoneOpts, csPACoder, gPGFOpts.popt.altCoder); pa->WriteProfileInt(csPhoneOpts, csPPrime, gPGFOpts.popt.prefPrime); pa->WriteProfileInt(csPhoneOpts, csPPrimeMask, gPGFOpts.popt.primeMask); pa->WriteProfileInt(csPhoneOpts, csPListen, gPGFOpts.popt.alwaysListen); pa->WriteProfileInt(csPhoneOpts, csPRing, gPGFOpts.popt.playRing); pa->WriteProfileInt(csPhoneOpts, csPFullDuplex, gPGFOpts.popt.fullDuplex); pa->WriteProfileInt(csPhoneOpts, csPIncoming, gPGFOpts.popt.idIncoming); pa->WriteProfileInt(csPhoneOpts, csPOutgoing, gPGFOpts.popt.idOutgoing); pa->WriteProfileInt(csPhoneOpts, csPUnencrypted, gPGFOpts.popt.idUnencrypted); if(gPGFOpts.popt.connection == _cme_Internet) pa->WriteProfileString(csPhoneOpts, csPConnection, "Internet"); else pa->WriteProfileString(csPhoneOpts, csPConnection, "Serial"); pa->WriteProfileInt(csPhoneOpts, csPsiGain, gPGFOpts.popt.siGain); pa->WriteProfileInt(csPhoneOpts, csPsiThreshold, gPGFOpts.popt.siThreshold); pa->WriteProfileString(csSerialOpts, csSModemInit, gPGFOpts.sopt.modemInit); pa->WriteProfileString(csSerialOpts, csSPort, gPGFOpts.sopt.port); pa->WriteProfileInt(csSerialOpts, csSBaud, gPGFOpts.sopt.baud); pa->WriteProfileInt(csSerialOpts, csSDTR, gPGFOpts.sopt.dtrHangup); pa->WriteProfileInt(csSerialOpts, csSMaxBaud, gPGFOpts.sopt.maxBaud); pa->WriteProfileInt(csSystemOpts, csWindowPosX, gPGFOpts.sysopt.windowPosX); pa->WriteProfileInt(csSystemOpts, csWindowPosY, gPGFOpts.sysopt.windowPosY); pa->WriteProfileInt(csSystemOpts, csViewStatusInfo, gPGFOpts.sysopt.viewStatusInfo); pa->WriteProfileInt(csSystemOpts, csViewEncodingDetails, gPGFOpts.sysopt.viewEncodingDetails); pa->WriteProfileString(csFileOpts, csRecvDir, gPGFOpts.fopt.recvDir); } else { strcpy(gPGFOpts.popt.identity, (LPCTSTR)pa->GetProfileString(csPhoneOpts, csPIdentity, "Unknown")); gPGFOpts.popt.prefEncryptor = pa->GetProfileInt(csPhoneOpts, csPEncryptor, _enc_cast); gPGFOpts.popt.cryptorMask = pa->GetProfileInt(csPhoneOpts, csPCryptMask, 0x0007); gPGFOpts.popt.prefCoder = pa->GetProfileInt(csPhoneOpts, csPCoder, 'GSM7'); gPGFOpts.popt.altCoder = pa->GetProfileInt(csPhoneOpts, csPACoder, 'GS6L'); gPGFOpts.popt.prefPrime = pa->GetProfileInt(csPhoneOpts, csPPrime, 3); gPGFOpts.popt.primeMask = pa->GetProfileInt(csPhoneOpts, csPPrimeMask, 0x3e); gPGFOpts.popt.alwaysListen = pa->GetProfileInt(csPhoneOpts, csPListen, 1); gPGFOpts.popt.playRing = pa->GetProfileInt(csPhoneOpts, csPRing, 1); gPGFOpts.popt.fullDuplex = pa->GetProfileInt(csPhoneOpts, csPFullDuplex, 0); gPGFOpts.popt.idIncoming = pa->GetProfileInt(csPhoneOpts, csPIncoming, 1); gPGFOpts.popt.idOutgoing = pa->GetProfileInt(csPhoneOpts, csPOutgoing, 1); gPGFOpts.popt.idUnencrypted = pa->GetProfileInt(csPhoneOpts, csPUnencrypted, 1); csT = pa->GetProfileString(csPhoneOpts, csPConnection, "Internet"); if(csT == "Internet") gPGFOpts.popt.connection = _cme_Internet; else gPGFOpts.popt.connection = _cme_Serial; gPGFOpts.popt.siGain = pa->GetProfileInt(csPhoneOpts, csPsiGain, 0); gPGFOpts.popt.siThreshold = pa->GetProfileInt(csPhoneOpts, csPsiThreshold, 0); strcpy(gPGFOpts.sopt.modemInit, (LPCSTR)pa->GetProfileString(csSerialOpts, csSModemInit, "S0=0")); strcpy(gPGFOpts.sopt.port, (LPCSTR)pa->GetProfileString(csSerialOpts, csSPort, "COM1")); gPGFOpts.sopt.baud = pa->GetProfileInt(csSerialOpts, csSBaud, 38400); gPGFOpts.sopt.dtrHangup = pa->GetProfileInt(csSerialOpts, csSDTR, 1); gPGFOpts.sopt.maxBaud = pa->GetProfileInt(csSerialOpts, csSMaxBaud, 28800); gPGFOpts.sysopt.windowPosX = pa->GetProfileInt(csSystemOpts, csWindowPosX, 90); gPGFOpts.sysopt.windowPosY = pa->GetProfileInt(csSystemOpts,csWindowPosY, 80); gPGFOpts.sysopt.viewStatusInfo = pa->GetProfileInt(csSystemOpts, csViewStatusInfo, 0); gPGFOpts.sysopt.viewEncodingDetails = pa->GetProfileInt(csSystemOpts,csViewEncodingDetails, 0); char path[MAX_PATH]; GetCurrentDirectory(sizeof(path), path); strcpy(gPGFOpts.fopt.recvDir, (LPCSTR)pa->GetProfileString(csFileOpts, csRecvDir, path)); } }