protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
// Selection of tabs via mouse
if (m.Msg == 0x201 /*WM_LBUTTONDOWN*/)
{
System.Windows.Forms.TabControl control = (System.Windows.Forms.TabControl)Component;
int lParam = m.LParam.ToInt32();
Point hitPoint = new Point(lParam & 0xffff, lParam >> 0x10);
if (Control.FromHandle(m.HWnd) == null) // Navigation
{
if (hitPoint.X < 18 && control.SelectedIndex > 0) // Left
{
control.SelectedIndex--;
}
else
{
control.SelectedIndex++; // Right
}
}
else // Header click
{
for (int i = 0; i < control.TabCount; i++)
{
if (control.GetTabRect(i).Contains(hitPoint))
{
control.SelectedIndex = i;
return;
}
}
}
}
}