views:

754

answers:

3

Hello. I want to send a double click to a listview. From what I've read on msdn it seems I gotta send a WM_NOTIFY message and something with NM_DBLCLK. But I do not understand really well hwo to implement it. I've worked with SendMessage before but MSDN is not that clear on how to fill the structs and so:

WM_NOTIFY http://msdn.microsoft.com/en-us/library/bb775583(VS.85).aspx NM_DBLCLK http://msdn.microsoft.com/en-us/library/bb774867(VS.85).aspx

+2  A: 

I suspect you are going down the wrong track. Probably the best way to send a double click message is to send two single clicks, one immediately after the other. This has the best chance of working and not surprising the app with a double click notification out of the blue.

If you want to send the notification to the parent window, then this might get you started:

NMITEMACTIVATE activate={0};
activate.hdr.hwndFrom = hWnd; // of the list view control
activate.hdr.idFrom = id; // of the list view control
activate.hdr.code = NM_DBLCLK;

activate.iItem = iItem; // the id of the list item to click
activate.iSubItem = iSubItem;
activate.ptAction = ptAction; // where the event occurred

::SendMessage(hWndParent, WM_NOTIFY, id, reinterpret_cast<LPNMITEMACTIVATE>(&activate));
1800 INFORMATION
The message for single click is exactly as the double click one, NM_LCLK. I don't get the point. Sure I can do a WM_LBUTTONDBLCLK, but for using that I'd have to have the clicked item visible on the screen, which I'd like to avoid if possible.
Jorge Branco
The notifaction message is sent from the list view to the parent control. There is no point in sending it to the list view. Do you want to send it to the parent?
1800 INFORMATION
I think I get your point. I thought it would be possible this way. Thanks
Jorge Branco
A: 

WM_NOTIFY is sent to the control's parent by the control to inform the parent that an event has occurred. You will accomplish nothing by sending it to the control itself.

Otherwise, I don't really understand what you're trying to do. Can you please clarify?

avakar
I have a listview on another program that on double click opens a window. That's why I need to double click the list view.
Jorge Branco
I see. In that case 1800 INFORMATION has already provided you with a solution.
avakar
A: 

it could be better generate mouse events from driver level using mouse_event API instead of sending fake WM_MOUSE messages http://msdn.microsoft.com/en-us/library/ms646260%28VS.85%29.aspx

luca