tags:

views:

29

answers:

2

I have 3 list control on one dialog box but only one is showing focus. if i clicked on 2nd list control then focus disaappear from 1st one. Means at a time only one list showing focus. How to make focus remain on all list control on same dialog box?

+1  A: 

I don't think that this is technically possible. 'Focus' is an attribute that can only be applied to an individual element.

Think of it in terms of 'focus' is the element that the user is currently interacting with. How would a user be expected to interact with 3 distinct elements at the same time?

Brian Scott
i am making a list control in which a element is color on which if user click then other list will be open which shows color that has been selected.is there any way to get the focus or highlight on every list.
@user323422: Sorry, I don't understand the issue you are having. Please explain with more detail and perhaps with some example code?
Brian Scott
A: 

As Brian says - focus can only be on one control at time. I'm guessing you are trying to change the other list controls based on the first list box. One way to do it is to associate a variable with each list control, like mListCtrl1, mListCtrl2. Then add a handler for the NM_CLICK event, and have some code like this:

void CTabTestDlg::OnNMClickList3(NMHDR *pNMHDR, LRESULT *pResult)
{
   LPNMITEMACTIVATE pNMItemActivate = (LPNMITEMACTIVATE)(pNMHDR);
   // TODO: Add your control notification handler code here
   *pResult = 0;
   UpdateData(true);
   DWORD dwData = mListCtrl1.GetItemData(pNMItemActivate->iItem);
   int max = mListCtrl2.GetItemCount();
   for (int i=0;i<max;i++)
   {
      DWORD dwData2 = mListCtrl2.GetItemData(i);
      if (dwData==dwData2)
      {
         mListCtrl2.SetItemState(i,LVIS_SELECTED,LVIS_SELECTED);
         break;
      }
   }
   UpdateData(false);
}

Note that I have the control set to "Always show selection", and "Single selection"

Jeff
u understood problem correctly but i am using list control. in list control i am using SetItemState() and applied thesame logic as yours but it is not showing selection in 2nd list if i clicked on list item.any clue?
yes its working:)