VOID CProfileAssociationPage::UpdateDeviceListBox() { // Add the associations to the list SendDlgItemMessage(m_hwnd, DeviceListControl, LB_RESETCONTENT, 0, 0); for (unsigned u = 0; u < AssociationCount(); u++ ) { LRESULT iItem = SendDlgItemMessage(m_hwnd, DeviceListControl, LB_ADDSTRING, 0, (LPARAM) DisplayName(u)); SendDlgItemMessage(m_hwnd, DeviceListControl, LB_SETITEMDATA, iItem, (LPARAM) Association(u)); } // If there are no associations, disable the Remove Devices button HWND hwndRemove = GetDlgItem(m_hwnd,RemoveButton); // If there are no more devices, or all are associated, disable the Add // Devices button. // // !!! To get more performance !!! // // EnableWindow(GetDlgItem(m_hwnd, AddButton), // m_pcpTarget->DeviceCount() && m_pcpTarget->DeviceCount() > AssociationCount()); // // !!! AddButton NEVER DISABLED !!! // // If focus is on Remove, move it to Add button. if (GetFocus() == hwndRemove) { HWND hwndAdd = GetDlgItem(m_hwnd, AddButton); SetFocus(hwndAdd); SendMessage(hwndRemove, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0)); SendMessage(hwndAdd, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0)); } EnableWindow(hwndRemove, !!(AssociationCount())); // If there is any device, set focus to 1st entry. if (SendDlgItemMessage(m_hwnd, DeviceListControl, LB_GETCOUNT, 0, 0)) SendDlgItemMessage(m_hwnd, DeviceListControl, LB_SETCURSEL, 0, 0); }
void Entry::associate(int entry_index, char type) { assert(num_associations < associations_size); associations[num_associations] = Association(entry_index, type); num_associations++; }