📄 subject_48804.htm
字号:
<p>
序号:48804 发表者:zhaiyl 发表日期:2003-08-04 01:01:54
<br>主题:如何得到CListCtrl里面一项的image list 里的序号?
<br>内容:ClistCtrl 选的是Icon<BR>自己画了两个图标,加入到了Imagelist<BR>序号当然是0和1了。<BR>在我双击List里面的一项时,怎么才能得到,这一项的Icon的序号呢?<BR>不知我有没有说明白。<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:野猫 回复日期:2003-08-04 01:10:42
<br>内容: int nIndex = ListCtrl->GetNextItem(-1,LVNI_ALL|LVNI_SELECTED);
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:zhaiyl 回复日期:2003-08-05 23:20:13
<br>内容:??这是Icon的序号吗?<BR>比如:我又两种Icon,序号为0和1<BR>List里面有十个Item,我随意点一个Item,想得到Icon的序号。<BR>怎么实现阿?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:兰色 回复日期:2003-08-06 08:25:56
<br>内容:你可以试试下面的方法:<BR>int nIndex;<BR>CString msg;<BR>nIndex=ListCtrl->GetSelectionMark();<BR>if(nIndex!=-1)<BR>{<BR> msg.Format("Your selection is now No.%d",nIndex);<BR> AfxMessageBox(msg);<BR>}<BR>将上面的代码加在你消息响应的地方,譬如OnLButtonDblClk()里。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:zhaiyl 回复日期:2003-08-06 13:26:13
<br>内容:兰色:<BR>GetSelectionMark()返回的应该是以0开始的Item的序号吧。<BR>可能是我没有说清楚,我想得到的是当前双击的Item的Icon的序号。<BR><BR>不知道用GetItem能不能行,我不会用啊。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:兰色 回复日期:2003-08-06 15:32:17
<br>内容:对不起,我不清楚。我只接触过选Report的CListCtrl.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:大橡胶 回复日期:2003-08-07 04:03:24
<br>内容:假如你是单项选择的话……<BR>int CXXX::GetSelectedImageIndex()<BR>{<BR> int iItem;//选中的项的索引<BR> LVITEM Item;//选中的项<BR> POSITION pos = pListCtrl->GetFirstSelectedItemPosition();<BR> if (pos==NULL) return -1;<BR> iItem = pListCtrl->GetNextSelectedItem(pos);//这几句也可以写成野猫的int iItem = pListCtrl->GetNextItem(-1,LVNI_ALL|LVNI_SELECTED); if (iItem==-1) return -1;<BR> Item.mask = LVIF_IMAGE;<BR> Item.iItem = iItem;<BR> Item.iSubItem = 0;<BR> pListCtrl->GetItem(&Item);<BR> return Item.iImage;<BR>}<BR>差不多吧。多项的就自己研究了。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:zhaiyl 回复日期:2003-08-15 17:30:55
<br>内容:谢谢大家!<BR>我已经用另一种变通的方法解决了,可能这个问题也没有什么实际意义。<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -