我正在填写一个组合框:
while((pHPSet = pHPTable->GetNext()) != NULL)
{
CString str = pHPSet->GetName();
// I am normally using str but to proove that this is
// not the problem I am using "a"
m_comboBaseHP.AddString(_T("a"));
}现在,我正在尝试读取组合框:
if(m_comboBaseHP.GetCount() > 0)
{
CString csHPName = _T("");
m_comboBaseHP.GetLBText(0, csHPName);
// This is the ms way but ReleaseBuffer causes a crash
//CString str = _T("");
//int n = m_comboBaseHP.GetLBTextLen( 0 );
//m_comboBaseHP.GetLBText( 0, str.GetBuffer(n) );
//str.ReleaseBuffer();
// Do whatever with csHPName
}问题是csHPName在调试器中显示了一些中文符号。我假设这是内存垃圾。这发生在相同的方法中。这发生在pre draw中。Post绘制了同样的问题。这发生在Debug和Release中。我不明白这是怎么发生的,因为我实际上并不是在使用指针。
发布于 2013-02-01 19:33:09
显然,有必要将属性Has Strings of the combobox设置为True。
https://stackoverflow.com/questions/14644947
复制相似问题