protected virtual void OnDrawTicks(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            if (((this.OwnerDrawParts & TrackBarOwnerDrawParts.Ticks) == TrackBarOwnerDrawParts.Ticks) && !this.DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, this.ClientRectangle, (TrackBarItemState)this.thumbState);

                if (this.DrawTicks != null)
                {
                    this.DrawTicks(this, e);
                }
            }
            else
            {
                if (this.TickStyle == TickStyle.None)
                {
                    return;
                }

                if (this.thumbBounds == Rectangle.Empty)
                {
                    return;
                }

                Color black = Color.Black;

                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int)TrackBarNativeMethods.TrackBarParts.TKP_TICS, this.thumbState);
                    black = vsr.GetColor(ColorProperty.TextColor);
                }

                if (this.Orientation == Orientation.Horizontal)
                {
                    this.DrawHorizontalTicks(graphics, black);
                }
                else
                {
                    this.DrawVerticalTicks(graphics, black);
                }
            }

            graphics.Dispose();
        }
        protected virtual void OnDrawThumb(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            graphics.Clip = new Region(this.thumbBounds);

            if (((this.OwnerDrawParts & TrackBarOwnerDrawParts.Thumb) == TrackBarOwnerDrawParts.Thumb) && !this.DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, this.thumbBounds, (TrackBarItemState)this.thumbState);
                if (this.DrawThumb != null)
                {
                    this.DrawThumb(this, e);
                }
            }
            else
            {
                // Determine the style of the thumb, based on the tickstyle
                TrackBarNativeMethods.TrackBarParts part = TrackBarNativeMethods.TrackBarParts.TKP_THUMB;
                if (this.thumbBounds == Rectangle.Empty)
                {
                    return;
                }

                switch (this.TickStyle)
                {
                case TickStyle.None:
                case TickStyle.BottomRight:
                    part = (this.Orientation != Orientation.Horizontal) ? TrackBarNativeMethods.TrackBarParts.TKP_THUMBRIGHT : TrackBarNativeMethods.TrackBarParts.TKP_THUMBBOTTOM;
                    break;

                case TickStyle.TopLeft:
                    part = (this.Orientation != Orientation.Horizontal) ? TrackBarNativeMethods.TrackBarParts.TKP_THUMBLEFT : TrackBarNativeMethods.TrackBarParts.TKP_THUMBTOP;
                    break;

                case TickStyle.Both:
                    part = (this.Orientation != Orientation.Horizontal) ? TrackBarNativeMethods.TrackBarParts.TKP_THUMBVERT : TrackBarNativeMethods.TrackBarParts.TKP_THUMB;
                    break;
                }

                // Perform drawing
                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int)part, this.thumbState);
                    vsr.DrawBackground(graphics, this.thumbBounds);
                    graphics.ResetClip();
                    graphics.Dispose();
                    return;
                }
                else
                {
                    switch (part)
                    {
                    case TrackBarNativeMethods.TrackBarParts.TKP_THUMBBOTTOM:
                        this.DrawPointerDown(graphics);
                        break;

                    case TrackBarNativeMethods.TrackBarParts.TKP_THUMBTOP:
                        this.DrawPointerUp(graphics);

                        break;

                    case TrackBarNativeMethods.TrackBarParts.TKP_THUMBLEFT:
                        this.DrawPointerLeft(graphics);

                        break;

                    case TrackBarNativeMethods.TrackBarParts.TKP_THUMBRIGHT:
                        this.DrawPointerRight(graphics);

                        break;

                    default:
                        if ((this.thumbState == 3) || !this.Enabled)
                        {
                            ControlPaint.DrawButton(graphics, this.thumbBounds, ButtonState.All);
                        }
                        else
                        {
                            // Tick-style is both - draw the thumb as a solid rectangle
                            graphics.FillRectangle(SystemBrushes.Control, this.thumbBounds);
                        }

                        ControlPaint.DrawBorder3D(graphics, this.thumbBounds, Border3DStyle.Raised);

                        break;
                    }
                }
            }

            graphics.ResetClip();
            graphics.Dispose();
        }