别让MSDN忽悠了你
来源:互联网 发布:使命召唤13优化补丁 编辑:程序博客网 时间:2024/06/02 15:40
虽说MSDN代码是微软的高手写的,很正确很权威.不过它有时候也有很龌龊的一面,为了不影响到广大的青少年和小朋友们,下面举例说明:MSDN为VS2005版,查询函数CListBox::DeleteString的说明如下
Deletes the item in position nIndex from the list box.
int DeleteString( UINT nIndex );
Parameters
- nIndex
Specifies the zero-based index of the string to be deleted.
Return Value
A count of the strings remaining in the list. The return value is LB_ERR if nIndex specifies an index greater than the number of items in the list.
Remarks
All items following nIndex now move down one position. For example, if a list box contains two items, deleting the first item will cause the remaining item to now be in the first position. nIndex=0 for the item in the first position.
Example
// The pointer to my list box.extern CListBox* pmyListBox;// Delete every other item from the list box.for (int i=0;i < pmyListBox->GetCount()/*每次大小都减一*/;i++){ pmyListBox->DeleteString( i );//并不是我们预料的那样删除,因为删除一个后,后面的元素索引将前移一位
}
正确的做法应该是
for (int i(pmyListBox->GetCount()-1);i >=0;--i){ pmyListBox->DeleteString( i );}
以上只是为了说明DeleteString的用法,如果想达到上述目的,
可以while(LB_ERR!=pComBox->DeleteString(0));
或者更直接pComBox->ResetContent();
- 别让MSDN忽悠了你
- 别忽悠“老年人”了
- 小心别被“忽悠”了
- 别让店小二宠坏了你
- 别让缺点限制了你
- 别让手机把你绑架了
- 别让PPT把你绑架了
- 历史真相别被忽悠了
- 别让你的经验杀了你的未来
- 小心你的小动作,别让它暴露了你
- 别让性格误了你的职场好事
- IT项目经理,你别让激情烧过了头
- IT项目经理,你别让激情烧过了头
- 别让Hibernate偷走了你的标识符
- 做回你自己,别让汽车控制了你
- 别让欲望吞噬了你的幸福
- 《别让不会说话害了你》---读书笔记
- 读书系列----《别让情绪失控害了你》
- 那根胡萝卜---走出软件作坊:三五个人十来条枪 如何成为开发正规军(十五)
- 汉编软件入驻中国共享软件注册中心
- 小小的收获
- 关于umask
- jar命令的使用
- 别让MSDN忽悠了你
- 将Excel中所有Sheet的数据导入一个DataSet
- 安盛现身中南大厦 华南联手补缺北部商圈
- 百灵报表(Eclipse BIRT)中的边框样式
- 世界粮食峰会举行 领导人一律“粗茶淡饭”
- Installshield 2008 And 脚本 (六)
- 网页变成黑白的
- RFC1867协议介绍
- 通过 http 协议上传文件