An application can determine what is displayed at a given location of the control, for example to show a context menu for the tab under the mouse cursor.
The SftTabs.HitTest method returns a TabHitTestInfo object describing the given location, in client coordinates of the control: the area (TabHitTestInfo.Area property), the tab (TabHitTestInfo.Tab property) and the tab part (TabHitTestInfo.Part property). The SftTabs.TabFromPoint method returns just the tab.
These areas are distinguished (see TabHitAreaEnum):
| Area | Description |
|---|---|
| TabHitAreaEnum.Tab | The location is on a tab. |
| TabHitAreaEnum.TabCloseButton | The location is on a tab's close button. |
| TabHitAreaEnum.ScrollBackwardButton, TabHitAreaEnum.ScrollForwardButton | The location is on a scroll button. |
| TabHitAreaEnum.CloseButton, TabHitAreaEnum.MinimizeButton, TabHitAreaEnum.RestoreButton | The location is on the control's Close, Minimize or Restore button. |
| TabHitAreaEnum.Strip | The location is on the tab row, outside of any tab or button. |
| TabHitAreaEnum.Page | The location is on the tab page area. |
| TabHitAreaEnum.Nowhere | The location is outside the control. |
C#
private void sftTabs1_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Right) {
TabClass tab = sftTabs1.TabFromPoint(e.Location);
if (tab != null)
tabMenu.Show(sftTabs1, e.Location);
}
}VB
Private Sub SftTabs1_MouseDown(sender As Object, e As MouseEventArgs) Handles SftTabs1.MouseDown If e.Button = MouseButtons.Right Then Dim tab As TabClass = SftTabs1.TabFromPoint(e.Location) If tab IsNot Nothing Then TabMenu.Show(SftTabs1, e.Location) End If End If End Sub
The location and size of a tab are returned by the SftTabs.GetTabBounds method and the TabClass.Bounds property. The TabClass.Displayed property returns whether a tab is currently displayed; a tab that is hidden or scrolled out of view is not. The SftTabs.StripBounds property returns the area of the tab row and the SftTabs.DisplayRectangle property the area of the tab pages.
See Also Tab Control Components