0

I want to detect when user clicks the Tab itself and the blank Tabs area in WeifenLuo.WinFormsUI.Docking component. To be specific:

Tab events

  1. Detect mouse wheel click on any Tab (marked with green)
  2. Detect right mouse click on empty space (marked with blue)

How to achieve that? I could not find any registered event for that purpose.

DerStarkeBaer
  • 669
  • 8
  • 28
Slappy
  • 5,250
  • 1
  • 23
  • 29
  • Not supported. You can only hack the code to implement your own events. – Lex Li Jul 27 '20 at 05:02
  • Can you tell more about how to implement own events? And also move your comment to answer so I can accept it so the other users know this is not supported. – Slappy Jul 28 '20 at 05:37
  • That control already has several events for similar things, which can be your example. I don't think I am giving an answer here. You can later post what you learn as an answer instead. – Lex Li Jul 28 '20 at 19:56

1 Answers1

0

I hadn't seen this post when I asked basically the same question stated differently for a slightly different goal. I got no answers either and no comments at all. I did come up with a solution for my goal using reflection. You can adapt it for your own use. See this post: Using DockPanelSuite, how do you get context menu for tab strip separate from document tab?

Edit:

Adding a summary to include essential parts as recommended by Noel

Summary:

You can't access the Tabs directly as they are protected, internal items. Additionally, the tabstrip seems to only be accessible after a document is placed on it and made active. I wasn't able to find an event for when the document pane or tabstrip gets created. You can use the DockPanel.ActiveDocumentChanged event to attach a mouse up event handler to the tabstrip via the DockPanel.ActiveDocumentPane.TabStripControl property.

In the mouse up event handler you'll need to access the tabs via reflection to see if the mouse pointer is over one of the tabs. The tabs themselves are not controls. They are really just an object that contains a reference to the document and the rectangle where the tab is drawn on the tabstrip.

Brad R.
  • 13
  • 5
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33596971) – Noel Jan 12 '23 at 19:31
  • Good point Noel. Added to the answer. – Brad R. Jan 12 '23 at 20:16