Print Page | Close Window

Context menu for Tabs?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2615
Printed Date: 08 November 2025 at 4:03pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Context menu for Tabs?
Posted By: brianh
Subject: Context menu for Tabs?
Date Posted: 21 July 2005 at 10:44am

Is there an easy way to add a context menu for the MDI tabs so that a user can right cick on them and display a menu for the selected tab, specifically I would like a 'close' option?  This would also be useful for the tab control too. Thanks.




Replies:
Posted By: Oleg
Date Posted: 21 July 2005 at 11:19pm

ON_MESSAGE(WM_XTP_PRETRANSLATEMOUSEMSG, OnWorkspaceMouseMsg)

 

LRESULT CMainFrame::OnWorkspaceMouseMsg(WPARAM wParam,LPARAM lParam)

{

CPoint point = CPoint((DWORD)lParam);

CXTPTabManagerItem* pItem = m_MTIClientWnd.HitTest(point);

if (pItem)

{

if (wParam == WM_RBUTTONDOWN)

{

CWnd* pFrame = CWnd::FromHandle(pItem->GetHandle());

MDIActivate(pFrame);

m_MTIClientWnd.Refresh();

CMenu menuPopup;

VERIFY(menuPopup.LoadMenu(IDR_WORKSAPCE_POPUP));

m_MTIClientWnd.WorkspaceToScreen(&point);

CXTPCommandBars::TrackPopupMenu(menuPopup.GetSubMenu(0), 0, point.x, point.y, this);

 

m_MTIClientWnd.Refresh();

return TRUE;

}

 

return FALSE;

}

return FALSE;

}



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: brianh
Date Posted: 25 July 2005 at 8:31am

Thanks Oleg, that's just what I needed. :)

I would also like to do the same for the CXTPTabControl tabs, any idea how?

Thanks.



Posted By: Oleg
Date Posted: 26 July 2005 at 1:51am

Only to override CXTPTabControl and its PreTranslateMessage

BOOL CTabControl2::PreTranslateMessage(MSG* pMsg)
{
  if (pMsg->message == WM_LBUTTONDOWN ||
   pMsg->message == WM_RBUTTONDOWN ||
   pMsg->message == WM_MBUTTONDOWN ||
   pMsg->message == WM_LBUTTONDBLCLK ||
   pMsg->message == WM_RBUTTONDBLCLK)
  {
   if (pMsg->hwnd != m_hWnd)
    return CXTPTabControl ::PreTranslateMessage(pMsg);

  //   doo something.

  }
 }

 return CXTPTabControl ::PreTranslateMessage(pMsg);
}



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: brianh
Date Posted: 26 July 2005 at 4:48am

Thanks Oleg, overriding PreTranslateMessage() and using the HitTest() function allows me to identify the tab being clicked, so I should be able to display a tab specific menu. :)  Thanks again.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net