VC 右键点击listctrl的item弹出菜单
15.右键点击listctrl的item弹出菜单添加listctrl控件的NM_RCLICK消息相应函数voidCTest6Dlg::OnRclickList1(NMHD...
15. 右键点击listctrl的item弹出菜单
添加listctrl控件的NM_RCLICK消息相应函数
void CTest6Dlg::OnRclickList1(NMHDR*
pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView =
(NM_LISTVIEW*)pNMHDR;
if(pNMListView->iItem !=
-1)
{
DWORD dwPos =
GetMessagePos();
CPoint point( LOWORD(dwPos), HIWORD(dwPos)
);
CMenu menu;
VERIFY(
menu.LoadMenu( IDR_MENU1 ) );
CMenu* popup =
menu.GetSubMenu(0);
ASSERT( popup != NULL
);
popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this );
}
*pResult = 0;
}
///
在vs2012上编译通过
代码网上找来的,但是运行后,右键点击listctrl其中一项,程序崩溃,哪里错了,快告诉我啊 展开
添加listctrl控件的NM_RCLICK消息相应函数
void CTest6Dlg::OnRclickList1(NMHDR*
pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView =
(NM_LISTVIEW*)pNMHDR;
if(pNMListView->iItem !=
-1)
{
DWORD dwPos =
GetMessagePos();
CPoint point( LOWORD(dwPos), HIWORD(dwPos)
);
CMenu menu;
VERIFY(
menu.LoadMenu( IDR_MENU1 ) );
CMenu* popup =
menu.GetSubMenu(0);
ASSERT( popup != NULL
);
popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this );
}
*pResult = 0;
}
///
在vs2012上编译通过
代码网上找来的,但是运行后,右键点击listctrl其中一项,程序崩溃,哪里错了,快告诉我啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询