Clistctrl中的问题 [英] Question in Clistctrl

查看:50
本文介绍了Clistctrl中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

我正在使用
在CListCtrl中插入值

Problem:

I am inserting the values in CListCtrl with

int iItem = m_listModules.InsertItem(9999, csTmp);

//where csTemp is 45.

//using LVN_INSERTITEM which takes it to the function Func1() which has

NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
   
    onInsertItem(pNMListView->iItem, &m_listModules)

onInsertItem(int iItem, CListCtrl *pListCtrl)
{
     CString csRunFile;
    long ldataitem = long(pListCtrl->GetItemData(iItem));

}


这是代码流

现在在ldataitem中,我得到0作为返回,而我要插入45.

请帮助

在此先谢谢您..


This is the flow of code

Now in ldataitem i m getting 0 as a return where as i am inserting 45.

please help

Thanks in advance..

推荐答案

您应该使用 ^ ]功能.

函数 GetItemData [ LVITEM [
You should be using the GetItem[^] function.

The function GetItemData[^] returns the 32-bit application-specific value associated with the specified item. You have set no such value in the code you shown.

Answer to OP comment:

You need to specify which items information you want to retrieve, this is done in the LVITEM structure you pass to the GetItem function.
Look at the LVITEM[^] documentation.

You can use the following code:
onInsertItem( int iItem, CListCtrl* pListCtrl )
{
	LVITEM plvItem;
	long lDataItem = 0;

	plvItem.mask = LVIF_TEXT;
	plvItem.iItem = iItem;
	if( pListCtrl != NULL && pListCtrl->GetItem( &plvItem ) )
		lDataItem = atol( plvItem.pszText );
}


I used GetItemText instead of GetItemData and it solved my purpose.

Thanks


这篇关于Clistctrl中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