我想在列表subitem中除了文本外,加个按钮,做了几次尝试都不成功.我做法如下,先是在header中添加定义
protect:
class CButtonEntry {
public:
CButtonEntry(int Index, int SubIndex);
virtual ~CButtonEntry();
int m_Index;
int m_SubIndex;
CButton m_button;
};
CMap <int, int, CButtonEntry*, CButtonEntry*&> m_ButtonEntries;然后在源文件中添加函数,用于程序调用来产生个按钮void CDragDropListCtrl::CreateButton(int Idx, int SubIdx)
{
// can only create progress for an existing item
if (Idx >= GetItemCount())
return; // CProgressEntry is a nested class containing Index,
// SubIndex, and CProgressCtrl members. CButtonEntry* ButtonEntry = new CButtonEntry(Idx, SubIdx);
CRect ItemRect;
GetSubItemRect(Idx, ButtonEntry->m_SubIndex, LVIR_BOUNDS,
ItemRect);
int left = ItemRect.left+4;
int top = ItemRect.top+4;
int right = ItemRect.right-4;
int bottom = ItemRect.bottom-4;
(ButtonEntry->m_button).Create(NULL,WS_CHILD | WS_VISIBLE| WS_BORDER,
CRect(left, top, right, bottom), this, 1);
m_ButtonEntries[Idx] = ButtonEntry;
}但运行到 cbutton类create 函数是程序自动断在了 _CrtDbgBreak() 里,不是很理解这个函数代表的含义.用类似的方法,在subitem里添加进度条却ok.
等待高手出现!