如何让CMFCTabCtrl关闭按钮关闭属性页
发布网友
发布时间:2022-11-05 05:55
我来回答
共1个回答
热心网友
时间:2023-10-05 10:29
CMFCTabCtrl::EnableActiveTabCloseButton
用于在CMFCTabCtrl的Tab页显示一个关闭按钮,看看关闭按钮怎么实现:
void CMFCBaseTabCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bWindowPosChanged = FALSE;
CWnd::OnLButtonDown(nFlags, point);
if (m_rectCloseButton.PtInRect(point))
{
m_bTabCloseButtonPressed = TRUE;
RedrawWindow(m_rectCloseButton);
return ;
}
...
void CMFCBaseTabCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_bTabCloseButtonPressed)
{
m_bTabCloseButtonPressed = FALSE;
m_bTabCloseButtonHighlighted = FALSE;
RedrawWindow(m_rectCloseButton);
if (m_rectCloseButton.PtInRect(point))
{
CWnd* pWndActive = GetActiveWnd();
if (pWndActive != NULL)
{
pWndActive->SendMessage(WM_CLOSE);
}
return ;
}
}