void CAntiVirus::Enum(CComboBox& wndAntiVirus) { if ( ! ::IsWindow( wndAntiVirus.GetSafeHwnd() ) ) return; wndAntiVirus.ResetContent(); // No anti-virus int nAntiVirus = wndAntiVirus.AddString( _T("") ); wndAntiVirus.SetItemDataPtr( nAntiVirus, (LPVOID)new CString() ); // Enum available anti-viruses CComPtr< ICatInformation > pInfo; HRESULT hr = pInfo.CoCreateInstance( CLSID_StdComponentCategoriesMgr ); if ( SUCCEEDED( hr ) ) { const CATID IDs[ 1 ] = { CATID_MSOfficeAntiVirus }; CComPtr< IEnumCLSID > pEnum; hr = pInfo->EnumClassesOfCategories( 1, IDs, 0, NULL, &pEnum ); if ( SUCCEEDED( hr ) ) { CLSID clsid; while ( pEnum->Next( 1, &clsid, NULL ) == S_OK ) { const CString sCLSID = Hashes::toGuid( clsid, true ); HKEY hClass = NULL; if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_CLASSES_ROOT, _T("CLSID\\") + sCLSID, 0, KEY_READ, &hClass ) ) { // Get it name TCHAR szValue[ MAX_PATH ] = {}; DWORD nValue = MAX_PATH, nType = REG_SZ; if ( ERROR_SUCCESS == RegQueryValueEx( hClass, NULL, NULL, &nType, (LPBYTE)szValue, &nValue ) ) { const int nIndex = wndAntiVirus.AddString( szValue ); wndAntiVirus.SetItemDataPtr( nIndex, (LPVOID)new CString( sCLSID ) ); if ( Settings.General.AntiVirus.CompareNoCase( sCLSID ) == 0 ) { nAntiVirus = nIndex; } } RegCloseKey( hClass ); } } } } wndAntiVirus.SetCurSel( nAntiVirus ); wndAntiVirus.EnableWindow( wndAntiVirus.GetCount() > 1 ); }
// // Helper utility to initialize a combo box from an array of text // static void initComboBox(CComboBox &b, const TCHAR *list[], int count, const TCHAR *initial) { b.Clear(); for (int i = 0; i < count; i += 2) //The odd index are the display text, the even index are the keys b.SetItemDataPtr(b.AddString(list[i + 1]), (void *)(list[i])); b.SelectString(0, initial); }
// populate an identity control with the list of identities, select the identity // passed if set, otherwise select the default identity (if set) void PopulateIdentityComboCtrl(CComboBox &IdentityCtrl, UserIdentity *pSelectIdentity /* = NULL */) { int itemnum; char *selectname = NULL; UserIdentity *pIdentity; UserIdentity *pDefaultIdentity = g_pPrefs->FindIdentityByDescripton(STRINGPREF(PREF_sDefaultIdentity)); if (pDefaultIdentity) { itemnum = IdentityCtrl.AddString(pDefaultIdentity->m_Description); IdentityCtrl.SetItemDataPtr(itemnum,pDefaultIdentity); selectname = pDefaultIdentity->m_Description; // select this one, unless we're supposed to select something else... } for (int i = 0 ; i < g_pPrefs->m_UserIdentitiesList.GetSize() ; i++ ) { pIdentity = g_pPrefs->m_UserIdentitiesList[i]; // check we've not already added this one. if (pIdentity != pDefaultIdentity) { itemnum = IdentityCtrl.AddString(pIdentity->m_Description); IdentityCtrl.SetItemDataPtr(itemnum,pIdentity); // select this one? if (pSelectIdentity && pSelectIdentity->m_Description && stricmp(pIdentity->m_Description,pSelectIdentity->m_Description) == 0) selectname = pIdentity->m_Description; } } if (selectname) // this should always be set, as we can't get to the connect dialog without an identity... IdentityCtrl.SelectString(0,selectname); else IdentityCtrl.SetCurSel(0); }
int CALLBACK CImageFontDlg::EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX * /*lpntme*/, int FontType, LPARAM lParam) { //CFontTestDlgのm_cmbFont(コンボ ボックス)のポインターを代入する CComboBox* pComboBox = (CComboBox*)lParam; if (FontType != TRUETYPE_FONTTYPE) { return TRUE; } //列挙されたフォント名をコンボ ボックスのリストに追加する CString strFontName; strFontName.Format(_T("%s (%s)"), lpelfe->elfFullName, lpelfe->elfScript); int nIndex = pComboBox->AddString(strFontName); int nLogFontIndex = m_aryLogfont.Add(lpelfe->elfLogFont); LOGFONT *pLogfont = &m_aryLogfont[nLogFontIndex]; pComboBox->SetItemDataPtr(nIndex, pLogfont); return TRUE; }
//----- BroadcastEvent() ---------------------------------------------------- BOOL CFormChunkMergeView::BroadcastEvent(WORD event, void* pParameter) { switch (event) { case IBCE_CHANGED_SETTINGS: { // set settings from configuration Configuration* pConfig (Configuration::getInstance()); CComboBox* pCBox ((CComboBox*) GetDlgItem(IDC_CB_TEMPLATE)); set<string> tDirList(pConfig->getDirListTemplates()); CString tmpPath (pConfig->_cmDefaultTemplate.c_str()); //- templates LogMessageObject::LogMessage(NCU_MSG_TYPE_INFO, "Adding templates"); pCBox->ResetContent(); for (auto pIter(tDirList.begin()), pEnd(tDirList.end()); pIter != pEnd; ++pIter) { if (pIter->rfind(".nif") == string::npos) continue; pCBox->AddString(CString(pIter->c_str())); LogMessageObject::LogMessage(NCU_MSG_TYPE_SUB_INFO, "added: %s", pIter->c_str()); } pCBox->SelectString(-1, CString(tmpPath)); pCBox->GetWindowText(tmpPath); if (tmpPath.IsEmpty()) pCBox->SetCurSel(0); LogMessageObject::LogMessage(NCU_MSG_TYPE_INFO, "templates found: %d", tDirList.size()); //- materials pCBox = (CComboBox*) GetDlgItem(IDC_CB_MAT_SINGLE); map<string, NifUtlMaterial> matMap(NifUtlMaterialList::getInstance()->getMaterialMap()); short tIdx (0); short selIdx(0); // add materials to combo box for (auto pIter(matMap.begin()), pEnd(matMap.end()); pIter != pEnd; ++pIter, ++tIdx) { pCBox->InsertString (tIdx, CString(pIter->second._name.c_str())); pCBox->SetItemDataPtr(tIdx, (void*) (pIter->second._code)); if (pIter->second._code == pConfig->_cmMatSingleType) { selIdx = tIdx; } } pCBox->SetCurSel(selIdx); // material flags int selItem(pConfig->_cmMatHandling + IDC_RD_MAT_SINGLE); ((CButton*) GetDlgItem(IDC_RD_MAT_SINGLE)) ->SetCheck(selItem == IDC_RD_MAT_SINGLE); ((CButton*) GetDlgItem(IDC_RD_MAT_NITRISHAPE))->SetCheck(selItem == IDC_RD_MAT_NITRISHAPE); ((CButton*) GetDlgItem(IDC_RD_MAT_DEFINE)) ->SetCheck(selItem == IDC_RD_MAT_DEFINE); GetDlgItem(IDC_CB_MAT_SINGLE)->EnableWindow(selItem == IDC_RD_MAT_SINGLE); GetDlgItem(IDC_BT_MAT_DEFINE)->EnableWindow(selItem == IDC_RD_MAT_DEFINE); // collision flags selItem = pConfig->_cmCollHandling + IDC_RD_COLL_CDATA; ((CButton*) GetDlgItem(IDC_RD_COLL_CDATA))->SetCheck(selItem == IDC_RD_COLL_CDATA); ((CButton*) GetDlgItem(IDC_RD_COLL_FBACK))->SetCheck(selItem == IDC_RD_COLL_FBACK); ((CButton*) GetDlgItem(IDC_RD_COLL_MESH)) ->SetCheck(selItem == IDC_RD_COLL_MESH); // other flags ((CButton*) GetDlgItem(IDC_RD_COLL_LOCAL)) ->SetCheck(pConfig->_cmMergeColl ? BST_UNCHECKED : BST_CHECKED); ((CButton*) GetDlgItem(IDC_RD_COLL_GLOBAL)) ->SetCheck(pConfig->_cmMergeColl ? BST_CHECKED : BST_UNCHECKED); ((CButton*) GetDlgItem(IDC_CK_REORDER_TRIS))->SetCheck(pConfig->_cmReorderTris ? BST_CHECKED : BST_UNCHECKED); break; } case IBCE_SET_TOOLTIPP: { _toolTipCtrl.Activate(Configuration::getInstance()->_showToolTipps); break; } } // switch (event) return TRUE; }
void CChunkMergeDlg::OnDefaultReloaddirectories() { logMessage(NCU_MSG_TYPE_INFO, "scanning directories..."); // re-scan templates CComboBox* pCBox = (CComboBox*) GetDlgItem(IDC_COMBO_TEMPLATE); CString pathTmpl(glConfig._pathTemplate.c_str()); set<string> directories; // reset selection box pCBox->ResetContent(); // parse directory parseDir(pathTmpl, directories, false); // in case of existing data if (directories.size() > 0) { // add files to selection box for (set<string>::iterator tIter = directories.begin(); tIter != directories.end(); tIter++) { if ((*tIter).rfind(".nif") == string::npos) continue; pCBox->AddString(CString((*tIter).c_str())); } pCBox->SelectString(-1, CString(glConfig._lastTemplate.c_str())); // make sure one entry is selected GetDlgItem(IDC_COMBO_TEMPLATE) ->GetWindowTextW(pathTmpl); if (pathTmpl.IsEmpty()) { pCBox->SetCurSel(0); } // reset last choosen template GetDlgItem(IDC_COMBO_TEMPLATE)->GetWindowTextW(pathTmpl); glConfig._lastTemplate = CStringA(pathTmpl).GetString(); } // re-load material glMaterialList.initializeMaterialMap(glConfig._pathNifXML); map<string, NifUtlMaterial> mapMap(glMaterialList.getMaterialMap()); short t (0); short selIdx(0); pCBox = (CComboBox*) GetDlgItem(IDC_COMBO_COLLMAT); for (map<string, NifUtlMaterial>::iterator pIter = mapMap.begin(); pIter != mapMap.end(); pIter++, t++) { pCBox->InsertString (t, CString(pIter->second._name.c_str())); pCBox->SetItemDataPtr(t, (void*) (pIter->second._code)); if (pIter->second._code == ((unsigned int) glConfig._collMaterial)) { selIdx = t; } } pCBox->SetCurSel(selIdx); // add messages from material list vector<string> userMessages(glMaterialList.getUserMessages()); for (vector<string>::iterator texIter = userMessages.begin(); texIter != userMessages.end(); texIter++) { logMessage(NCU_MSG_TYPE_INFO, texIter->c_str()); } logMessage(NCU_MSG_TYPE_INFO, "scan done."); }