在CMainFrame类中重写虚方法PreTranslateMessage处理鼠标双击事件,方法原型如下:
virtual BOOL PreTranslateMessage(MSG* pMsg);
判断鼠标双击的区域是否为多文档选项卡区域,如果是调用全屏代码使文档全屏显示。
判断鼠标双击区域关键代码如下:
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
case WM_LBUTTONDBLCLK:
{
CRect rect,b;
GetMDITabs().GetWindowRect(&rect);
POINT pt = pMsg->pt;
BOOL isAction = FALSE;
if(theApp.m_Options.m_bTabsOnTop)
{
if(pt.x > rect.left && pt.x < rect.right
&& pt.y > rect.top && pt.y < rect.top + 20)
{
isAction = TRUE;
}
}
else
{
if(pt.x > rect.left && pt.x < rect.right
&& pt.y > rect.bottom - 20 && pt.y < rect.bottom)
{
isAction = TRUE;
}
}
if(isAction)
{
//处理双击事件使用文档全屏显示
OnMaxshowtab();
return TRUE;
}
}
break;
}
return CMDIFrameWnd::PreTranslateMessage(pMsg);
}