// Creates a new grid cell and performs any necessary initialisation
CGridCell* CGridCtrl::CreateCell(int nRow, int nCol)
{
CGridCell* pCell = new CGridCell;
if (!pCell)
return NULL;
// Make format same as cell above
if (nRow > 0 && nCol >= 0 && nCol < m_nCols)
pCell->nFormat = GetItemFormat(nRow-1, nCol);
// Make font default grid font
memcpy(&(pCell->lfFont), &m_Logfont, sizeof(LOGFONT));
return pCell;
}编译器提示该处发生了内存泄漏,请问有人用过吗?如何解决???多谢!!
CGridCell* CGridCtrl::CreateCell(int nRow, int nCol)
{
CGridCell* pCell = new CGridCell;
if (!pCell)
return NULL;
// Make format same as cell above
if (nRow > 0 && nCol >= 0 && nCol < m_nCols)
pCell->nFormat = GetItemFormat(nRow-1, nCol);
// Make font default grid font
memcpy(&(pCell->lfFont), &m_Logfont, sizeof(LOGFONT));
return pCell;
}编译器提示该处发生了内存泄漏,请问有人用过吗?如何解决???多谢!!
CGridCell* pCell = new CGridCell;创建了新的CGridCell指针,它并不在本函数中被释放,因此你必须自己调用delete pCell才能解决这个泄漏问题。
比如CGridCell *pCell = m_GridCtrl.CreateCell();
delete pCell;
这样才能释放掉
进入后, 搜索 CGridCtrl
有没有版本可以实现类似功能的?