别让MSDN忽悠了你

虽说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.

Collapse imageReturn 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.

Collapse imageRemarks

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.

Collapse imageExample

 CopyCode imageCopy Code
// 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();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
感谢您的提问。根据您的引用内容,Windows 10 Enterprise 2015 LTSB是64位和32位的企业版Win10系统。这是一个长期拥有微软后期支持的版本,会定期推送安全更新和补丁,具有较高的系统稳定性,非常适合对系统稳定性有高要求的用户。至于Windows 11,根据最新的引用内容,最新版本是经过2022年4月更新的消费者版,文件大小为5.35 GB。如果您需要更详细的信息或具体的下载链接,建议您参考MSDN网站或其他可靠的资源网站以获得最新和准确的信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [win10msdn我告诉你哪个版本好](https://blog.csdn.net/cxy11112222/article/details/105842078)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *3* [MSDN我告诉你 一个没有人注意的工具站](https://blog.csdn.net/m0_62273488/article/details/126935051)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值