Click here to Skip to main content
15,911,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwhy CListCtl::InsertItem() would crash? Pin
kcynic25-Dec-07 17:05
kcynic25-Dec-07 17:05 
AnswerRe: why CListCtl::InsertItem() would crash? Pin
Maxwell Chen25-Dec-07 17:15
Maxwell Chen25-Dec-07 17:15 
GeneralRe: why CListCtl::InsertItem() would crash? [modified] Pin
kcynic25-Dec-07 17:34
kcynic25-Dec-07 17:34 
AnswerRe: why CListCtl::InsertItem() would crash? Pin
Naveen25-Dec-07 18:25
Naveen25-Dec-07 18:25 
GeneralRe: why CListCtl::InsertItem() would crash? Pin
kcynic25-Dec-07 18:32
kcynic25-Dec-07 18:32 
GeneralRe: why CListCtl::InsertItem() would crash? Pin
Naveen25-Dec-07 18:33
Naveen25-Dec-07 18:33 
GeneralRe: why CListCtl::InsertItem() would crash? Pin
kcynic25-Dec-07 18:53
kcynic25-Dec-07 18:53 
GeneralRe: why CListCtl::InsertItem() would crash? Pin
kcynic25-Dec-07 22:27
kcynic25-Dec-07 22:27 
Now,I found that,the problem is not InsertItem,but is CString or std::wstring.
//
std::wstring get_wstring(int tag)
{
wchar_t * s = NULL;
int len = function_ret_wstring(tag,&s);//return the characters in s,s is null terminated
std::wstring ss = s;
free(s);//s was alloced by function_ret_wstring() on heap
return ss;
}
//in the UI
void SomeClass::ShowItems()
{
for(int i=0;i<item_count;++i)>
{
CString temp(L"");

temp = get_wstring(tag1).c_str();
m_list.InsertItem(i,temp);

temp = get_wstring(tag2).c_str();
m_list.SetItemText(i,1,temp);

temp = get_wstring(tag3).c_str();
m_list.SetItemText(i,2,temp);
}
}

It is very strang,the codes work well on some computers,but would crash on some computers,too.
Because,the computer which run the codes crashedly have no VC installed,I could not debug.But I think the problem is the deconstructor of CString or std::wstring,Someone would like to give me some advise I will be very appreciate.

Thanks
GeneralRe: why CListCtl::InsertItem() would crash? Pin
Naveen25-Dec-07 23:10
Naveen25-Dec-07 23:10 
GeneralRe: why CListCtl::InsertItem() would crash? Pin
kcynic26-Dec-07 14:22
kcynic26-Dec-07 14:22 
AnswerRe: why CListCtl::InsertItem() would crash? Pin
peterchen26-Dec-07 0:02
peterchen26-Dec-07 0:02 
GeneralRe: why CListCtl::InsertItem() would crash? Pin
kcynic26-Dec-07 14:26
kcynic26-Dec-07 14:26 
QuestionGDI+ Set Image DPI (win32) Pin
r3dqu33n25-Dec-07 16:22
r3dqu33n25-Dec-07 16:22 
GeneralRe: GDI+ Set Image DPI (win32) Pin
followait25-Dec-07 17:48
followait25-Dec-07 17:48 
GeneralDesktop_.ini file is getting created in InstallShield Pin
AnayKulkarni25-Dec-07 3:11
AnayKulkarni25-Dec-07 3:11 
GeneralRe: Desktop_.ini file is getting created in InstallShield Pin
Kiran Pinjala26-Dec-07 1:38
Kiran Pinjala26-Dec-07 1:38 
GeneralError in MD5Init() Function Pin
Developer61124-Dec-07 23:40
Developer61124-Dec-07 23:40 
GeneralRe: Error in MD5Init() Function Pin
CPallini25-Dec-07 3:21
mveCPallini25-Dec-07 3:21 
GeneralRe: Error in MD5Init() Function Pin
Developer61126-Dec-07 0:48
Developer61126-Dec-07 0:48 
QuestionHow to search a Subitem in list control? Pin
Rad.Krish24-Dec-07 23:32
Rad.Krish24-Dec-07 23:32 
GeneralRe: How to search a Subitem in list control? Pin
CPallini25-Dec-07 2:55
mveCPallini25-Dec-07 2:55 
GeneralLarge File Processing Pin
Sangeetha_J24-Dec-07 23:10
Sangeetha_J24-Dec-07 23:10 
GeneralRe: Large File Processing Pin
CPallini24-Dec-07 23:39
mveCPallini24-Dec-07 23:39 
GeneralRe: Large File Processing Pin
Sangeetha_J24-Dec-07 23:54
Sangeetha_J24-Dec-07 23:54 
GeneralRe: Large File Processing Pin
CPallini25-Dec-07 2:43
mveCPallini25-Dec-07 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.