void CMainListView::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码 CString strOrderBy = CString(_T("ORDER BY bSell "));
CMainListCtrl& ctlList = (CMainListCtrl&) GetListCtrl();

ASSERT (pNMLV != NULL);
long nCurrentClickColumn = pNMLV->iSubItem; LVCOLUMN column;
ctlList.GetColumn(nCurrentClickColumn,&column);         CString szTmp = column.pszText;   /////<--我应该怎么转换啊?
         ////这样老是错 *pResult = 0;
}

解决方案 »

  1.   

    typedef struct _LVCOLUMN { 
        UINT mask; 
        int fmt; 
        int cx; 
        LPTSTR pszText; //这里的类型不是CString的,要转换,怎么转换看连接!!
        int cchTextMax; 
        int iSubItem; 
    #if (_WIN32_IE >= 0x0300)
        int iImage;
        int iOrder;
    #endif
    } LVCOLUMN, *LPLVCOLUMN; 
    http://dev.csdn.net/develop/article/12/12365.shtm
      

  2.   

    要想用GetColumn()得到标题栏信息一定要对
    column.mask域进行设置!
    比如要想得到文本请如下设置
    column.mask = LVCF_TEXT ;
    CString strTemp = clumn.pszText ;
    这样就可以了。楼主的错误就出在这里。
    因为你还没指定要对GetColumn()函数调用想到什么,当你
    调用strTemp =  column.pszText这时column.pszText指定一个无效的地址。
    所以就出错