大多数如何创建桌面警报的示例如下所示。它使用 new 关键字创建新的 CMFCDesktopAlertWnd,用于创建 CMFCDesktopAlertDialog。这些示例都没有在函数末尾删除对象,所以我想有些东西正在释放内存。什么是释放内存?
CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd;
// int m_nAnimation
pPopup->SetAnimationType ((CMFCPopupMenu::ANIMATION_TYPE) m_nAnimation);
// int m_nAnimationSpeed
pPopup->SetAnimationSpeed (m_nAnimationSpeed);
// int m_nTransparency
pPopup->SetTransparency ((BYTE)m_nTransparency);
// BOOL m_bSmallCaption
pPopup->SetSmallCaption (m_bSmallCaption);
// BOOL m_bAutoClose, int m_nAutoCloseTime
pPopup->SetAutoCloseTime (m_bAutoClose ? m_nAutoCloseTime * 1000 : 0);
// int m_nPopupSource
if (m_nPopupSource == 0)
{
// int m_nVisualMngr
// CPoint m_ptPopup
// The this pointer points to a CDesktopAlertDemoDlg class which extends the CDialogEx class.
if (m_nVisualMngr == 5) // MSN-style
{
pPopup->Create (this, IDD_DIALOG2, NULL, m_ptPopup, RUNTIME_CLASS (CMSNDlg));
}
else
{
pPopup->Create (this, IDD_DIALOG1,
m_menuPopup.GetSubMenu (0)->GetSafeHmenu (), m_ptPopup, RUNTIME_CLASS (CMyPopupDlg));
}
}