我正在用标签在 MFC 中编写一个应用程序。我正在CTabView
用自己的课程扩展课程。
我想在关闭活动选项卡时捕获事件并将其从 TabView 中实际删除。
该消息WM_LBUTTONUP
从未在这里处理过-在任何子类中都没有处理过-我做错了什么?
当我关闭活动标签时,我可以在哪里捕捉事件?
IMPLEMENT_DYNCREATE(CBottomTabView, CTabView)
BEGIN_MESSAGE_MAP(CBottomTabView, CTabView)
ON_WM_CREATE()
ON_WM_LBUTTONUP()
END_MESSAGE_MAP()
CBottomTabView::CBottomTabView()
{
}
CBottomTabView::~CBottomTabView()
{
}
BOOL CBottomTabView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CTabView::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), NULL);
return TRUE;
}
int CBottomTabView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabView::OnCreate(lpCreateStruct) == -1)
return -1;
GetTabControl().SetLocation(CMFCBaseTabCtrl::LOCATION_BOTTOM);
GetTabControl().ModifyTabStyle(CMFCTabCtrl::STYLE_3D_ONENOTE);
GetTabControl().EnableTabDocumentsMenu(TRUE);
GetTabControl().EnableActiveTabCloseButton(TRUE);
GetTabControl().EnableTabSwap(TRUE);
AddView(RUNTIME_CLASS(CLogView),_T("Log"));
AddView(RUNTIME_CLASS(CLogView),_T("Log2"));
AddView(RUNTIME_CLASS(CLogView),_T("Log3"));
return 0;
}
// This method is never handled!!!
void CBottomTabView::OnLButtonUp(UINT nFlags, CPoint point)
{
int nTab = GetTabControl().GetTabFromPoint(point);
GetTabControl().SetActiveTab(nTab);
if (GetTabControl().IsTabCloseButtonPressed())
{
RemoveView(nTab);
}
else
{
CTabView::OnLButtonUp(nFlags, point);
}
}
// This metod is handled only when changing the tab
void CBottomTabView::OnActivateView(CView* view)
{
CTabView::OnActivateView(view);
}