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

来源:互联网 发布:英语六级听力软件那个 编辑:程序博客网 时间:2024/05/20 02:27
  • 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    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;
    }

0 0
原创粉丝点击