/// <include file='doc\TabControlDesigner.uex' path='docs/doc[@for="TabControlDesigner.GetHitTest"]/*' />
        /// <devdoc>
        ///     Allows your component to support a design time user interface.  A TabStrip
        ///     control, for example, has a design time user interface that allows the user
        ///     to click the tabs to change tabs.  To implement this, TabStrip returns
        ///     true whenever the given point is within its tabs.
        /// </devdoc>
        protected override bool GetHitTest(Point point)
        {
            TabControl tc = ((TabControl)Control);

            // tabControlSelected tells us if a tab page or the tab control itself is selected.
            // If the tab control is selected, then we need to return true from here - so we can switch back and forth
            // between tabs.  If we're not currently selected, we want to select the tab control
            // so return false.
            if (tabControlSelected)
            {
                NativeMethods.TCHITTESTINFO tcInfo = new NativeMethods.TCHITTESTINFO();
                tcInfo.pt = Control.PointToClient(point);;
                UnsafeNativeMethods.SendMessage(Control.Handle, NativeMethods.TCM_HITTEST, 0, tcInfo);
                return(tcInfo.flags != NativeMethods.TabControlHitTest.TCHT_NOWHERE);
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// Gets hot tab index.
 /// </summary>
 /// <returns>Index of the tab over that the mouse is hovering or -1 if the mouse isn't over any tab.</returns>
 private unsafe int HitTest()
 {
     NativeMethods.TCHITTESTINFO hti = new NativeMethods.TCHITTESTINFO();
     Point mousePos = this.PointToClient(TabControl.MousePosition);
     hti.pt.x = mousePos.X; hti.pt.y = mousePos.Y;
     return (int)NativeMethods.SendMessage(this.Handle, NativeMethods.TCM_HITTEST, IntPtr.Zero, (IntPtr)(&hti));
 }
Пример #3
0
 private TabPage TabUnderMouse()
 {
     NativeMethods.TCHITTESTINFO HTI = new NativeMethods.TCHITTESTINFO(tabControl.PointToClient(Cursor.Position));
     int tabID = NativeMethods.SendMessage(tabControl.Handle, NativeMethods.TCM_HITTEST, IntPtr.Zero, ref HTI);
     return tabID == -1 ? null : tabControl.TabPages[tabID];
 }
Пример #4
0
		/// <summary>
		/// Gets hot tab index.
		/// </summary>
		/// <returns>Index of the tab over that the mouse is hovering or -1 if the mouse isn't over any tab.</returns>
		private int HitTest()
		{
			NativeMethods.TCHITTESTINFO hti = new NativeMethods.TCHITTESTINFO();
			Point mousePos = PointToClient(MousePosition);
			hti.pt.x = mousePos.X;
			hti.pt.y = mousePos.Y;

			IntPtr htiPointer = Marshal.AllocCoTaskMem(Marshal.SizeOf(hti));
			Marshal.StructureToPtr(hti, htiPointer, false);

			int result = (int)NativeMethods.SendMessage(Handle, NativeMethods.TCM_HITTEST,
				IntPtr.Zero, htiPointer);
			Marshal.DestroyStructure(htiPointer, typeof(NativeMethods.TCHITTESTINFO));
			Marshal.FreeCoTaskMem(htiPointer);

			return result;
		}
Пример #5
0
 public static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wparam, NativeMethods.TCHITTESTINFO lparam);