Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Context menu for Tabs?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Context menu for Tabs?

 Post Reply Post Reply
Author
Message
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post Topic: Context menu for Tabs?
    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.

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.066 seconds.