void CComboBox_Clear(CComboBox &ctrlComboBox) { ASSERT(ctrlComboBox.GetSafeHwnd() != NULL); if (ctrlComboBox.GetSafeHwnd() == NULL) return; for (int i = ctrlComboBox.GetCount() - 1; i >= 0; i--) ctrlComboBox.DeleteString(i); }
void CComboBox_Assign(CComboBox &ctrlComboBox, const CStringArray &arrstrItems) { ASSERT(ctrlComboBox.GetSafeHwnd() != NULL); ctrlComboBox.Clear(); for (int i = 0; i < arrstrItems.GetCount(); ++i) ctrlComboBox.AddString(arrstrItems[i]); }
void CAntiVirus::UpdateData(CComboBox& wndAntiVirus) { if ( ! ::IsWindow( wndAntiVirus.GetSafeHwnd() ) ) return; if ( wndAntiVirus.IsWindowEnabled() ) { Settings.General.AntiVirus = *(CString*)wndAntiVirus.GetItemDataPtr( wndAntiVirus.GetCurSel() ); } }
void CAntiVirus::Free(CComboBox& wndAntiVirus) { if ( ! ::IsWindow( wndAntiVirus.GetSafeHwnd() ) ) return; const int nCount = wndAntiVirus.GetCount(); for ( int i = 0; i < nCount; ++i ) { delete (CString*)wndAntiVirus.GetItemDataPtr( i ); } }
CString CComboBox_GetSelectedString(const CComboBox &ctrlComboBox) { ASSERT(ctrlComboBox.GetSafeHwnd() != NULL); int nCurSel = ctrlComboBox.GetCurSel(); CString strSelectedItem; if (nCurSel != CB_ERR) ctrlComboBox.GetLBText(nCurSel, strSelectedItem); return strSelectedItem; }
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 ); }
void CComboBox_CopyTo(const CComboBox &ctrlComboBox, CStringArray &arrstrItems) { ASSERT(ctrlComboBox.GetSafeHwnd() != NULL); arrstrItems.RemoveAll(); arrstrItems.SetSize(ctrlComboBox.GetCount()); CString strItem; for (int i = 0; i < ctrlComboBox.GetCount(); ++i) { ctrlComboBox.GetLBText(i, strItem); arrstrItems[i] = strItem; } }
AFX_STATIC int CALLBACK EnumFontFamExProc( ENUMLOGFONTEX *lpelfe, // logical-font data NEWTEXTMETRICEX *lpntme, // physical-font data DWORD FontType, // type of font LPARAM lParam) // application-defined data { CComboBox* pWndCombo = DYNAMIC_DOWNCAST(CComboBox, (CComboBox*)lParam); if (::IsWindow(pWndCombo->GetSafeHwnd())) { switch (pWndCombo->GetDlgCtrlID()) { case XTP_IDC_EDIT_COMB_NAMES: { //if (lpelfe->elfLogFont.lfPitchAndFamily & FIXED_PITCH) { // Make sure the fonts are only added once. if (pWndCombo->FindStringExact(0, (LPCTSTR)lpelfe->elfFullName) == CB_ERR) { // Add to list pWndCombo->AddString((LPCTSTR)lpelfe->elfLogFont.lfFaceName); } } } break; case XTP_IDC_EDIT_COMB_SIZES: { if (FontType != TRUETYPE_FONTTYPE) { CWindowDC dc(NULL); CString csSize; csSize.Format(_T("%i"), ::MulDiv(lpntme->ntmTm.tmHeight - lpntme->ntmTm.tmInternalLeading, 72, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY))); // Make sure the fonts are only added once. if (pWndCombo->FindStringExact(0, (LPCTSTR)csSize) == CB_ERR) { // Add to list pWndCombo->AddString((LPCTSTR)csSize); } } } break; case XTP_IDC_EDIT_COMB_SCRIPT: { if (lpelfe->elfScript[0] != _T('\0')) { // Make sure the fonts are only added once. if (pWndCombo->FindStringExact(0, (LPCTSTR)lpelfe->elfScript) == CB_ERR) { // Add to list int iIndex = pWndCombo->AddString((LPCTSTR)lpelfe->elfScript); if (iIndex != CB_ERR) { pWndCombo->SetItemData(iIndex, (DWORD)lpelfe->elfLogFont.lfCharSet); } } } } break; } } return TRUE; }