C++ – Send a double click to a listview (c++, not .net!)

cclicklistviewpostmessagesendmessage

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

Best Answer

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));
Related Topic