您的位置:首页 > 其它

MFC中为ListControl控件添加NM_CLICK消息选择控件中的文件并获取文件路径和文件名字

2015-06-01 16:06 621 查看
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://www.blogbus.com/shijuanfeng-logs/100675062.html

void CListDialogDlg::OnClickListCtrl(NMHDR* pNMHDR, LRESULT* pResult)

    {

       // TODO: Add your control notification handler code here

        NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

       CString str;

       str.Format(_T(“Item index: %d,SubItem:%d”), pNMListView->iItem,


            pNMListView->iSubItem);

       MessageBox(str);
       *pResult = 0;

    }

我改写后的,可以转为该路径下图像的代码

void CRelCtrlDlg::OnNMClickListPhoto(NMHDR *pNMHDR, LRESULT *pResult)

{

 // TODO: Add your control notification handler code here

 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

 CString str;

 str = m_ListCtrl.GetItemText( pNMListView->iItem, pNMListView->iSubItem ) ;

 str =  “\\”  + str;

 str = m_szPath + str;

 char *fileName = (LPSTR)(LPCTSTR)str;

 IplImage* img = cvLoadImage(fileName);

 *pResult = 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mfc listcontrol NM_CLICK