请问各位大侠如何CListView中的视图中响应ITEMDBLClICK事件?能实现吗,我没有找到相应的函数。HDN_ITEMDBLCLICK怎么用,最好能举个例子,谢谢了。
解决方案 »
- 我的数组内的对象是通过指针来操作的,我想抒某个对象进行再复制一份或把对象的内部再复制一份要怎么来实现。请高手指教。
- MFC ActiveX控件在IE中能通知道IE(javastript)做一些事情吗?
- 求代理服务器的技术文档,及程序源码
- 是否有必要学习vc的界面设计技巧
- 生成按钮等等的那个工具体丢了怎么找出来?
- 这里人气旺。请教大伙,CLEARCASE如何进行权限配置?
- 怎样屏蔽键盘和鼠标响应?在线等候中~~~~~~~~~~~!
- 监测网络数据,马上给分,在线等待!
- 我想知道vc++的发展前景如何,和java比怎样?
- 线程中使用PostMessage的一个问题
- 难道Receive()只能一下子接收所有发送的数据量?
- COM技术内幕示例的编译问题,求助!
响应WM_LBUTTONDBLCLK消息,通过MOUSE点击点找到被双击的ITEM。操作:
在你的CListCtrl派生类中唤出class wizard,选message maps,选WM_LBUTTONDBLCLK,按下Add Function,按edit code。代码:
void CMyListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CListCtrl::OnLButtonDblClk(nFlags, point); ClientToScreen(&point);
CPoint pt(0,0);
::GetCursorPos(&pt);
ScreenToClient(&pt); LVHITTESTINFO info;
info.pt = pt;
this->HitTest(&info); //do your work here.
MessageBox("icelight?");
}
POINT pt;
UINT flags;
int iItem;
int iSubItem;
} LVHITTESTINFO, FAR *LPLVHITTESTINFO;
对不起,能再问你一下吗,我是在单文档中的listview中GetListCtrl()中调用,怎么用啊!相应单击。
enum { IDD = _UNKNOWN_RESOURCE_ID_ };
改为你建的dialog模板的ID。再用向导为模板里的list box建一个control的对象。然后在头文件里将CListCtrl m_list改为CMyListCtrl m_list就能用上面所写的代码了。
---------------------
void CListChildView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here /*
在这里添加响应列表控件的鼠标双击消息的代码
相关数据结构:
typedef struct tagNMHDR {
HWND hwndFrom; //消息句柄
UINT idFrom; //控件id
UINT code; //消息通知码
} NMHDR;
typedef struct _HD_ITEM { hdi
UINT mask; //屏蔽码:关键,指定了下面的数据项的有效性
int cxy; //列表项的宽度/高度
LPSTR pszText; //
HBITMAP hbm;
int cchTextMax;
int fmt;
LPARAM lParam;
} HD_ITEM; typedef struct _HD_NOTIFY {
NMHDR hdr;
int iItem; //激发消息的列表框的item
int iButton; //0:left button,1:right button,2:middle button
HD_ITEM FAR *pitem;
} HD_NOTIFY;
详细解释见msdn 例如:
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
int nSelected=phdn->iItem;
......
然后利用发送消息的方式与别的窗口通信!即可满足你的要求!
*/
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
int nSelected=phdn->iItem;
CMainFrame *pFrame=(CMainFrame*)AfxGetMainWnd();
//Send message to the mainframe windows!
if(nSelected!=-1)//empty listctrl!
pFrame->PostMessage(WM_MSG_FROM_LISTDLG,MAKELRESULT(nSelected+1, 0),0);} afx_msg LRESULT OnListenMessage(WPARAM wParam,LPARAM lParam);
ON_MESSAGE(WM_MSG_FROM_LISTDLG,OnListenMessage)
LRESULT CMainFrame:: OnListenMessage(WPARAM wParam,LPARAM lParam)
{
int index=int(wParam);
CString str;
str.Format("You have choosed the the %dth item!",index);
MessageBox(str);
return true;
}
--------------
程序的功能是,跟踪当前双击的列表框的item的位置!
再mainframe 中相应消息
typedef struct tagNMHDR {
HWND hwndFrom; //消息句柄
UINT idFrom; //控件id
UINT code; //消息通知码
} NMHDR;
typedef struct _HD_ITEM { hdi
UINT mask; //屏蔽码:关键,指定了下面的数据项的有效性
int cxy; //列表项的宽度/高度
LPSTR pszText; //
HBITMAP hbm;
int cchTextMax;
int fmt;
LPARAM lParam;
} HD_ITEM; typedef struct _HD_NOTIFY {
NMHDR hdr;
int iItem; //激发消息的列表框的item
int iButton; //0:left button,1:right button,2:middle button
HD_ITEM FAR *pitem;
} HD_NOTIFY;的结构就行了!