void CMiscPage::OnPageDisplay( void ) { HPROPERTY hItem; m_PropertyList.AddItem( PropCreateCategory("Strings") ); for (int i = 0; i < PREF_STRING_MAX; i++) { hItem = m_PropertyList.AddItem( PropCreateSimple(PREF_STRING_NAME(i) , g_pNewPrefs->m_StringPrefs[i] )); if (hItem) m_PropertyList.SetItemData(hItem, MAKELPARAM(i,PII_STRING) ); } m_PropertyList.AddItem( PropCreateCategory("Paths") ); for (int i = 0; i < PREF_PATH_MAX; i++) { hItem = m_PropertyList.AddItem( PropCreateFileName(PREF_PATH_NAME(i) , g_pNewPrefs->m_PathPrefs[i] )); if (hItem) m_PropertyList.SetItemData(hItem, MAKELPARAM(i,PII_PATH) ); } m_PropertyList.AddItem( PropCreateCategory("Numbers") ); for (int i = 0; i < PREF_INT_MAX; i++) { hItem = m_PropertyList.AddItem( PropCreateSimple(PREF_INT_NAME(i) , (LONG)g_pNewPrefs->m_IntPrefs[i] )); if (hItem) m_PropertyList.SetItemData(hItem, MAKELPARAM(i,PII_INTEGER) ); } m_PropertyList.AddItem( PropCreateCategory("Booleans") ); for (int i = 0; i < PREF_BOOL_MAX; i++) { hItem = m_PropertyList.AddItem( PropCreateSimple(PREF_BOOL_NAME(i) , g_pNewPrefs->m_BoolPrefs[i] ? (bool)true : (bool)false )); // note the case of "bool" if (hItem) m_PropertyList.SetItemData(hItem, MAKELPARAM(i,PII_BOOL) ); } m_PropertyList.AddItem( PropCreateCategory("Fonts") ); for (int i = 0; i < PREF_FONT_MAX; i++) { char *FontInfo = HydraIRC_BuildString(128,"%s,%d,%s%s%s", g_pNewPrefs->m_FontPrefs[i].m_Name, g_pNewPrefs->m_FontPrefs[i].m_Size, g_pNewPrefs->m_FontPrefs[i].m_Flags == FIF_NONE ? "N" : (g_pNewPrefs->m_FontPrefs[i].m_Flags & FIF_BOLD ? "B" : ""), g_pNewPrefs->m_FontPrefs[i].m_Flags & FIF_ITALIC ? "I" : "", g_pNewPrefs->m_FontPrefs[i].m_Flags & FIF_UNDERLINE ? "U" : ""); if (FontInfo) { hItem = m_PropertyList.AddItem( PropCreateSimple(PREF_FONT_NAME(i), FontInfo )); if (hItem) m_PropertyList.SetItemData(hItem, MAKELPARAM(i,PII_FONT) ); free(FontInfo); } } m_PropertyList.AddItem( PropCreateCategory("Colors") ); for (int i = 0; i < PREF_COLOR_MAX; i++) { char *ColorInfo; if (g_pNewPrefs->m_ColorPrefs[i] != -1) ColorInfo = HydraIRC_BuildString(8,"#%06x",RGBVALTOCOLORREF(g_pNewPrefs->m_ColorPrefs[i])); else ColorInfo = strdup("System"); if (ColorInfo) { hItem = m_PropertyList.AddItem( PropCreateSimple(PREF_COLOR_NAME(i) , ColorInfo )); if (hItem) m_PropertyList.SetItemData(hItem, MAKELPARAM(i,PII_COLOR) ); free(ColorInfo); } } this->UpdateWindow(); }
LRESULT CDeviceHardwarePage::OnInitDialog(HWND hwndFocus, LPARAM lParam) { ATLASSERT(NULL != m_pDevice.get()); if (NULL == m_pDevice.get()) { return 0; } m_propList.SubclassWindow(GetDlgItem(IDC_PROPLIST)); m_propList.SetExtendedListStyle(PLS_EX_CATEGORIZED); // // Device Hardware Information // boost::shared_ptr<const NDAS_DEVICE_HARDWARE_INFO> pDevHWInfo = m_pDevice->GetHardwareInfo(); CString strValue = (LPCTSTR) IDS_DEVPROP_CATEGORY_HARDWARE; m_propList.AddItem(PropCreateCategory(strValue)); if (0 == pDevHWInfo.get()) { CString str = MAKEINTRESOURCE(IDS_DEVICE_HARDWARE_INFO_NA); m_propList.AddItem(PropCreateSimple(str, _T(""))); return 0; } CString strType; // Version strType.LoadString(IDS_DEVPROP_HW_VERSION); pHWVersionString(strValue, pDevHWInfo->HardwareVersion); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Max Request Blocks strType.LoadString(IDS_DEVPROP_HW_MAX_REQUEST_BLOCKS); strValue.Format(_T("%d"), pDevHWInfo->MaximumTransferBlocks); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Slots strType.LoadString(IDS_DEVPROP_HW_SLOT_COUNT); strValue.Format(_T("%d"), pDevHWInfo->NumberOfCommandProcessingSlots); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Targets //strType.LoadString(IDS_DEVPROP_HW_TARGET_COUNT); //strValue.Format(_T("%d"), pDevHWInfo->NumberOfTargets); //m_propList.AddItem(PropCreateSimple(strType, strValue)); // Max Targets strType.LoadString(IDS_DEVPROP_HW_MAX_TARGET_COUNT); strValue.Format(_T("%d"), pDevHWInfo->MaximumNumberOfTargets); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Max LUs strType.LoadString(IDS_DEVPROP_HW_MAX_LU_COUNT); strValue.Format(_T("%d"), pDevHWInfo->MaximumNumberOfLUs); m_propList.AddItem(PropCreateSimple(strType, strValue)); boost::shared_ptr<const NDAS_DEVICE_HARDWARE_INFO> phwi = m_pDevice->GetHardwareInfo(); if (NULL != phwi.get() && !IsNullNdasDeviceId(phwi->NdasDeviceId)) { strType.LoadString(IDS_DEVPRO_HW_MAC_ADDRESS); strValue.Format(_T("%02X:%02X:%02X:%02X:%02X:%02X"), phwi->NdasDeviceId.Node[0], phwi->NdasDeviceId.Node[1], phwi->NdasDeviceId.Node[2], phwi->NdasDeviceId.Node[3], phwi->NdasDeviceId.Node[4], phwi->NdasDeviceId.Node[5]); m_propList.AddItem(PropCreateSimple(strType, strValue)); } // // Unit Device Hardware Information // const ndas::UnitDeviceVector& unitDevices = m_pDevice->GetUnitDevices(); for (DWORD i = 0; i < unitDevices.size(); ++i) { ndas::UnitDevicePtr pUnitDevice = unitDevices.at(i); const NDAS_UNITDEVICE_HARDWARE_INFO* pHWI = pUnitDevice->GetHWInfo(); strValue.FormatMessage(IDS_DEVPROP_UNITDEV_TITLE_FMT, i + 1); m_propList.AddItem(PropCreateCategory(strValue)); if (NULL == pHWI) { // "Not available" CString str = MAKEINTRESOURCE(IDS_UNITDEVICE_HARDWARE_INFO_NA); m_propList.AddItem(PropCreateSimple(str, _T(""))); continue; } // Media Type strType.LoadString(IDS_DEVPROP_UNITDEV_DEVICE_TYPE); pUnitDeviceMediaTypeString(strValue, pHWI->MediaType); m_propList.AddItem(PropCreateSimple(strType, strValue)); CString modeDelimiter(MAKEINTRESOURCE(IDS_MODE_DELIMITER)); // Transfer Mode strType.LoadString(IDS_DEVPROP_UNITDEV_TRANSFER_MODE); strValue = _T(""); { const struct { const BOOL& Mode; UINT ResID; } TransferModeStrings[] = { pHWI->PIO, IDS_TRANSFER_MODE_PIO, pHWI->DMA, IDS_TRANSFER_MODE_DMA, pHWI->UDMA, IDS_TRANSFER_MODE_UDMA }; bool multipleModes = false; for (int i = 0; i < RTL_NUMBER_OF(TransferModeStrings); ++i) { if (multipleModes) strValue += modeDelimiter; if (TransferModeStrings[i].Mode) { strValue += CString(MAKEINTRESOURCE(TransferModeStrings[i].ResID)); multipleModes = true; } } m_propList.AddItem(PropCreateSimple(strType, strValue)); } // LBA support? strType.LoadString(IDS_DEVPROP_UNITDEV_LBA_MODE); strValue = _T(""); { const struct { const BOOL& Mode; UINT ResID; } LbaModeStrings[] = { pHWI->LBA, IDS_LBA_MODE_LBA, pHWI->LBA48, IDS_LBA_MODE_LBA48 }; bool multipleModes = false; for (int i = 0; i < RTL_NUMBER_OF(LbaModeStrings); ++i) { if (multipleModes) strValue += modeDelimiter; if (LbaModeStrings[i].Mode) { strValue += CString(MAKEINTRESOURCE(LbaModeStrings[i].ResID)); multipleModes = true; } } m_propList.AddItem(PropCreateSimple(strType, strValue)); } // Model strType.LoadString(IDS_DEVPROP_UNITDEV_MODEL); strValue = pHWI->Model; strValue.TrimLeft(); strValue.TrimRight(); m_propList.AddItem(PropCreateSimple(strType, strValue)); // FWRev strType.LoadString(IDS_DEVPROP_UNITDEV_FWREV); strValue = pHWI->FirmwareRevision; strValue.TrimLeft(); strValue.TrimRight(); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Serial No strType.LoadString(IDS_DEVPROP_UNITDEV_SERIALNO); strValue = pHWI->SerialNumber; strValue.TrimLeft(); strValue.TrimRight(); m_propList.AddItem(PropCreateSimple(strType, strValue)); } return 0; }
LRESULT CHardwarePage::OnInitDialog(HWND hwndFocus, LPARAM lParam) { ATLASSERT(NULL != m_pDevice); if (NULL == m_pDevice) { return 0; } m_propList.SubclassWindow(GetDlgItem(IDC_PROPLIST)); m_propList.SetExtendedListStyle(PLS_EX_CATEGORIZED); CString strType, strValue; // // Device Hardware Information // const NDAS_DEVICE_HW_INFORMATION* pDevHWInfo = m_pDevice->GetHwInfo(); strValue.LoadString(IDS_DEVPROP_CATEGORY_HARDWARE); m_propList.AddItem(PropCreateCategory(strValue)); if (NULL == pDevHWInfo) { m_propList.AddItem(PropCreateSimple(_T("Not available."), _T(""))); return 0; } // Version strType.LoadString(IDS_DEVPROP_HW_VERSION); pHWVersionString(strValue, pDevHWInfo->dwHwVersion); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Max Request Blocks strType.LoadString(IDS_DEVPROP_HW_MAX_REQUEST_BLOCKS); strValue.Format(_T("%d"), pDevHWInfo->nMaxRequestBlocks); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Slots strType.LoadString(IDS_DEVPROP_HW_SLOT_COUNT); strValue.Format(_T("%d"), pDevHWInfo->nSlots); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Targets strType.LoadString(IDS_DEVPROP_HW_TARGET_COUNT); strValue.Format(_T("%d"), pDevHWInfo->nTargets); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Max Targets strType.LoadString(IDS_DEVPROP_HW_MAX_TARGET_COUNT); strValue.Format(_T("%d"), pDevHWInfo->nMaxTargets); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Max LUs strType.LoadString(IDS_DEVPROP_HW_MAX_LU_COUNT); strValue.Format(_T("%d"), pDevHWInfo->nMaxLUs); m_propList.AddItem(PropCreateSimple(strType, strValue)); // // Unit Device Hardware Information // for (DWORD i = 0; i < m_pDevice->GetUnitDeviceCount(); ++i) { ndas::UnitDevice* pUnitDevice = m_pDevice->GetUnitDevice(i); const NDAS_UNITDEVICE_HW_INFORMATION* pHWI = pUnitDevice->GetHWInfo(); strValue.FormatMessage(IDS_DEVPROP_UNITDEV_TITLE_FMT, i + 1); m_propList.AddItem(PropCreateCategory(strValue)); if (NULL == pHWI) { m_propList.AddItem(PropCreateSimple(_T("Not available"), _T(""))); continue; } // Media Type strType.LoadString(IDS_DEVPROP_UNITDEV_DEVICE_TYPE); pUnitDeviceMediaTypeString(strValue, pHWI->MediaType); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Transfer Mode strType.LoadString(IDS_DEVPROP_UNITDEV_TRANSFER_MODE); strValue = _T(""); if (pHWI->bPIO) strValue += _T("PIO, "); if (pHWI->bDMA) strValue += _T("DMA, "); if (pHWI->bUDMA) strValue += _T("UDMA, "); if (strValue.GetLength() > 2) { // Trimming ", " strValue = strValue.Left(strValue.GetLength() - 2); } m_propList.AddItem(PropCreateSimple(strType, strValue)); // LBA support? strType.LoadString(IDS_DEVPROP_UNITDEV_LBA_MODE); strValue = _T(""); if (pHWI->bLBA) strValue += _T("LBA, "); if (pHWI->bLBA48) strValue += _T("LBA48, "); if (strValue.GetLength() > 2) { // Trimming ", " strValue = strValue.Left(strValue.GetLength() - 2); } m_propList.AddItem(PropCreateSimple(strType, strValue)); // Model strType.LoadString(IDS_DEVPROP_UNITDEV_MODEL); strValue = pHWI->szModel; strValue.TrimRight(); m_propList.AddItem(PropCreateSimple(strType, strValue)); // FWRev strType.LoadString(IDS_DEVPROP_UNITDEV_FWREV); strValue = pHWI->szFwRev; strValue.TrimRight(); m_propList.AddItem(PropCreateSimple(strType, strValue)); // Serial No strType.LoadString(IDS_DEVPROP_UNITDEV_SERIALNO); strValue = pHWI->szSerialNo; strValue.TrimRight(); m_propList.AddItem(PropCreateSimple(strType, strValue)); pUnitDevice->Release(); } return 0; }
void CPropertyView::AddProperties(SPropertyList *pPL) { HPROPERTY hProp = NULL; LPCSTR szLastProperty = ""; for(int i=0; i<pPL->nProperties; i++) { if(pPL->aProperties[i].eType == SProperty::ptCategory) { szLastProperty = pPL->aProperties[i].szPropName; } hProp = m_ctrlList.FindProperty(pPL->aProperties[i].szPropName, szLastProperty); if(hProp) { if(pPL->aProperties[i].eType != SProperty::ptCategory) { if( pPL->aProperties[i].eType == SProperty::ptString || pPL->aProperties[i].eType == SProperty::ptUCString || pPL->aProperties[i].eType == SProperty::ptLCString ) { CComVariant vValue = pPL->aProperties[i].szString; m_ctrlList.SetItemValue(hProp, &vValue); } else if( pPL->aProperties[i].eType == SProperty::ptARGBColor || pPL->aProperties[i].eType == SProperty::ptRGBColor ) { RGBQUAD Color = (RGBQUAD)ARGBCOLOR(pPL->aProperties[i].rgbColor); CComVariant vValue = (int)(*(DWORD*)&Color); m_ctrlList.SetItemValue(hProp, &vValue); } else if( pPL->aProperties[i].eType == SProperty::ptValue || pPL->aProperties[i].eType == SProperty::ptRangeValue ) { CComVariant vValue = pPL->aProperties[i].nValue; m_ctrlList.SetItemValue(hProp, &vValue); } else if( pPL->aProperties[i].eType == SProperty::ptBoolean ) { CComVariant vValue = (int)(pPL->aProperties[i].bBoolean & 1); m_ctrlList.SetItemValue(hProp, &vValue); } else if( pPL->aProperties[i].eType == SProperty::ptList ) { CComVariant vValue = pPL->aProperties[i].nIndex; m_ctrlList.SetItemValue(hProp, &vValue); } } if(hProp) { m_ctrlList.SetItemEnabled(hProp, pPL->aProperties[i].bEnabled); m_ctrlList.SetItemMultivalue(hProp, pPL->aProperties[i].bMultivalue); } } else { if( pPL->aProperties[i].eType == SProperty::ptCategory ) { hProp = m_ctrlList.AddItem( PropCreateCategory(pPL->aProperties[i].szPropName) ); } else if( pPL->aProperties[i].eType == SProperty::ptString ) { hProp = m_ctrlList.AddItem( PropCreateSimple(pPL->aProperties[i].szPropName, pPL->aProperties[i].szString) ); } else if( pPL->aProperties[i].eType == SProperty::ptUCString ) { hProp = m_ctrlList.AddItem( PropCreateSimple(pPL->aProperties[i].szPropName, pPL->aProperties[i].szString, ES_UPPERCASE) ); } else if( pPL->aProperties[i].eType == SProperty::ptLCString ) { hProp = m_ctrlList.AddItem( PropCreateSimple(pPL->aProperties[i].szPropName, pPL->aProperties[i].szString, ES_LOWERCASE) ); } else if( pPL->aProperties[i].eType == SProperty::ptValue ) { hProp = m_ctrlList.AddItem( PropCreateSimple(pPL->aProperties[i].szPropName, pPL->aProperties[i].nValue) ); } else if( pPL->aProperties[i].eType == SProperty::ptARGBColor ) { hProp = m_ctrlList.AddItem( PropCreateColor(pPL->aProperties[i].szPropName, (RGBQUAD)ARGBCOLOR(pPL->aProperties[i].rgbColor), TRUE) ); } else if( pPL->aProperties[i].eType == SProperty::ptRGBColor ) { hProp = m_ctrlList.AddItem( PropCreateColor(pPL->aProperties[i].szPropName, (RGBQUAD)ARGBCOLOR(pPL->aProperties[i].rgbColor), FALSE) ); } else if( pPL->aProperties[i].eType == SProperty::ptRangeValue ) { hProp = m_ctrlList.AddItem( PropCreateSimple(pPL->aProperties[i].szPropName, pPL->aProperties[i].nValue, pPL->aProperties[i].nLowerRange, pPL->aProperties[i].nHigherRange, pPL->aProperties[i].dwSlider) ); } else if( pPL->aProperties[i].eType == SProperty::ptBoolean ) { hProp = m_ctrlList.AddItem( PropCreateSimple(pPL->aProperties[i].szPropName, pPL->aProperties[i].bBoolean) ); } else if( pPL->aProperties[i].eType == SProperty::ptList ) { hProp = m_ctrlList.AddItem( PropCreateList( pPL->aProperties[i].szPropName, pPL->aProperties[i].List, pPL->aProperties[i].nIndex) ); } if(hProp) { m_ctrlList.SetItemEnabled(hProp, pPL->aProperties[i].bEnabled); m_ctrlList.SetItemMultivalue(hProp, pPL->aProperties[i].bMultivalue); } } } memset(&m_PropertyList, 0, sizeof(SPropertyList)); m_PropertyList.Merge(pPL); // save the properties for later. }