コード例 #1
0
        protected override bool GetHitTest(Point point)
        {
            if (SelectionService.PrimarySelection == Control)
            {
                TCHITTESTINFO _tabControlHitTestInfo = new TCHITTESTINFO {
                    Point = Control.PointToClient(point), Flags = 0
                };

                Message _message = new Message {
                    HWnd = Control.Handle, Msg = 0x130D
                };

                IntPtr _longIntParameter = Marshal.AllocHGlobal(Marshal.SizeOf(_tabControlHitTestInfo));
                Marshal.StructureToPtr(_tabControlHitTestInfo, _longIntParameter, false);
                _message.LParam = _longIntParameter;

                base.WndProc(ref _message);
                Marshal.FreeHGlobal(_longIntParameter);

                if (_message.Result.ToInt32() != -1)
                {
                    return(_tabControlHitTestInfo.Flags != TabControlHitTest.TCHT_NOWHERE);
                }
            }

            return(false);
        }
コード例 #2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            TCHITTESTINFO HTI = new TCHITTESTINFO(e.X, e.Y);

            HotTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);
        }
コード例 #3
0
        private void _tc_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                var HTI    = new TCHITTESTINFO(e.X, e.Y);
                var hotTab = _tc.TabPages[SendMessage(_tc.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI)];
                _tc.SelectedIndex = hotTab.TabIndex;
            }

            for (var i = 0; i < _tc.TabPages.Count; i++)
            {
                var tabRect = this._tc.GetTabRect(i);
                tabRect.Inflate(-2, -2);
                var closeImage = new Bitmap(Resources._5657_close);
                var imageRect  = new Rectangle(
                    (tabRect.Right - closeImage.Width),
                    tabRect.Top + (tabRect.Height - closeImage.Height) / 2,
                    closeImage.Width,
                    closeImage.Height);

                if (imageRect.Contains(e.Location) && _tc.TabPages.Count > 1)
                {
                    _tc.TabPages.RemoveAt(i);
                    break;
                }
            }
        }
コード例 #4
0
        protected override bool GetHitTest(Point point)
        {
            if (this.SelectionService.PrimarySelection == this.Control)
            {
                TCHITTESTINFO hti = new TCHITTESTINFO();

                hti.pt    = this.Control.PointToClient(point);
                hti.flags = 0;

                Message m = new Message();
                m.HWnd = this.Control.Handle;
                m.Msg  = TCM_HITTEST;

                IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(hti));
                Marshal.StructureToPtr(hti, lparam, false);
                m.LParam = lparam;

                base.WndProc(ref m);
                Marshal.FreeHGlobal(lparam);

                if (m.Result.ToInt32() != -1)
                {
                    return(hti.flags != TabControlHitTest.TCHT_NOWHERE);
                }
            }

            return(false);
        }
コード例 #5
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            TCHITTESTINFO HTI = new TCHITTESTINFO(e.X, e.Y);

            HotTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            Rectangle r = new Rectangle(DragStartPosition, Size.Empty);

            r.Inflate(SystemInformation.DragSize);

            TabPage tp = HoverTab();

            if (tp != null)
            {
                if (!r.Contains(e.X, e.Y))
                {
                    this.DoDragDrop(tp, DragDropEffects.All);
                }
            }
            DragStartPosition = Point.Empty;
        }
コード例 #6
0
        /*
         * protected override void OnMouseEnter(EventArgs e)
         * {
         *  Point p = PointToClient(Cursor.Position);
         *  TCHITTESTINFO HTI = new TCHITTESTINFO(p.X, p.Y);
         *  HoveredTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);
         *  Console.WriteLine("Entered: {0}", HoveredTabIndex);
         *
         *  if(HoveredTabIndex!=SelectedIndex)
         *  {
         *      Rectangle recBounds = this.GetTabRect(HoveredTabIndex);
         *      Rectangle lineRect = new Rectangle(recBounds.X, recBounds.Y, recBounds.Width - 4, recBounds.Height);
         *      this.CreateGraphics().DrawRectangle(SystemPens.ActiveBorder, lineRect);
         *      CurrentIndex = HoveredTabIndex;
         *  }
         *
         *  Console.WriteLine("Current: {0}", CurrentIndex);
         *  base.OnMouseEnter(e);
         * }
         */

        protected override void OnMouseMove(MouseEventArgs e)
        {
            //Point p = PointToClient(Cursor.Position);
            TCHITTESTINFO HTI = new TCHITTESTINFO(e.X, e.Y);

            HoveredTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);

            if (HoveredTabIndex != SelectedIndex)
            {
                TabPage page = TabPages[SelectedIndex];
                page.MouseEnter += Page_MouseEnter;;
                Rectangle recBounds = this.GetTabRect(HoveredTabIndex < 0 ? 0 : HoveredTabIndex);
                Rectangle lineRect  = new Rectangle(recBounds.X, recBounds.Y, recBounds.Width - 4, recBounds.Height);
                this.CreateGraphics().DrawRectangle(SystemPens.ActiveBorder, lineRect);
                CurrentIndex = HoveredTabIndex;
            }
            else
            {
                Invalidate();
            }

            base.OnMouseMove(e);
        }
