Reputation: 59
I have a ListView
where I display other controls on top of it. I can capture when you click one of the controls and take action. What I would like is to also send a click notification to the ListView
below it so it would act as if the ListView
was clicked. So it will select/unselect the item in the ListView
where the click happened. I want to send a click message to the ListView
rather than manually select/unselect the item because I don't want to have to try and figure out if it is a multiselect list or not, what keys are pressed, what non-clicked items need to remain selected or unselected, ... Ideally I would send a click notification to the ListView
and it would take all appropriate actions just as if it was clicked.
I have played around with calling the SendMessage
from user32.dll
- both WM_NOTIFY
and OCM_NOTIFY
with an NMITEMACTIVATE
struct as the lParam
. I cant seem to get it to work. I have also played with the OnNotifyMessage
call with no luck.
I can successfully capture the click event from the control on top of the list view, get the cursor position, translate that to the item/sub item in the ListView
below it, ... I just can't seem to programmatically send whatever notification needs to be sent to the ListView
so it takes appropriate action.
EDIT:
The possible solution in the link below will allow the click to pass through the control to the ListView below it, but you must create custom classes for all controls and you lose the ability to handle any click events in the controls on top.
Upvotes: 2
Views: 719
Reputation: 1218
You'll need to create a class that extends the control residing over the ListView and override one of its events. Here is a very similar question question to yours that should help you. https://stackoverflow.com/a/8635626/3508142
Upvotes: 2