using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ToolTipTest
{
public partial class frmMain : Form
{
#region Support
private const string LINE = "\r\n";
private const int WM_VSCROLL = 0x115;
private const int WM_HSCROLL = 0x114;
private const int SB_LINEUP = 0;
private const int SB_LINEDOWN = 1;
[DllImport("user32.dll")]
private extern static int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
private int _iSelected = -1;
private IntPtr _pOwner = IntPtr.Zero;
private Color _oSelected = Color.CadetBlue;
private Color _oNormal = Color.WhiteSmoke;
private Color _oForeColor = Color.Black;
private Color _oTitleColor = Color.Black;
private Tooltip _ttMain;
private Tooltip _ttBalloon;
private Tooltip _ttOwnerDrawn;
private Tooltip _ttOdSub;
private Tooltip _ttControlHints;
#endregion
#region Style Switches
private void Defaults()
{
// control properties
_ttControlHints = new Tooltip();
_ttControlHints.CustomStyle = TipStyle.Solid;
_ttControlHints.MultiLine = true;
_ttControlHints.MaximumWidth = -1;
_ttControlHints.ForeColor = Color.Black;
_ttControlHints.TitleColor = Color.Black;
_ttControlHints.Opacity = 1.0f;
// multiplexing tips
_ttControlHints.SetToolTip(trkReshow, "ReShow delay (int ToolTip.ReShowDelay) Gets/Sets the length of time that must transpire before subsequent " + LINE +
"ToolTip windows appear as the pointer moves between one control to another.");
_ttControlHints.SetTipTitle(trkReshow.Handle, "ReShow Delay", null, new Size(0,0));
_ttControlHints.SetToolTip(trkFadeout, "FadeOut Delay (int ToolTip.FadeDelay) Gets/Sets the ToolTip fading delay interval in custom style mode.");
_ttControlHints.SetTipTitle(trkFadeout.Handle, "FadeOut Delay", null, new Size(0, 0));
_ttControlHints.SetToolTip(trkAutopop, "AutoPop Delay (int ToolTip.FadeDelay) int ToolTip.AutoPopDelay Gets/Sets the period of time the ToolTip " + LINE +
"remains visible if the pointer is stationary over the control.");
_ttControlHints.SetTipTitle(trkAutopop.Handle, "AutoPop Delay", null, new Size(0, 0));
_ttControlHints.SetToolTip(trkAutomatic, "Automatic Delay (int ToolTip.AutomaticDelay) Gets/Sets the automatic delay for the ToolTip.");
_ttControlHints.SetTipTitle(trkAutomatic.Handle, "Automatic Delay", null, new Size(0, 0));
_ttControlHints.SetToolTip(llForeColor, "ForeColor (Color ToolTip.ForeColor) Gets/Sets the ToolTip ForeColor. If visual styles are " + LINE +
"enabled, this will only have effect if using one of the customized modes.");
_ttControlHints.SetTipTitle(llForeColor.Handle, "ForeColor", null, new Size(0, 0));
_ttControlHints.SetToolTip(llCaptionFont, "TipFont (Font ToolTip.TipFont) Gets/Sets the ToolTip font for the main body of text. " + LINE +
"For use with OwnerDraw style or custom styles options.");
_ttControlHints.SetTipTitle(llCaptionFont.Handle, "TipFont", null, new Size(0, 0));
_ttControlHints.SetToolTip(llTitleForeColor, "TitleColor (Color ToolTip.TitleColor) Gets/Sets the ToolTip title color. For use with custom styles options.");
_ttControlHints.SetTipTitle(llTitleForeColor.Handle, "TitleColor", null, new Size(0, 0));
_ttControlHints.SetToolTip(llTitleFont, "TitleFont (Font ToolTip.TitleFont) Gets/Sets the ToolTip title font. For use with custom styles options.");
_ttControlHints.SetTipTitle(llTitleFont.Handle, "TitleFont", null, new Size(0, 0));
_ttControlHints.SetToolTip(llReset, "Reset the example styles.");
_ttControlHints.SetTipTitle(llReset.Handle, "Reset", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos0, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos0.Handle, "TipPosition.TopCenter", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos1, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos1.Handle, "TipPosition.TopRight", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos2, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos2.Handle, "TipPosition.RightCenter", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos3, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos3.Handle, "TipPosition.BottomRight", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos4, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos4.Handle, "TipPosition.BottomCenter", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos5, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos5.Handle, "TipPosition.BottomLeft", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos6, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos6.Handle, "TipPosition.LeftCenter", null, new Size(0, 0));
_ttControlHints.SetToolTip(lbPos7, "Position (enum ToolTip.Position) Gets/Sets the ToolTip position relative to the cursor.");
_ttControlHints.SetTipTitle(lbPos7.Handle, "TipPosition.TopLeft", null, new Size(0, 0));
_ttControlHints.SetToolTip(rdFade0, "FadeOut (enum ToolTip.FadeOut) Gets/Sets the ToolTip fading style in custom style mode.");
_ttControlHints.SetTipTitle(rdFade0.Handle, "FadeStyle.Default", null, new Size(0, 0));
_ttControlHints.SetToolTip(rdFade1, "FadeOut (enum ToolTip.FadeOut) Gets/Sets the ToolTip fading style in custom style mode.");
_ttControlHints.SetTipTitle(rdFade1.Handle, "FadeStyle.Phaser", null, new Size(0, 0));
_ttControlHints.SetToolTip(rdFade2, "FadeOut (enum ToolTip.FadeOut) Gets/Sets the ToolTip fading style in custom style mode.");
_ttControlHints.SetTipTitle(rdFade2.Handle, "FadeStyle.Pulse", null, new Size(0, 0));
// main
_ttMain = new Tooltip();
// main events
_ttMain.Disposed += new Tooltip.DisposedDelegate(ttMain_Disposed);
_ttMain.Disposing += new Tooltip.DisposingDelegate(ttMain_Disposing);
_ttMain.LeftButtonDblClick += new Tooltip.LeftButtonDblClickDelegate(ttMain_LeftButtonDblClick);
_ttMain.LeftButtonDown += new Tooltip.LeftButtonDownDelegate(ttMain_LeftButtonDown);
_ttMain.LeftButtonUp += new Tooltip.LeftButtonUpDelegate(ttMain_LeftButtonUp);
_ttMain.MiddleButtonDblClick += new Tooltip.MiddleButtonDblClickDelegate(ttMain_MiddleButtonDblClick);
_ttMain.MiddleButtonDown += new Tooltip.MiddleButtonDownDelegate(ttMain_MiddleButtonDown);
_ttMain.MiddleButtonUp += new Tooltip.MiddleButtonUpDelegate(ttMain_MiddleButtonUp);
_ttMain.MouseMove += new Tooltip.MouseMoveDelegate(ttMain_MouseMove);
_ttMain.MouseWheel += new Tooltip.MouseWheelDelegate(ttMain_MouseWheel);
_ttMain.Pop += new Tooltip.PopDelegate(ttMain_Pop);
_ttMain.PopUp += new Tooltip.ShowDelegate(ttMain_PopUp);
_ttMain.RightButtonDblClick += new Tooltip.RightButtonDblClickDelegate(ttMain_RightButtonDblClick);
_ttMain.RightButtonDown += new Tooltip.RightButtonDownDelegate(ttMain_RightButtonDown);
_ttMain.RightButtonUp += new Tooltip.RightButtonUpDelegate(ttMain_RightButtonUp);
// balloon style
_ttBalloon = new Tooltip();
_ttBalloon.BallonStyle = true;//<-enable balloon style (style should not be flipped, causes internal errors, hence a seperate instance)
// balloon events
_ttBalloon.Disposed += new Tooltip.DisposedDelegate(ttBalloon_Disposed);
_ttBalloon.Disposing += new Tooltip.DisposingDelegate(ttBalloon_Disposing);
_ttBalloon.LeftButtonDblClick += new Tooltip.LeftButtonDblClickDelegate(ttMain_LeftButtonDblClick);
_ttBalloon.LeftButtonDown += new Tooltip.LeftButtonDownDelegate(ttMain_LeftButtonDown);
_ttBalloon.LeftButtonUp += new Tooltip.LeftButtonUpDelegate(ttMain_LeftButtonUp);
_ttBalloon.MiddleButtonDblClick += new Tooltip.MiddleButtonDblClickDelegate(ttMain_MiddleButtonDblClick);
_ttBalloon.MiddleButtonDown += new Tooltip.MiddleButtonDownDelegate(ttMain_MiddleButtonDown);
_ttBalloon.MiddleButtonUp += new Tooltip.MiddleButtonUpDelegate(ttMain_MiddleButtonUp);
_ttBalloon.MouseMove += new Tooltip.MouseMoveDelegate(ttMain_MouseMove);
_ttBalloon.MouseWheel += new Tooltip.MouseWheelDelegate(ttMain_MouseWheel);
_ttBalloon.Pop += new Tooltip.PopDelegate(ttMain_Pop);
_ttBalloon.PopUp += new Tooltip.ShowDelegate(ttBalloon_PopUp);
_ttBalloon.RightButtonDblClick += new Tooltip.RightButtonDblClickDelegate(ttMain_RightButtonDblClick);
_ttBalloon.RightButtonDown += new Tooltip.RightButtonDownDelegate(ttMain_RightButtonDown);
_ttBalloon.RightButtonUp += new Tooltip.RightButtonUpDelegate(ttMain_RightButtonUp);
//ownerdrawn styles
_ttOwnerDrawn = new Tooltip();
// add images
_ttOwnerDrawn.AddImage(imageList2.Images[0], new Size(16, 16));
_ttOwnerDrawn.AddImage(imageList2.Images[1], new Size(16, 16));
_ttOwnerDrawn.AddImage(imageList2.Images[2], new Size(16, 16));
// can be focused or there is no mouse down event
_ttOwnerDrawn.CanFocus = true;
// assign ownership
_ttOwnerDrawn.SetToolTip(this.lb18.Handle, " "); // <- has to have a string even when ownerdrawn
// styles
_ttOwnerDrawn.TipFont = new Font("MS Sans Serif", 8, FontStyle.Regular);
_ttOwnerDrawn.MultiLine = true;
_ttOwnerDrawn.Clickable = true;
_ttOwnerDrawn.ShowAlways = true;
// ownerdrawn style flag
_ttOwnerDrawn.CustomStyle = TipStyle.OwnerDrawn;
// od popup
_ttOdSub = new Tooltip();
_ttOdSub.CustomStyle = TipStyle.Solid;
_ttOdSub.BackColor = Color.White;
_ttOdSub.TipFont = new Font("MS Sans Serif", 8, FontStyle.Regular);
_ttOdSub.MultiLine = true;
_ttOdSub.Clickable = true;
_ttOdSub.ShowAlways = true;
_ttOdSub.Opacity = 1.0f;
// create sample values
createVals();
sizeTip();
// events
_ttOwnerDrawn.Disposed += new Tooltip.DisposedDelegate(ttMain_Disposed);
_ttOwnerDrawn.Disposing += new Tooltip.DisposingDelegate(ttMain_Disposing);
_ttOwnerDrawn.Draw += new Tooltip.DrawDelegate(ttOwnerDrawn_Draw);
_ttOwnerDrawn.LeftButtonDblClick += new Tooltip.LeftButtonDblClickDelegate(ttMain_LeftButtonDblClick);
_ttOwnerDrawn.LeftButtonDown += new Tooltip.LeftButtonDownDelegate(ttOwnerDrawn_LeftButtonDown);
_ttOwnerDrawn.LeftButtonUp += new Tooltip.LeftButtonUpDelegate(ttMain_LeftButtonUp);
_ttOwnerDrawn.MiddleButtonDblClick += new Tooltip.MiddleButtonDblClickDelegate(ttMain_MiddleButtonDblClick);
_ttOwnerDrawn.MiddleButtonDown += new Tooltip.MiddleButtonDownDelegate(ttMain_MiddleButtonDown);
_ttOwnerDrawn.MiddleButtonUp += new Tooltip.MiddleButtonUpDelegate(ttMain_MiddleButtonUp);
_ttOwnerDrawn.MouseMove += new Tooltip.MouseMoveDelegate(ttMain_MouseMove);
_ttOwnerDrawn.MouseWheel += new Tooltip.MouseWheelDelegate(ttMain_MouseWheel);
_ttOwnerDrawn.Pop += new Tooltip.PopDelegate(ttOwnerDrawn_Pop);
_ttOwnerDrawn.PopUp += new Tooltip.ShowDelegate(ttMain_PopUp);
_ttOwnerDrawn.RightButtonDblClick += new Tooltip.RightButtonDblClickDelegate(ttMain_RightButtonDblClick);
_ttOwnerDrawn.RightButtonDown += new Tooltip.RightButtonDownDelegate(ttMain_RightButtonDown);
_ttOwnerDrawn.RightButtonUp += new Tooltip.RightButtonUpDelegate(ttMain_RightButtonUp);
}
private void Style(int iStyle)
{
if ((!_ttMain.IsVisible()) || (_ttBalloon.IsVisible()) || (_ttOwnerDrawn.IsVisible()))
{
if (iStyle != _iSelected)
{
Reset();
_iSelected = iStyle;
}
switch (iStyle)
{
case 1:
_pOwner = lb1.Handle; //<- required by example only
_ttMain.SetToolTip(lb1, "This is an example of a standard tooltip control..");//<-set with either control or handle
_ttMain.UseVisualStyle = false;
break;
case 2:
_pOwner = lb2.Handle;
_ttBalloon.MaximumWidth = 320;//<-max formatting rectangle
_ttBalloon.SetToolTip(lb2, "This is a balloon style tooltip control..");
break;
case 3:
_pOwner = lb3.Handle;
_ttMain.SetToolTip(lb3.Handle, "By setting the MultiLine property to true, and " +
"adjusting the MaximumWidth parameter, the ToolTip layout can be controlled.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 320;
break;
case 4:
_pOwner = lb4.Handle;
_ttMain.SetToolTip(lb4.Handle, "The SetTipTitle call adds a Tip Title, " +
"and an optional icon to the ToolTip.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.SetTipTitle("Multiline with System Icon", OsIcon.InfoLarge);//<-using system icon enum
break;
case 5:
_pOwner = lb5.Handle;
_ttMain.SetToolTip(lb5, "The SetTipTitle call has four overloads. " + LINE +
"You can add a caption with no Icon." + LINE +
"A system Icon (in default mode)." + LINE +
"A custom Icon in Default mode (Global)." + LINE +
"A custom icon to each individual ToolTip (non-Default modes)");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 320;
_ttMain.SetTipTitle(IntPtr.Zero, "Default mode with a custom Icon", this.imageList1.Images[3], new Size(32, 32));
break;
case 6:
_pOwner = lb6.Handle;
_ttBalloon.SetToolTip(lb6.Handle, "The Balloon style ToolTip can contain both an Icon and a close button." + LINE +
"This option requires the properties: CloseButton = true, and ShowAlways = true");
_ttBalloon.CloseButton = true;//<-add a close button
_ttBalloon.MultiLine = true;
_ttBalloon.MaximumWidth = 300;//<-set the formatting width to control text wrap
_ttBalloon.ShowAlways = true;//<-remain visible
_ttBalloon.SetTipTitle("Balloon style with a Close button", OsIcon.ErrorLarge);
break;
case 7:
_pOwner = lb7.Handle;
_ttMain.SetToolTip(lb7, "All styles of tooltip, can use the close button, the only " +
"prerequisite is that the ToolTip should have a Title to maintain the proper spacing.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CloseButton = true;
_ttMain.ShowAlways = true;
_ttMain.Clickable = true;
_ttMain.SetTipTitle("Multiline with System Icon", OsIcon.WarningLarge);
break;
case 8:
_pOwner = lb8.Handle;
_ttMain.SetToolTip(lb8, "A Gradient style multiline tooltip with a linear-vertical gradient" + LINE +
"The Opacity level can be set with any of the custom styles, here we are using 0.85f.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.LinearVertical;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientEndColor = Color.Gainsboro;
_ttMain.Opacity = 0.85f;
_ttMain.SetTipTitle(_pOwner, "Vertical Gradient with Custom Icon", this.imageList1.Images[0], new Size(32, 32));
break;
case 9:
_pOwner = lb9.Handle;
_ttMain.SetToolTip(lb9, "There are eight different gradient styles to select from, ranging from" +
"a standard linear gradient to a SigmaBell pattern cross fade.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.LinearHorizontal;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientEndColor = Color.AliceBlue;
_ttMain.Opacity = 1.0f;
_ttMain.SetTipTitle(_pOwner, "Horizontal gradient with Icon", this.imageList1.Images[1], new Size(32, 32));
break;
case 10:
_pOwner = lb10.Handle;
_ttMain.SetToolTip(lb10, "The Opacity level only effects the background transparency levels. " +
"The Icon and text are always rendered completely opaque.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.BackwardDiagonal;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientEndColor = Color.BlanchedAlmond;
_ttMain.Opacity = 0.8f;
_ttMain.SetTipTitle(_pOwner, "Backward diagonal with Icon", this.imageList1.Images[2], new Size(32, 32));
break;
case 11:
_pOwner = lb11.Handle;
_ttMain.SetToolTip(lb11, "The tip icon can be any form of image available to an imagelist, " +
"this example uses icons, bitmaps and PNGs.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.ForwardDiagonal;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientEndColor = Color.FromArgb(0x00CA00);
_ttMain.Opacity = 0.8f;
_ttMain.SetTipTitle(_pOwner, "Forward diagonal with Icon", this.imageList1.Images[3], new Size(32, 32));
break;
case 12:
_pOwner = lb12.Handle;
_ttMain.SetToolTip(lb12, "There are thirty-eight properties, sixteen events, and " +
" twenty seven methods, this far exceeds the standard ToolTip class capabilities.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.ForeColor = Color.White;
_ttMain.TitleColor = Color.White;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.HorizontalTube;
_ttMain.GradientStartColor = Color.PowderBlue;
_ttMain.GradientEndColor = Color.SteelBlue;
_ttMain.Opacity = 1.0f;
_ttMain.SetTipTitle(_pOwner, "Horizontal tube with Icon", this.imageList1.Images[4], new Size(32, 32));
break;
case 13:
_pOwner = lb13.Handle;
_ttMain.SetToolTip(lb13, "ToolTips can be multiplexed; multiple controls can be added " +
"to the same ToolTip instance. In custom modes, seperate Icons and title captions can be used.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 330;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.VerticalTube;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientEndColor = Color.FromArgb(0xC0D8DD);
_ttMain.Opacity = 1.0f;
_ttMain.SetTipTitle(_pOwner, "Vertical tube with Icon", this.imageList1.Images[5], new Size(32, 32));
break;
case 14:
_pOwner = lb14.Handle;
_ttMain.SetToolTip(lb14, "Title font, caption font, and forecolors are all independantly adjustable.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CustomStyle = TipStyle.Gradient;
_ttMain.GradientType = GradientStyle.BlendTriangular;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientEndColor = Color.FromArgb(0x75B000);
_ttMain.Opacity = 1.0f;
_ttMain.SetTipTitle(_pOwner, "Triangular blend with Icon", this.imageList1.Images[6], new Size(32, 32));
break;
case 15:
_pOwner = lb15.Handle;
_ttMain.SetToolTip(lb15, "The Glass custom style is a predefined style option."+
"The custom style options exist as an example of what can be done with " +
"through the paint interface. Feel free to add styles of your own.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 320;
_ttMain.CustomStyle = TipStyle.Glass;
_ttMain.Opacity = 0.8f;
_ttMain.SetTipTitle(_pOwner, "Glass style with Icon", this.imageList1.Images[7], new Size(32, 32));
break;
case 16:
_pOwner = lb16.Handle;
_ttMain.SetToolTip(lb16, "The Mirror style is an offshoot of the transparency styles " +
"touched upon in this example. The example can be extended using colors and styles of your own.");
_ttMain.MultiLine = true;
_ttMain.MaximumWidth = 300;
_ttMain.CustomStyle = TipStyle.Mirror;
_ttMain.Opacity = 0.8f;
_ttMain.SetTipTitle(_pOwner, "Mirror style with Icon", this.imageList1.Images[8], new Size(32, 32));
break;
case 17:
_pOwner = lb17.Handle;
_ttMain.SetToolTip(lb17, "The Graphical style uses a Bitmap image as the backdrop to the ToolTip " +
"control.");
_ttMain.CustomStyle = TipStyle.Graphical;
_ttMain.BackGroundImage = ToolTipTest.Properties.Resources.bg3;
_ttMain.MultiLine = true;
_ttMain.CloseButton = true;
_ttMain.ShowAlways = true; //<- tooltip remains even when client is out of focus
_ttMain.ForeColor = Color.WhiteSmoke;
_ttMain.TitleColor = Color.WhiteSmoke;
_ttMain.Opacity = 0.95f; //<- transparency index 0.1 - 1.0
_ttMain.MaximumWidth = 250; //<- set the max width to adjust formatting rect
_ttMain.Size = new Size(250, 80); //<- specify size
_ttMain.SetTipTitle(_pOwner, "Graphical style with Icon", this.imageList1.Images[9], new Size(32, 32));
break;
case 19:
_pOwner = pb19.Handle;
_ttMain.SetToolTipByRect(pb19.Handle, "upper left corner", new Rectangle(0, 0, 20, 20));
_ttMain.SetToolTipByRect(pb19.Handle, "upper right corner", new Rectangle(pb19.Width - 20, 0, 20, 20));
_ttMain.SetToolTipByRect(pb19.Handle, "bottom left corner", new Rectangle(0, pb19.Height - 20, 20, 20));
_ttMain.SetToolTipByRect(pb19.Handle, "bottom right corner", new Rectangle(pb19.Width - 20, pb19.Height - 20, 20, 20));
_ttMain.SetToolTipByRect(pb19.Handle, "center", new Rectangle(pb19.Width / 2 - 10, pb19.Height / 2 - 10, 20, 20));
_ttMain.CustomStyle = TipStyle.Default;//<-available only with 'Default' style
_ttMain.ForeColor = Color.Black;
_ttMain.TitleColor = Color.Black;
_ttMain.Opacity = 1.0f;
break;
}
}
}
private void Reset()
{
if ((_pOwner == lb2.Handle) || (_pOwner == lb6.Handle))
{
if (_pOwner != IntPtr.Zero)
{
_ttBalloon.RemoveTip(_pOwner);
}
_ttBalloon.CloseButton = false;
_ttBalloon.MultiLine = false;
_ttBalloon.MaximumWidth = 150;
_ttBalloon.ShowAlways = false;
_ttBalloon.CanFocus = false;
}
else
{
if (_pOwner != IntPtr.Zero)
{
_ttMain.RemoveTip(_pOwner);
}
_ttMain.BorderColor = Color.FromKnownColor(KnownColor.ButtonShadow);
_ttMain.CenterTip = false;
_ttMain.Clickable = false;
_ttMain.CloseButton = false;
_ttMain.CustomStyle = TipStyle.Default;
_ttMain.ForeColor = _oForeColor;
_ttMain.GradientEndColor = Color.LightGray;
_ttMain.GradientStartColor = Color.White;
_ttMain.GradientType = GradientStyle.VerticalTube;
_ttMain.MaximumWidth = 150;
_ttMain.MultiLine = false;
_ttMain.Opacity = 0.6f;
_ttMain.RightToLeft = false;
_ttMain.ShowAlways = false;
_ttMain.TitleColor = _oTitleColor;
_ttMain.UseAnimation = false;
_ttMain.UseFading = true;
_ttMain.UseVisualStyle = false;
_ttMain.Size = new Size(0, 0);
_ttMain.FadePulseColor = Color.LimeGreen;
}
}
#endregion
#region Event Handlers
#region Display
private void eventData(string data)
{
txtEvent.AppendText(data + LINE);
txtEvent.ScrollToCaret();
}
private void eventData(string data, Point pos)
{
txtEvent.AppendText(data + LINE);
txtEvent.AppendText("X: " + pos.X.ToString() + LINE);
txtEvent.AppendText("Y: " + pos.Y.ToString() + LINE);
txtEvent.ScrollToCaret();
}
private void eventData(string data, DrawEventArgs e)
{
txtEvent.AppendText(data + LINE);
txtEvent.AppendText("X: " + e.Position.X.ToString() + LINE);
txtEvent.AppendText("Y: " + e.Position.ToString() + LINE);
txtEvent.AppendText("Height: " + e.Bounds.Height.ToString() + LINE);
txtEvent.AppendText("Width: " + e.Bounds.Width.ToString() + LINE);
txtEvent.AppendText("Hdc: " + e.Hdc.ToString() + LINE);
txtEvent.AppendText("Parent: " + e.ParentWnd.ToString() + LINE);
txtEvent.ScrollToCaret();
}
#endregion
#region ttBalloon
private void ttBalloon_Disposed()
{
eventData("State: DISPOSED" + LINE + "Class: _ttBalloon");
}
private void ttBalloon_Disposing()
{
eventData("State: DISPOSING" + LINE + "Class: _ttBalloon");
}
private void ttBalloon_PopUp()
{
eventData("State: SHOWING" + LINE + "Class: _ttBalloon");
}
#endregion
#region ttMain
private void ttMain_Disposed()
{
eventData("State: DISPOSED" + LINE + "Class: _ttMain");
}
private void ttMain_Disposing()
{
eventData("State: DISPOSING" + LINE + "Class: _ttMain");
}
private void ttMain_LeftButtonDblClick(Object sender, DrawEventArgs e)
{
eventData("State: LeftButtonDblClick", e);
}
private void ttMain_LeftButtonDown(Object sender, DrawEventArgs e)
{
eventData("State: LeftButtonDown", e);
}
private void ttMain_LeftButtonUp(Object sender, DrawEventArgs e)
{
eventData("State: LeftButtonUp", e);
}
private void ttMain_MiddleButtonDblClick(Object sender, DrawEventArgs e)
{
eventData("State: MiddleButtonDblClick", e);
}
private void ttMain_MiddleButtonDown(Object sender, DrawEventArgs e)
{
eventData("State: MiddleButtonDown", e);
}
private void ttMain_MiddleButtonUp(Object sender, DrawEventArgs e)
{
eventData("State: MiddleButtonUp", e);
}
private void ttMain_MouseMove(Point pos)
{
eventData("State: MouseMove", pos);
}
private void ttMain_MouseWheel()
{
eventData("State: MouseWheel");
}
private void ttMain_Pop()
{
eventData("State: POP");
}
private void ttMain_PopUp()
{
eventData("State: SHOWING" + LINE + "Class: _ttMain");
}
private void ttMain_RightButtonDblClick(Object sender, DrawEventArgs e)
{
eventData("State: RightButtonDblClick", e);
}
private void ttMain_RightButtonDown(Object sender, DrawEventArgs e)
{
eventData("State: RightButtonDown", e);
}
private void ttMain_RightButtonUp(Object sender, DrawEventArgs e)
{
eventData("State: RightButtonUp", e);
}
#endregion
#region ttOwnerDrawn
private void ttOwnerDrawn_Disposed()
{
eventData("State: DISPOSED" + LINE + "Class: _ttOwnerDrawn");
}
private void ttOwnerDrawn_Disposing()
{
eventData("State: DISPOSING" + LINE + "Class: _ttOwnerDrawn");
}
private void ttOwnerDrawn_Draw(Object sender, DrawEventArgs e)
{
drawStudio(e, -1);
eventData("State: DRAW", e);
}
private void ttOwnerDrawn_LeftButtonDblClick(Object sender, DrawEventArgs e)
{
eventData("State: LeftButtonDblClick", e);
}
private void ttOwnerDrawn_LeftButtonDown(Object sender, DrawEventArgs e)
{
int iC = -1;
Rectangle rS = new Rectangle();
rS.Y = _ttOwnerDrawn.ScreenPosition().Top;
rS.X = _ttOwnerDrawn.ScreenPosition().Left;
rS.Width = e.Bounds.Width;
rS.Height = 16;
for (int i = 0; i < 16; i++)
{
if (rS.Contains(Cursor.Position))
{
rS.Width = 16;
iC = i + 1;
if (rS.Contains(Cursor.Position))
_bShowSub = true;
}
rS.Y += 16;
}
drawStudio(e, iC);
eventData("State: LeftButtonDown", e);
}
private void ttOwnerDrawn_LeftButtonUp(Object sender, DrawEventArgs e)
{
eventData("State: LeftButtonUp", e);
}
private void ttOwnerDrawn_MiddleButtonDblClick(Object sender, DrawEventArgs e)
{
eventData("State: MiddleButtonDblClick", e);
}
private void ttOwnerDrawn_MiddleButtonDown(Object sender, DrawEventArgs e)
{
eventData("State: MiddleButtonDown", e);
}
private void ttOwnerDrawn_MiddleButtonUp(Object sender, DrawEventArgs e)
{
eventData("State: MiddleButtonUp", e);
}
private void ttOwnerDrawn_MouseMove(Point pos)
{
eventData("State: MouseMove", pos);
}
private void ttOwnerDrawn_MouseWheel()
{
eventData("State: MouseWheel");
}
private void ttOwnerDrawn_Pop()
{
eventData("State: POP");
_bShowSub = false;
}
private void ttOwnerDrawn_PopUp()
{
eventData("State: SHOWING" + LINE + "Owner: _ttOwnerDrawn");
}
private void ttOwnerDrawn_RightButtonDblClick(Object sender, DrawEventArgs e)
{
eventData("State: RightButtonDblClick", e);
}
private void ttOwnerDrawn_RightButtonDown(Object sender, DrawEventArgs e)
{
eventData("State: RightButtonDown", e);
}
private void ttOwnerDrawn_RightButtonUp(Object sender, DrawEventArgs e)
{
eventData("State: RightButtonUp", e);
}
#endregion
#endregion
#region OwnerDraw Sample
# region Support
private const int VER_PLATFORM_WIN32_NT = 0x2;
private enum UxThemeGLYPHStates
{
GLPS_CLOSED = 1,
GLPS_OPENED = 2
}
private enum UxThemeTreeviewParts
{
TVP_TREEITEM = 1,
TVP_GLYPH = 2,
TVP_BRANCH = 3,
TVP_HOTGLYPH = 4
}
private enum UxThemeSize
{
TS_MIN = 0,
TS_TRUE,
TS_DRAW
}
private enum OsType : int
{
ostUnsupported,
ostW2k,
ostXp,
ostVista
}
[StructLayout(LayoutKind.Sequential)]
private struct SIZE
{
internal int cX;
internal int cY;
}
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
internal RECT(int X, int Y, int Width, int Height)
{
this.Left = X;
this.Top = Y;
this.Right = Width;
this.Bottom = Height;
}
internal int Left;
internal int Top;
internal int Right;
internal int Bottom;
}
[StructLayout(LayoutKind.Sequential)]
private struct OSVERSIONINFO
{
internal int dwVersionInfoSize;
internal int dwMajorVersion;
internal int dwMinorVersion;
internal int dwBuildNumber;
internal int dwPlatformId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 127)]
internal byte[] szCSDVersion;
}
[DllImport("kernel32")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetVersionEx(ref OSVERSIONINFO osvi);
[DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
private static extern IntPtr OpenThemeData(IntPtr hWnd, string classList);
[DllImport("uxtheme.dll", ExactSpelling = true)]
private extern static Int32 GetThemePartSize(IntPtr hTheme, IntPtr hdc, UxThemeTreeviewParts part, UxThemeGLYPHStates state, ref RECT pRect, UxThemeSize eSize, out SIZE size);
[DllImport("uxtheme.dll", ExactSpelling = true)]
private extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ref RECT pClipRect);
[DllImport("uxtheme.dll", ExactSpelling = true)]
private extern static Int32 CloseThemeData(IntPtr hTheme);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private bool _bShowSub = false;
private int _iOffset = 0;
private cStoreDc _cDc = new cStoreDc();
private OsType _eOsType;
private string[,] _aVal;
#endregion
#region Draw
/// <summary>
/// Just a quick example, if you want to finish, assign icon by object type, finish scrollbars, and
/// flesh out subtip
/// </summary>
/// <param name="e">params</param>
private void drawStudio(DrawEventArgs e, int Selected)
{
// drawing to a buffer
_cDc.Width = e.Bounds.Width;
_cDc.Height = e.Bounds.Height;
Graphics g = Graphics.FromHdc(_cDc.Hdc);
// fill the back
Rectangle rB = e.Bounds;
Brush hB = new SolidBrush(Color.Black);
Brush hC = new SolidBrush(Color.White);
rB.Inflate(4, 4);
g.FillRectangle(hC, rB);
// draw borders
g.DrawLines(SystemPens.ControlLightLight, new Point[] {
new Point (0, e.Bounds.Height - 1),
new Point (0, 0),
new Point (e.Bounds.Width - 1, 0)
});
g.DrawLines(SystemPens.ControlDarkDark, new Point[] {
new Point (0, e.Bounds.Height - 1),
new Point (e.Bounds.Width - 1, e.Bounds.Height - 1),
new Point (e.Bounds.Width - 1, 0)
});
bool bScroll = (_aVal.Length / 2 > 15);
int iPln = 0;
int iLft = 0;
int iC = -1;
SizeF sF = new SizeF();
int iCt = bScroll ? 15 : _aVal.Length / 2;
if (Selected > iCt)
{
if ((_iOffset + iCt) < _aVal.Length / 2)
_iOffset += 1;
}
// draw icon and glyph
for (int i = 0; i < iCt; i++)
{
// draw focused rect
if (i == Selected - 1)
{
Rectangle rS = new Rectangle(1, i * 16, e.Bounds.Width - 2, 16);
g.FillRectangle(SystemBrushes.MenuHighlight, rS);
iC = Selected - 1;
}
if (_ttOdSub.Showing)
{
_ttOdSub.Hide();
_ttOdSub.RemoveTip(_ttOwnerDrawn.Handle);
}
if (hasGlyph(_aVal[i + _iOffset, 0]))
{
drawGlyph(g, 2, (i * 16) + 2);
imageList2.Draw(g, 18, (i * 16) + 2, 1);
iLft = 36;
}
else
{
imageList2.Draw(g, 2, (i * 16) + 2, 1);
iLft = 18;
}
// value name text
sF = _ttOwnerDrawn.MeasureString(_aVal[i, 0], _ttOwnerDrawn.TipFont);
if (iPln < sF.Width)
iPln = (int)sF.Width;
g.DrawString(_aVal[i + _iOffset, 0], _ttOwnerDrawn.TipFont, (iC == i) ? hC : hB, iLft, 2 + (16 * i));
}
// draw divider
iPln += iLft + 12;
g.DrawLine(SystemPens.ButtonFace, iPln, 1, iPln, bScroll ? e.Bounds.Height - 14 : e.Bounds.Height - 2);
g.DrawLine(SystemPens.ControlLightLight, iPln + 1, 1, iPln + 1, bScroll ? e.Bounds.Height - 14 : e.Bounds.Height - 2);
// value text
iPln += 4;
for (int i = 0; i < iCt; i++)
{
g.DrawString(_aVal[i + _iOffset, 1], _ttOwnerDrawn.TipFont, (iC == i) ? hC : hB, iPln, 2 + (16 * i));
}
// scrollbar and arrow
if (bScroll)
{
g.DrawLine(SystemPens.ControlDark, 2, e.Bounds.Height - 13, e.Bounds.Width - 4, e.Bounds.Height - 13);
g.DrawLine(SystemPens.ButtonFace, 2, e.Bounds.Height - 14, e.Bounds.Width - 4, e.Bounds.Height - 14);
g.DrawLine(SystemPens.ControlDarkDark, (e.Bounds.Width / 2) - 4, e.Bounds.Height - 9, (e.Bounds.Width / 2) + 4, e.Bounds.Height - 9);
g.DrawLine(SystemPens.ControlDarkDark, (e.Bounds.Width / 2) - 3, e.Bounds.Height - 8, (e.Bounds.Width / 2) + 3, e.Bounds.Height - 8);
g.DrawLine(SystemPens.ControlDarkDark, (e.Bounds.Width / 2) - 2, e.Bounds.Height - 7, (e.Bounds.Width / 2) + 2, e.Bounds.Height - 7);
g.DrawLine(SystemPens.ControlDarkDark, (e.Bounds.Width / 2) - 1, e.Bounds.Height - 6, (e.Bounds.Width / 2) + 1, e.Bounds.Height - 6);
}
// blit to tip
BitBlt(e.Hdc, 0, 0, e.Bounds.Width, e.Bounds.Height, _cDc.Hdc, 0, 0, 0xCC0020);
int iSel = (Selected - 1) + _iOffset;
if (_bShowSub)
{
if (hasGlyph(_aVal[iSel, 0]))
{
drawSubTip(_aVal[iSel, 1].Substring(_aVal[iSel, 1].IndexOf("{") + 1, _aVal[iSel, 1].IndexOf("}") - 1));
}
}
hB.Dispose();
hC.Dispose();
g.Dispose();
}
#endregion
#region Helper Methods
private void drawSubTip(string text)
{
_ttOdSub.RemoveTip(_ttOwnerDrawn.Handle);
string[] v = text.Split(',');
Size sT = new Size();
SizeF sF = new SizeF();
string s = String.Empty;
for (int k = 0; k < v.Length; k++)
{
sF = _ttOdSub.MeasureString(v[k], _ttOdSub.TipFont);
if ((int)sF.Width > sT.Width)
sT.Width = (int)sF.Width + 40;
s += v[k] + LINE;
}
sT.Height = (v.Length * 20);
_ttOdSub.Size = sT;
_ttOdSub.MaximumWidth = sT.Width;
_ttOdSub.SetToolTip(_ttOwnerDrawn.Handle, s);
_ttOdSub.CanFocus = true;
_ttOdSub.Show();
_bShowSub = false;
}
private bool hasGlyph(string match)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(lb18);
for (int j = 0; j < properties.Count; j++)
{
if (properties[j].GetValue(lb18) != null)
{
if (properties[j].Name == match)
{
if ((properties[j].PropertyType.IsNested) || (properties[j].GetValue(lb18).ToString().Contains("{")))
{
return true;
}
else
{
return false;
}
}
}
}
return false;
}
private void createVals()
{
int nC = 0;
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(lb18);
// get valid prop count
for (int i = 0; i < properties.Count; i++)
{
if (properties[i].GetValue(lb18) != null)
{
if (properties[i].Name != null)
{
if (properties[i].GetValue(lb18).ToString() != null)
{
nC += 1;
}
}
}
}
// build the prop array
_aVal = new string[nC, 2];
nC = 0;
for (int i = 0; i < properties.Count; i++)
{
if (properties[i].GetValue(lb18) != null)
{
if (properties[i].Name != String.Empty)
{
_aVal[nC, 0] = properties[i].Name;
_aVal[nC, 1] = properties[i].GetValue(lb18).ToString();
nC += 1;
}
}
}
}
private void sizeTip()
{
Graphics g = Graphics.FromHwnd(_ttOwnerDrawn.Handle);
int nP = 0;
int nV = 0;
SizeF sF = new SizeF();
_ttOwnerDrawn.MaximumWidth = -1;
for (int i = 0; i < _aVal.Length / 2; i++)
{
sF = _ttOwnerDrawn.MeasureString(_aVal[i, 0], _ttOwnerDrawn.TipFont);
if ((int)sF.Width > nP)
nP = (int)sF.Width;
if (_aVal[i, 1] == null)
_aVal[i, 1] = "null";
if (_aVal[i, 1].Length > 40)
_aVal[i, 1] = _aVal[i, 1].Substring(0, 38) + "..";
sF = _ttOwnerDrawn.MeasureString(_aVal[i, 1], _ttOwnerDrawn.TipFont);
if ((int)sF.Width > nV)
nV = (int)sF.Width;
}
if ((_aVal.Length / 2) > 15)
_ttOwnerDrawn.Size = new Size(nP + nV + 48, 18 + 16 * 15);//<-15 is max visible, 18px for scrollbar
else
_ttOwnerDrawn.Size = new Size(nP + nV + 48, 8 + 16 * (_aVal.Length / 2));//<-count + 8px for spacers
versionCheck();
}
private void versionCheck()
{
OSVERSIONINFO tVer = new OSVERSIONINFO();
tVer.dwVersionInfoSize = Marshal.SizeOf(tVer);
GetVersionEx(ref tVer);
if ((tVer.dwPlatformId & VER_PLATFORM_WIN32_NT) == VER_PLATFORM_WIN32_NT)
{
if (tVer.dwMajorVersion == 5)
{
if (tVer.dwMinorVersion >= 5)
{
_eOsType = OsType.ostXp;
return;
}
else
{
_eOsType = OsType.ostW2k;
return;
}
}
else if (tVer.dwMajorVersion > 5)
{
_eOsType = OsType.ostVista;
return;
}
else
{
_eOsType = OsType.ostUnsupported;
return;
}
}
}
private void drawGlyph(Graphics g, int X, int Y)
{
IntPtr hTheme = IntPtr.Zero;
int ret = 0;
SIZE tSize = new SIZE();
RECT tRect = new RECT();
if ((_eOsType == OsType.ostXp) || (_eOsType == OsType.ostVista))
{
try
{
hTheme = OpenThemeData(_ttOwnerDrawn.Handle, "TreeView");
if (hTheme != IntPtr.Zero)
{
ret = GetThemePartSize(hTheme, IntPtr.Zero, UxThemeTreeviewParts.TVP_HOTGLYPH, UxThemeGLYPHStates.GLPS_CLOSED, ref tRect, UxThemeSize.TS_TRUE, out tSize);
tRect.Top = Y;
tRect.Right = 16;
tRect.Left = X;
tRect.Bottom = tRect.Top + 16;
// draw part
ret = DrawThemeBackground(hTheme, g.GetHdc(), 2, 2, ref tRect, ref tRect);
g.ReleaseHdc();
}
}
finally
{
if (hTheme != IntPtr.Zero)
CloseThemeData(hTheme);
}
}
else
{
g.FillRectangle(SystemBrushes.ButtonFace, X + 2, Y + 3, 8, 8);
g.DrawRectangle(SystemPens.ControlDark, X + 2, Y + 3, 8, 8);
g.DrawLine(SystemPens.ControlDark, X + 6, Y + 4, X + 6, Y + 10);
g.DrawLine(SystemPens.ControlDark, X + 2, Y + 7, X + 9, Y + 7);
}
}
#endregion
#endregion
#region Position
private void lbPos0_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.TopCenter;
posColorReset();
lbPos0.BackColor = Color.CadetBlue;
lbPos0.ForeColor = Color.White;
}
private void lbPos1_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.TopRight;
posColorReset();
_ttMain.BackColor = Color.Gainsboro;
lbPos1.BackColor = Color.CadetBlue;
lbPos1.ForeColor = Color.White;
}
private void lbPos2_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.RightCenter;
posColorReset();
lbPos2.BackColor = Color.CadetBlue;
lbPos2.ForeColor = Color.White;
}
private void lbPos3_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.BottomRight;
posColorReset();
lbPos3.BackColor = Color.CadetBlue;
lbPos3.ForeColor = Color.White;
}
private void lbPos4_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.BottomCenter;
posColorReset();
lbPos4.BackColor = Color.CadetBlue;
lbPos4.ForeColor = Color.White;
}
private void lbPos5_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.BottomLeft;
posColorReset();
lbPos5.BackColor = Color.CadetBlue;
lbPos5.ForeColor = Color.White;
}
private void lbPos6_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.LeftCenter;
posColorReset();
lbPos6.BackColor = Color.CadetBlue;
lbPos6.ForeColor = Color.White;
}
private void lbPos7_Click(object sender, EventArgs e)
{
_ttMain.Position = TipPosition.TopLeft;
posColorReset();
lbPos7.BackColor = Color.CadetBlue;
lbPos7.ForeColor = Color.White;
}
private void posColorReset()
{
lbPos0.BackColor = Color.White;
lbPos0.ForeColor = Color.Black;
lbPos1.BackColor = Color.White;
lbPos1.ForeColor = Color.Black;
lbPos2.BackColor = Color.White;
lbPos2.ForeColor = Color.Black;
lbPos3.BackColor = Color.White;
lbPos3.ForeColor = Color.Black;
lbPos4.BackColor = Color.White;
lbPos4.ForeColor = Color.Black;
lbPos5.BackColor = Color.White;
lbPos5.ForeColor = Color.Black;
lbPos6.BackColor = Color.White;
lbPos6.ForeColor = Color.Black;
lbPos7.BackColor = Color.White;
lbPos7.ForeColor = Color.Black;
}
#endregion
#region Form Controls
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
Defaults();
colorDialog1.AllowFullOpen = true;
colorDialog1.AnyColor = true;
colorDialog1.SolidColorOnly = false;
colorDialog1.ShowHelp = true;
}
private void lb1_MouseEnter(object sender, EventArgs e)
{
lb1.BackColor = _oSelected;
lb1.ForeColor = Color.White;
pb1.BackColor = _oSelected;
Style(1);
}
private void lb1_MouseLeave(object sender, EventArgs e)
{
lb1.BackColor = _oNormal;
lb1.ForeColor = Color.Black;
pb1.BackColor = _oNormal;
}
private void lb2_MouseEnter(object sender, EventArgs e)
{
lb2.BackColor = _oSelected;
lb2.ForeColor = Color.White;
pb2.BackColor = _oSelected;
Style(2);
}
private void lb2_MouseLeave(object sender, EventArgs e)
{
lb2.BackColor = _oNormal;
lb2.ForeColor = Color.Black;
pb2.BackColor = _oNormal;
}
private void lb3_MouseEnter(object sender, EventArgs e)
{
lb3.BackColor = _oSelected;
lb3.ForeColor = Color.White;
pb3.BackColor = _oSelected;
Style(3);
}
private void lb3_MouseLeave(object sender, EventArgs e)
{
lb3.BackColor = _oNormal;
lb3.ForeColor = Color.Black;
pb3.BackColor = _oNormal;
}
private void lb4_MouseEnter(object sender, EventArgs e)
{
lb4.BackColor = _oSelected;
lb4.ForeColor = Color.White;
pb4.BackColor = _oSelected;
Style(4);
}
private void lb4_MouseLeave(object sender, EventArgs e)
{
lb4.BackColor = _oNormal;
lb4.ForeColor = Color.Black;
pb4.BackColor = _oNormal;
}
private void lb5_MouseEnter(object sender, EventArgs e)
{
lb5.BackColor = _oSelected;
lb5.ForeColor = Color.White;
pb5.BackColor = _oSelected;
Style(5);
}
private void lb5_MouseLeave(object sender, EventArgs e)
{
lb5.BackColor = _oNormal;
lb5.ForeColor = Color.Black;
pb5.BackColor = _oNormal;
}
private void lb6_MouseEnter(object sender, EventArgs e)
{
lb6.BackColor = _oSelected;
lb6.ForeColor = Color.White;
pb6.BackColor = _oSelected;
Style(6);
}
private void lb6_MouseLeave(object sender, EventArgs e)
{
lb6.BackColor = _oNormal;
lb6.ForeColor = Color.Black;
pb6.BackColor = _oNormal;
}
private void lb7_MouseEnter(object sender, EventArgs e)
{
lb7.BackColor = _oSelected;
lb7.ForeColor = Color.White;
pb7.BackColor = _oSelected;
Style(7);
}
private void lb7_MouseLeave(object sender, EventArgs e)
{
lb7.BackColor = _oNormal;
lb7.ForeColor = Color.Black;
pb7.BackColor = _oNormal;
}
private void lb8_MouseEnter(object sender, EventArgs e)
{
lb8.BackColor = _oSelected;
lb8.ForeColor = Color.White;
pb8.BackColor = _oSelected;
Style(8);
}
private void lb8_MouseLeave(object sender, EventArgs e)
{
lb8.BackColor = _oNormal;
lb8.ForeColor = Color.Black;
pb8.BackColor = _oNormal;
}
private void lb9_MouseEnter(object sender, EventArgs e)
{
lb9.BackColor = _oSelected;
lb9.ForeColor = Color.White;
pb9.BackColor = _oSelected;
Style(9);
}
private void lb9_MouseLeave(object sender, EventArgs e)
{
lb9.BackColor = _oNormal;
lb9.ForeColor = Color.Black;
pb9.BackColor = _oNormal;
}
private void lb10_MouseEnter(object sender, EventArgs e)
{
lb10.BackColor = _oSelected;
lb10.ForeColor = Color.White;
pb10.BackColor = _oSelected;
Style(10);
}
private void lb10_MouseLeave(object sender, EventArgs e)
{
lb10.BackColor = _oNormal;
lb10.ForeColor = Color.Black;
pb10.BackColor = _oNormal;
}
private void lb11_MouseEnter(object sender, EventArgs e)
{
lb11.BackColor = _oSelected;
lb11.ForeColor = Color.White;
pb11.BackColor = _oSelected;
Style(11);
}
private void lb11_MouseLeave(object sender, EventArgs e)
{
lb11.BackColor = _oNormal;
lb11.ForeColor = Color.Black;
pb11.BackColor = _oNormal;
}
private void lb12_MouseEnter(object sender, EventArgs e)
{
lb12.BackColor = _oSelected;
lb12.ForeColor = Color.White;
pb12.BackColor = _oSelected;
Style(12);
}
private void lb12_MouseLeave(object sender, EventArgs e)
{
lb12.BackColor = _oNormal;
lb12.ForeColor = Color.Black;
pb12.BackColor = _oNormal;
}
private void lb13_MouseEnter(object sender, EventArgs e)
{
lb13.BackColor = _oSelected;
lb13.ForeColor = Color.White;
pb13.BackColor = _oSelected;
Style(13);
}
private void lb13_MouseLeave(object sender, EventArgs e)
{
lb13.BackColor = _oNormal;
lb13.ForeColor = Color.Black;
pb13.BackColor = _oNormal;
}
private void lb14_MouseEnter(object sender, EventArgs e)
{
lb14.BackColor = _oSelected;
lb14.ForeColor = Color.White;
pb14.BackColor = _oSelected;
Style(14);
}
private void lb14_MouseLeave(object sender, EventArgs e)
{
lb14.BackColor = _oNormal;
lb14.ForeColor = Color.Black;
pb14.BackColor = _oNormal;
}
private void lb15_MouseEnter(object sender, EventArgs e)
{
lb15.BackColor = _oSelected;
lb15.ForeColor = Color.White;
pb15.BackColor = _oSelected;
Style(15);
}
private void lb15_MouseLeave(object sender, EventArgs e)
{
lb15.BackColor = _oNormal;
lb15.ForeColor = Color.Black;
pb15.BackColor = _oNormal;
}
private void lb16_MouseEnter(object sender, EventArgs e)
{
lb16.BackColor = _oSelected;
lb16.ForeColor = Color.White;
pb16.BackColor = _oSelected;
Style(16);
}
private void lb16_MouseLeave(object sender, EventArgs e)
{
lb16.BackColor = _oNormal;
lb16.ForeColor = Color.Black;
pb16.BackColor = _oNormal;
}
private void lb17_MouseEnter(object sender, EventArgs e)
{
lb17.BackColor = _oSelected;
lb17.ForeColor = Color.White;
pb17.BackColor = _oSelected;
Style(17);
}
private void lb17_MouseLeave(object sender, EventArgs e)
{
lb17.BackColor = _oNormal;
lb17.ForeColor = Color.Black;
pb17.BackColor = _oNormal;
}
private void lb18_MouseEnter(object sender, EventArgs e)
{
lb18.BackColor = _oSelected;
lb18.ForeColor = Color.White;
pb18.BackColor = _oSelected;
}
private void lb18_MouseLeave(object sender, EventArgs e)
{
lb18.BackColor = _oNormal;
lb18.ForeColor = Color.Black;
pb18.BackColor = _oNormal;
}
private void pb19_MouseEnter(object sender, EventArgs e)
{
Style(19);
}
private void trkReshow_Scroll(object sender, EventArgs e)
{
_ttMain.ReShowDelay = trkReshow.Value;
lblReshow.Text = "ReShow Delay: " + trkReshow.Value.ToString() + "ms";
}
private void trkFadeout_Scroll(object sender, EventArgs e)
{
_ttMain.FadeDelay = trkFadeout.Value;
lblFadeout.Text = "FadeOut Delay: " + trkFadeout.Value.ToString() + "ms";
}
private void trkAutopop_Scroll(object sender, EventArgs e)
{
_ttMain.AutoPopDelay = trkAutopop.Value;
lblAutopop.Text = "AutoPop Delay: " + trkAutopop.Value.ToString() + "ms";
}
private void trkAutomatic_Scroll(object sender, EventArgs e)
{
_ttMain.AutomaticDelay = trkAutomatic.Value;
lblAutomatic.Text = "Automatic Delay: " + trkAutomatic.Value.ToString() + "ms";
}
private void btUp_Click(object sender, EventArgs e)
{
scrollUp();
}
private void btDown_Click(object sender, EventArgs e)
{
scrollDown();
}
private void scrollUp()
{
SendMessage(txtEvent.Handle, WM_VSCROLL, SB_LINEUP, 0);
}
private void scrollDown()
{
SendMessage(txtEvent.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
_ttMain.Dispose();
_ttBalloon.Dispose();
_ttOwnerDrawn.Dispose();
if (_cDc != null)
_cDc.Dispose();
}
private void llForeColor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
_oForeColor = colorDialog1.Color;
}
private void llTitleForeColor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
_oTitleColor = colorDialog1.Color;
}
private void llCaptionFont_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
_ttMain.TipFont = fontDialog1.Font;
}
private void llTitleFont_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
_ttMain.TitleFont = fontDialog1.Font;
}
private void llReset_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
_oTitleColor = Color.Black;
_oForeColor = Color.Black;
_ttMain.TipFont = new Font("MS Sans Serif", 8, FontStyle.Regular);
_ttMain.TitleFont = new Font("MS Sans Serif", 9, FontStyle.Bold);
}
private void rdFade0_CheckedChanged(object sender, EventArgs e)
{
_ttMain.FadeOut = FadeStyle.Default;
}
private void rdFade1_CheckedChanged(object sender, EventArgs e)
{
_ttMain.FadeOut = FadeStyle.Phaser;
}
private void rdFade2_CheckedChanged(object sender, EventArgs e)
{
_ttMain.FadeOut = FadeStyle.Pulse;
}
private void btUp_MouseMove(object sender, MouseEventArgs e)
{
if ((e.X > (btUp.Size.Width / 2) - 8) && (e.X < (btUp.Size.Width / 2) + 8))
scrollUp();
}
private void btDown_MouseMove(object sender, MouseEventArgs e)
{
if ((e.X > (btDown.Size.Width / 2) - 8) && (e.X < (btDown.Size.Width / 2) + 8))
scrollDown();
}
#endregion
}
}