コード例 #7
0
ファイル: FlatTabControl.cs プロジェクト: devfinity-fx/cpms_z
        /*
        protected override void OnMouseEnter(EventArgs e)
        {
            Point p = PointToClient(Cursor.Position);
            TCHITTESTINFO HTI = new TCHITTESTINFO(p.X, p.Y);
            HoveredTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);
            Console.WriteLine("Entered: {0}", HoveredTabIndex);

            if(HoveredTabIndex!=SelectedIndex)
            {
                Rectangle recBounds = this.GetTabRect(HoveredTabIndex);
                Rectangle lineRect = new Rectangle(recBounds.X, recBounds.Y, recBounds.Width - 4, recBounds.Height);
                this.CreateGraphics().DrawRectangle(SystemPens.ActiveBorder, lineRect);
                CurrentIndex = HoveredTabIndex;
            }

            Console.WriteLine("Current: {0}", CurrentIndex);
            base.OnMouseEnter(e);
        }
        */
        protected override void OnMouseMove(MouseEventArgs e)
        {
            //Point p = PointToClient(Cursor.Position);
            TCHITTESTINFO HTI = new TCHITTESTINFO(e.X, e.Y);
            HoveredTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);

            if (HoveredTabIndex != SelectedIndex)
            {
                TabPage page = TabPages[SelectedIndex];
                page.MouseEnter += Page_MouseEnter; ;
                Rectangle recBounds = this.GetTabRect(HoveredTabIndex < 0 ? 0 : HoveredTabIndex);
                Rectangle lineRect = new Rectangle(recBounds.X, recBounds.Y, recBounds.Width - 4, recBounds.Height);
                this.CreateGraphics().DrawRectangle(SystemPens.ActiveBorder, lineRect);
                CurrentIndex = HoveredTabIndex;
            }
            else
            {
                Invalidate();
            }

            base.OnMouseMove(e);
        }
コード例 #8
0
 private static extern int SendMessage(IntPtr hwnd, int msg, IntPtr wParam, ref TCHITTESTINFO lParam);
コード例 #9
0
 internal static extern int SendMessage(
     IntPtr hwnd,
     int tMsg,
     IntPtr wParam,
     ref TCHITTESTINFO lParam);
コード例 #10
0
 public static extern IntPtr SendMessage([In] HandleRef hWnd, [In] uint msg, [In] IntPtr wParam, [In] ref TCHITTESTINFO lParam);
コード例 #11
0
ファイル: ImageTabControl.cs プロジェクト: hirekoke/Densha
 public int HitTest(int x, int y)
 {
     TCHITTESTINFO htInfo = new TCHITTESTINFO(x, y);
     int idx = SendMessage(this.Handle, (int)TabCtrlMessage.HITTEST, IntPtr.Zero, ref htInfo).ToInt32();
     return idx;
 }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: edores/snippet-manager
 private void ContentFileTabs_MouseDown(object sender, MouseEventArgs e)
 {
     TCHITTESTINFO HTI = new TCHITTESTINFO(e.X, e.Y);
     TabPage tp = ContentFileTabs.TabPages[SendMessage(ContentFileTabs.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI)];
     ContentFileTabs.SelectedTab = tp;
     ContentFileTabs.ContextMenuStrip = cmContentTab;
 }
コード例 #13
0
		}																									// 1.0.020


		protected override bool GetHitTest(System.Drawing.Point point)										// 1.0.020
		{																									// 1.0.020
			if (this.SelectionService.PrimarySelection == this.Control)										// 1.0.020
			{																								// 1.0.020
				TCHITTESTINFO hti = new TCHITTESTINFO();													// 1.0.020

				hti.pt = this.Control.PointToClient(point);													// 1.0.020
				hti.flags = 0;																				// 1.0.020

				System.Windows.Forms.Message m = new System.Windows.Forms.Message();						// 1.0.020
				m.HWnd = this.Control.Handle;																// 1.0.020
				m.Msg = TCM_HITTEST;																		// 1.0.020

				IntPtr lparam = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(hti));	// 1.0.020
				System.Runtime.InteropServices.Marshal.StructureToPtr(hti, lparam, false);					// 1.0.020
				m.LParam = lparam;																			// 1.0.020

				base.WndProc(ref m);																		// 1.0.020
				System.Runtime.InteropServices.Marshal.FreeHGlobal(lparam);									// 1.0.020

				if (m.Result.ToInt32() != -1)																// 1.0.020
				{																							// 1.0.020
					return hti.flags != TabControlHitTest.TCHT_NOWHERE;										// 1.0.020
				}																							// 1.0.020
			}																								// 1.0.020
			return false;																					// 1.0.020
		}																									// 1.0.020
コード例 #14
0
ファイル: CommCtrl.Tab.cs プロジェクト: wushian/Vanara
 public static extern IntPtr SendMessage(HWND hWnd, TabControlMessage Msg, int wParam, ref TCHITTESTINFO item);
コード例 #15
0
ファイル: User32.cs プロジェクト: Celtech/BolDevStudio
 internal static extern int SendMessage(
     IntPtr hwnd,
     int tMsg,
     IntPtr wParam,
     ref TCHITTESTINFO lParam);
コード例 #16
0
ファイル: FlatTabControl.cs プロジェクト: devfinity-fx/cpms_z
 private static extern int SendMessage(IntPtr hwnd, int msg, IntPtr wParam, ref TCHITTESTINFO lParam);
コード例 #17
0
 internal static extern IntPtr SendMessage(HandleRef hWnd, int msg, IntPtr wParam, ref TCHITTESTINFO lParam);
コード例 #18
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            TCHITTESTINFO HTI = new TCHITTESTINFO(e.X, e.Y);
            HotTabIndex = SendMessage(this.Handle, TCM_HITTEST, IntPtr.Zero, ref HTI);

            if (e.Button != MouseButtons.Left) return;

            Rectangle r = new Rectangle(DragStartPosition, Size.Empty);
            r.Inflate(SystemInformation.DragSize);

            TabPage tp = HoverTab();

            if (tp != null)
            {
                if (!r.Contains(e.X, e.Y))
                    this.DoDragDrop(tp, DragDropEffects.All);
            }
            DragStartPosition = Point.Empty;
        }