aiwaweiwei 发表于 2006-8-13 12:32:00

停靠栏的问题,希望好心人帮帮忙看看,问题该怎么解决

<P>我在停靠栏上放了listcontrol控件,代码如下:要实现当停靠栏显示时,listcontrol中的数据也显示出来!extern _ConnectionPtr pConn;<BR>BOOL CAcDialogBar::Create (CFrameWnd *pParent, UINT nIDTemplate, UINT style, UINT nID) {<BR>&nbsp;if ( !CDialogBar::Create (pParent, nIDTemplate, style, nID) )<BR>&nbsp;&nbsp;return (FALSE) ;<BR>&nbsp;mSizeCurrent =m_sizeDefault ;<BR>&nbsp;&nbsp;&nbsp; CAcDialogBar m_MyBar;<BR>&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.SubclassDlgItem(IDC_LS_COPeople,this); <BR>&nbsp;&nbsp;&nbsp; DWORD dwStyle = m_ctrlCoPeople.GetExtendedStyle();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dwStyle |= LVS_EX_FULLROWSELECT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dwStyle |= LVS_EX_GRIDLINES;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.SetExtendedStyle(dwStyle); //设置扩展风格<BR>&nbsp;m_ctrlCoPeople.InsertColumn(0,"协同用户");<BR>&nbsp;m_ctrlCoPeople.InsertColumn(1,"协同方式");<BR>&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.InsertColumn(2,"用户IP");<BR>&nbsp;m_ctrlCoPeople.InsertColumn(3,"协同项目");<BR>&nbsp;m_ctrlCoPeople.InsertColumn(4,"协同模块");&nbsp;&nbsp;<BR>&nbsp;m_ctrlCoPeople.SetColumnWidth(0,100);//设置列的宽度。<BR>&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.SetColumnWidth(1,100);<BR>&nbsp;m_ctrlCoPeople.SetColumnWidth(2,100);<BR>&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.SetColumnWidth(3,100);<BR>&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.SetColumnWidth(4,100);&nbsp;&nbsp;&nbsp;<BR>&nbsp;CString vsql,vstrType,vstrName,vstrIp,vstrPid,vstrMid;<BR>&nbsp;_RecordsetPtr vst;<BR>&nbsp;_variant_t Holder;<BR>&nbsp;int i = 0;<BR>&nbsp;vst.CreateInstance(__uuidof(Recordset));<BR>&nbsp;&nbsp;&nbsp; vsql.Format("SELECT * FROM tempcoinfo");<BR>&nbsp;&nbsp;&nbsp; vst-&gt;Open(_variant_t(vsql),pConn.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);<BR>&nbsp;&nbsp;&nbsp; if(!vst-&gt;adoEOF)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;m_ctrlCoPeople.DeleteAllItems();<BR>&nbsp;&nbsp;vst-&gt;MoveFirst();<BR>&nbsp;&nbsp;while (!vst-&gt;adoEOF)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LV_ITEM lvitem;<BR>&nbsp;&nbsp;&nbsp;lvitem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;<BR>&nbsp;&nbsp;&nbsp;lvitem.state = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;lvitem.stateMask = 0; <BR>&nbsp;&nbsp;&nbsp;//char temp;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;lvitem.iItem = i;<BR>&nbsp;&nbsp;&nbsp;lvitem.iSubItem = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //lvitem.pszText =itoa(i, temp, 10); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //m_ctrlCoPeople.InsertItem(&amp;lvitem);<BR>&nbsp;&nbsp;&nbsp;Holder=vst-&gt;GetCollect("tempType");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vstrType = Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Holder=vst-&gt;GetCollect("tempname");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;vstrName= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Holder=vst-&gt;GetCollect("tempip");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vstrIp= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Holder=vst-&gt;GetCollect("coprojectid");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vstrPid= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Holder=vst-&gt;GetCollect("comodeid");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vstrMid= Holder.vt==VT_NULL?"":(char *)(_bstr_t)Holder;&nbsp; <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;lvitem.pszText =(LPSTR)LPCSTR(vstrName) ;<BR>&nbsp;&nbsp;&nbsp;m_ctrlCoPeople.InsertItem(&amp;lvitem);&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;m_ctrlCoPeople.SetItemText(i,1,(LPCTSTR)vstrType);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ctrlCoPeople.SetItemText(i,2,(LPCTSTR)vstrIp);<BR>&nbsp;&nbsp;m_ctrlCoPeople.SetItemText(i,3,(LPCTSTR)vstrPid);<BR>&nbsp;m_ctrlCoPeople.SetItemText(i,4,(LPCTSTR)vstrMid); <BR>&nbsp;&nbsp;&nbsp;vst-&gt;MoveNext();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i=i+1;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;}<BR>&nbsp;&nbsp;&nbsp; vst-&gt;Close();<BR>&nbsp;&nbsp;&nbsp; delete vst;&nbsp;<BR>&nbsp;return (TRUE) ;<BR>}<BR>可是当运行时,所有m_ctrlCoPeople.SetItemText()语句只能在最后一条记录显示出数据来,其余的都不显示查询到的数据,请问该问题怎么解决,谢谢!!!</P>
页: [1]
查看完整版本: 停靠栏的问题,希望好心人帮帮忙看看,问题该怎么解决