00 向本进程窗口中的ListView窗口发送NM_DBLCLK通知(SDK代码)

Post date: 2012/4/6 上午 12:54:48

  1. // 注意这里是向本进程的ListView窗口发送NM_DBLCLK通知,通过WM_NOTIFY消息,WM_NOTIFY不能跨进程,主要是因为SendMessage发送WM_NOTIFY消息最后一个LPARAM参数是个指针。
  2. // MSDN上有明确说明:For Microsoft Windows 2000 and later systems, the WM_NOTIFY message cannot be sent between processes。
  3. int nId = ::GetDlgCtrlID(HWND_LISTVIEW); // HWND_LISTVIEW为ListView的窗口句柄
  4. NMITEMACTIVATE nmitem = {0};
  5. nmitem.hdr.code = NM_DBLCLK;
  6. nmitem.hdr.hwndFrom = HWND_LISTVIEW;
  7. nmitem.hdr.idFrom = nId;
  8. nmitem.iItem = 5;
  9. nmitem.iSubItem = 1; // 这里模拟点击ListView的第6行第2列
  10. ::SendMessage(::GetParent(HWND_LISTVIEW), WM_NOTIFY, (WPARAM)nId, (LPARAM)&nmitem);