Example #1
0
        private void Control_Resize(object sender, EventArgs e)
        {
            Control caller = (Control)sender;

            this.tf.parent = caller.Handle;
            this.tempptr   = Marshal.AllocHGlobal(this.tf.size);
            Marshal.StructureToPtr(this.tf, this.tempptr, false);
            SendMessage(this.toolwindow, TTM_GETTOOLINFO, 0, this.tempptr);
            this.tf      = (toolinfo)Marshal.PtrToStructure(this.tempptr, typeof(toolinfo));
            this.tf.rect = caller.ClientRectangle;
            Marshal.StructureToPtr(this.tf, this.tempptr, false);
            SendMessage(this.toolwindow, TTM_SETTOOLINFO, 0, this.tempptr);
            Marshal.FreeHGlobal(this.tempptr);
        }
Example #2
0
 public BalloonToolTip()
 {
     // Private members initial values.
     this.max = 200;
     this.autopop = 5000;
     this.initial = 500;
     this.title = string.Empty;
     this.bgcolor = Color.FromKnownColor(KnownColor.Info);
     this.fgcolor = Color.FromKnownColor(KnownColor.InfoText);
     this.tooltexts = new Hashtable();
     this.enabled = true;
     this.icon = BalloonIcons.None;
     // Creating the tooltip control.
     this.toolwindow = CreateWindowEx(0, "tooltips_class32", string.Empty,
                                      WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
                                      CW_USEDEFAULT, CW_USEDEFAULT, IntPtr.Zero, 0, 0, 0);
     SetWindowPos(this.toolwindow, this.TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
     SendMessage(this.toolwindow, TTM_SETMAXTIPWIDTH, 0, new IntPtr(this.max));
     // Creating the toolinfo structure to be used later.
     this.tf = new toolinfo();
     this.tf.flag = TTF_SUBCLASS | TTF_TRANSPARENT;
     this.tf.size = Marshal.SizeOf(typeof (toolinfo));
 }
Example #3
0
 public BalloonToolTip()
 {
     // Private members initial values.
     this.max       = 200;
     this.autopop   = 5000;
     this.initial   = 500;
     this.title     = string.Empty;
     this.bgcolor   = Color.FromKnownColor(KnownColor.Info);
     this.fgcolor   = Color.FromKnownColor(KnownColor.InfoText);
     this.tooltexts = new Hashtable();
     this.enabled   = true;
     this.icon      = BalloonIcons.None;
     // Creating the tooltip control.
     this.toolwindow = CreateWindowEx(0, "tooltips_class32", string.Empty,
                                      WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
                                      CW_USEDEFAULT, CW_USEDEFAULT, IntPtr.Zero, 0, 0, 0);
     SetWindowPos(this.toolwindow, this.TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
     SendMessage(this.toolwindow, TTM_SETMAXTIPWIDTH, 0, new IntPtr(this.max));
     // Creating the toolinfo structure to be used later.
     this.tf      = new toolinfo();
     this.tf.flag = TTF_SUBCLASS | TTF_TRANSPARENT;
     this.tf.size = Marshal.SizeOf(typeof(toolinfo));
 }
Example #4
0
 private void Control_Resize(object sender, EventArgs e)
 {
     Control caller = (Control) sender;
     this.tf.parent = caller.Handle;
     this.tempptr = Marshal.AllocHGlobal(this.tf.size);
     Marshal.StructureToPtr(this.tf, this.tempptr, false);
     SendMessage(this.toolwindow, TTM_GETTOOLINFO, 0, this.tempptr);
     this.tf = (toolinfo) Marshal.PtrToStructure(this.tempptr, typeof (toolinfo));
     this.tf.rect = caller.ClientRectangle;
     Marshal.StructureToPtr(this.tf, this.tempptr, false);
     SendMessage(this.toolwindow, TTM_SETTOOLINFO, 0, this.tempptr);
     Marshal.FreeHGlobal(this.tempptr);
 }
Example #5
0
        public BalloonToolTip()
        {
            // Private members initial values.
            max			= 2000;
            autopop		= 5000;
            initial		= 500;
            title		= string.Empty;
            bgcolor		= Color.FromKnownColor(KnownColor.Info);
            fgcolor		= Color.FromKnownColor(KnownColor.InfoText);
            tooltexts	= new System.Collections.Hashtable();
            enabled		= false;
            icon		= BalloonIcons.None;

            // Creating the tooltip control.
            toolwindow = CreateWindowEx(0, "tooltips_class32", string.Empty, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, IntPtr.Zero, 0, 0, 0);
            SetWindowPos(toolwindow, TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
            SendMessage(toolwindow, TTM_SETMAXTIPWIDTH, 0, new IntPtr(max));

            // Creating the toolinfo structure to be used later.
            tf = new toolinfo();
            tf.flag = TTF_TRACK | TTF_SUBCLASS | TTF_TRANSPARENT | TTF_ABSOLUTE;
            tf.id = toolwindow;
            tf.size = Marshal.SizeOf(tf);
        }
        /// <summary>
        /// Hides the balloon tooltip
        /// </summary>
        /// <param name="sender">The sender.</param>
        public void Hide(Control sender)
        {
            tf.parent = ((Control)sender).Handle;

            tempptr = Marshal.AllocHGlobal(tf.size);
            Marshal.StructureToPtr(tf, tempptr, false);

            SendMessage(toolwindow, TTM_GETTOOLINFO, 0, tempptr);
            tf = (toolinfo)Marshal.PtrToStructure(tempptr, typeof(toolinfo));

            tf.flag = TTF_IDISHWND | TTF_ABSOLUTE | TTF_TRACK;
            //tf.size = Marshal.SizeOf(typeof(toolinfo));
            Marshal.StructureToPtr(tf, tempptr, false);
            SendMessage(toolwindow, TTM_SETTOOLINFO, 0, tempptr);

            SendMessage(toolwindow, TTM_TRACKPOSITION, 0, IntPtr.Zero);
            SendMessage(toolwindow, TTM_TRACKACTIVATE, 0, tempptr);
            Marshal.FreeHGlobal(tempptr);

        }
        /// <summary>
        /// show the balloon tooltip,
        /// to make it visible without the user have to hover over the control
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="location">The location.</param>
        public void Show(Control sender, Point location)
        {
            tf.parent = ((Control)sender).Handle;

            tempptr = Marshal.AllocHGlobal(tf.size);
            Marshal.StructureToPtr(tf, tempptr, false);

            SendMessage(toolwindow, TTM_GETTOOLINFO, 0, tempptr);
            tf = (toolinfo)Marshal.PtrToStructure(tempptr, typeof(toolinfo));

            tf.flag = TTF_IDISHWND | TTF_ABSOLUTE | TTF_TRACK;
            //tf.size = Marshal.SizeOf(typeof(toolinfo));
            //tf.text="test";
            Marshal.StructureToPtr(tf, tempptr, false);
            SendMessage(toolwindow, TTM_SETTOOLINFO, 0, tempptr);

            SendMessage(toolwindow, TTM_TRACKPOSITION, 0, (IntPtr)MAKELONG(location.X, location.Y));
            SendMessage(toolwindow, TTM_TRACKACTIVATE, 1, tempptr);
            Marshal.FreeHGlobal(tempptr);


        }