List control view and button MFC vc++
-
Initially I put my button as GetDlgItem(IDC_MYBUTTON)->ShowWindow(FALSE). What I wanted to do is when I select one of the rows in the list view control, I wanted to make my button display on the dialog or visible. What will be the best way to achieve this. I would like to receive some guidance. Thank you.
-
Initially I put my button as GetDlgItem(IDC_MYBUTTON)->ShowWindow(FALSE). What I wanted to do is when I select one of the rows in the list view control, I wanted to make my button display on the dialog or visible. What will be the best way to achieve this. I would like to receive some guidance. Thank you.
You could handle TVN_SELCHANGED message from your list control, check whether some item in list control is selected and if it is then show your button, otherwise hide it
-
You could handle TVN_SELCHANGED message from your list control, check whether some item in list control is selected and if it is then show your button, otherwise hide it
Could you give one example as an explanation. Thanks.
-
Could you give one example as an explanation. Thanks.
I am awfully sorry! it is [LVN_ITEMCHANGED notification code - Windows applications | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/controls/lvn-itemchanged) you should handle! (f..g autocomplete!) Just use MFC class wizard to implement this notification. Then it its message handler write something like:
GetDlgItem(IDC_MYBUTTON)->ShowWindow(GetDlgItem()->GetSelectedCount() > 0);
-
I am awfully sorry! it is [LVN_ITEMCHANGED notification code - Windows applications | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/controls/lvn-itemchanged) you should handle! (f..g autocomplete!) Just use MFC class wizard to implement this notification. Then it its message handler write something like:
GetDlgItem(IDC_MYBUTTON)->ShowWindow(GetDlgItem()->GetSelectedCount() > 0);
Thank you so much for the example :)