ToolStrip Border

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gene kelley

    #1

    ToolStrip Border


    The default ToolStrip apparently renders an MS Office Style ToolStrip when the RenderMode is other
    than "System". When using a BackgroundImage in the ToolStrip, this Office Style border has rounded
    corners and looks like hell.

    According to the Help file:

    To change the Microsoft Office–style borders to straight
    Override
    System.Windows. Forms.ToolStrip ProfessionalRen derer.OnRenderT oolStripBorder( System.Windows. Forms.ToolStrip RenderEventArgs ),
    but do not call the base class.


    Can anyone explain or show an example of how the above is implemented?

    Thanks,

    Gene

  • Smokey Grindle

    #2
    Re: ToolStrip Border

    Here's an example of a renderer I wrote (not optimized)


    Imports System.Drawing

    Imports System.Drawing. Drawing2D

    Imports System.Windows. Forms

    Public Class GrayGradRendere r

    Inherits ToolStripRender er

    Dim sbDark As New SolidBrush(Colo r.FromArgb(145, 145, 145))

    Dim sbLight As New SolidBrush(Colo r.FromArgb(255, 255, 255))

    Dim i_Margin As Integer = -1

    <DebuggerStepTh rough()Private Sub MoneyMenuRender er_RenderArrow( ByVal
    sender As Object, ByVal e As
    System.Windows. Forms.ToolStrip ArrowRenderEven tArgs) Handles Me.RenderArrow

    Dim rect As Rectangle = e.ArrowRectangl e

    rect.Y = rect.Y + 1

    rect.Height = rect.Height - 1

    If e.Item.Selected Or e.Item.Pressed Then

    ControlPaint.Dr awMenuGlyph(e.G raphics, rect, MenuGlyph.Arrow ,
    Color.FromArgb( 0, 255, 254, 249), Color.FromArgb( 0, 80, 80, 80))

    Else

    ControlPaint.Dr awMenuGlyph(e.G raphics, rect, MenuGlyph.Arrow ,
    Color.FromArgb( 0, 255, 254, 249), Color.FromArgb( 0, 91, 91, 91))

    End If

    End Sub

    Private Sub GrayGradRendere r_RenderButtonB ackground(ByVal sender As Object,
    ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args) Handles
    Me.RenderButton Background

    Dim radius As Integer = 3

    ' check for selected checked items

    If TypeOf e.Item Is ToolStripButton Then

    If CType(e.Item, ToolStripButton ).Checked = True Then

    e.Graphics.Fill Rectangle(New SolidBrush(Colo r.FromArgb(40, Color.DarkBlue) ),
    0, 0, e.Item.Width - 1, e.Item.Height - 2)

    e.Graphics.Draw Rectangle(New Pen(Color.FromA rgb(200, Color.DarkBlue) ), 0, 0,
    e.Item.Width - 1, e.Item.Height - 2)

    End If

    End If

    If e.Item.Selected = True Then

    DrawRoundedRect angle(e.Graphic s, 0, 0, e.Item.Width - 2, e.Item.Height - 2,
    5)

    End If

    End Sub

    Private Sub GrayGradRendere r_RenderDropDow nButtonBackgrou nd(ByVal sender As
    Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
    Handles Me.RenderDropDo wnButtonBackgro und

    If e.Item.Selected = True Then

    DrawRoundedRect angle(e.Graphic s, 0, 0, e.Item.Width - 2, e.Item.Height - 2,
    5)

    End If

    End Sub

    Private Sub GrayGradRendere r_RenderGrip(By Val sender As Object, ByVal e As
    System.Windows. Forms.ToolStrip GripRenderEvent Args) Handles Me.RenderGrip

    If e.GripStyle = ToolStripGripSt yle.Visible Then

    If e.GripDisplaySt yle = ToolStripGripDi splayStyle.Vert ical Then

    If TypeOf e.ToolStrip Is MenuStrip Then

    ControlPaint.Dr awBorder3D(e.Gr aphics, New Rectangle(0, 2,
    e.GripBounds.Wi dth, e.GripBounds.He ight - 2), Border3DStyle.R aisedInner)

    Else

    ControlPaint.Dr awBorder3D(e.Gr aphics, New Rectangle(0, 2,
    e.GripBounds.Wi dth, e.GripBounds.He ight - 4), Border3DStyle.R aisedInner)

    End If

    Else

    If TypeOf e.ToolStrip Is MenuStrip Then

    ControlPaint.Dr awBorder3D(e.Gr aphics, New Rectangle(0, 0,
    e.GripBounds.Wi dth - 3, e.GripBounds.He ight), Border3DStyle.R aisedInner)

    Else

    ControlPaint.Dr awBorder3D(e.Gr aphics, New Rectangle(2, 0,
    e.GripBounds.Wi dth - 2, e.GripBounds.He ight), Border3DStyle.R aisedInner)

    End If

    End If

    End If

    End Sub

    <DebuggerStepTh rough()Private Sub
    MoneyMenuRender er_RenderImageM argin(ByVal sender As Object, ByVal e As
    System.Windows. Forms.ToolStrip RenderEventArgs ) Handles Me.RenderImageM argin

    i_Margin = e.AffectedBound s.Width

    If My.Computer.Scr een.BitsPerPixe l 8 Then

    Dim br As New Drawing2D.Linea rGradientBrush( e.AffectedBound s,
    Color.FromArgb( 255, 255, 255), Color.FromArgb( 210, 210, 210),
    Drawing2D.Linea rGradientMode.H orizontal)

    e.Graphics.Fill Rectangle(br, e.AffectedBound s)

    Else

    e.Graphics.Fill Rectangle(New SolidBrush(Colo r.White), 0, 0,
    e.AffectedBound s.Width, e.AffectedBound s.Height)

    End If



    e.Graphics.Draw Line(New Pen(Color.White , 1), i_Margin - 1, 0, i_Margin - 1,
    e.AffectedBound s.Height)

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(145, 145, 145), 1), i_Margin - 2,
    0, i_Margin - 2, e.AffectedBound s.Height)



    End Sub

    <DebuggerStepTh rough()Protecte d Overrides Sub OnRenderItemTex t(ByVal e As
    System.Windows. Forms.ToolStrip ItemTextRenderE ventArgs)

    If e.Item.Selected And Not e.Item.Pressed Then

    e.TextColor = Color.White

    ElseIf e.Item.Selected And e.Item.Pressed Then

    e.TextColor = Color.White

    Else

    e.TextColor = Color.Black

    End If

    MyBase.OnRender ItemText(e)

    End Sub



    <DebuggerStepTh rough()Private Sub MoneyMenuRender er_RenderItemCh eck(ByVal
    sender As Object, ByVal e As
    System.Windows. Forms.ToolStrip ItemImageRender EventArgs) Handles
    Me.RenderItemCh eck

    If e.Item.Pressed Then

    ControlPaint.Dr awMenuGlyph(e.G raphics, e.ImageRectangl e,
    MenuGlyph.Check mark, Color.FromArgb( 0, 0, 0), Color.FromArgb( 0, 0, 0, 0))

    End If

    End Sub

    ' renders menu over background

    <DebuggerStepTh rough()Private Sub
    MoneyMenuRender er_RenderMenuIt emBackground(By Val sender As Object, ByVal e
    As System.Windows. Forms.ToolStrip ItemRenderEvent Args) Handles
    Me.RenderMenuIt emBackground

    Dim i_Alpha As Integer = 255

    If e.Item.Selected Or e.Item.Pressed Then

    DrawRoundedRect angle(e.Graphic s, 0, 0, e.Item.Bounds.W idth - 2,
    e.Item.Bounds.H eight - 2, 4)

    End If

    End Sub

    Private Sub GrayGradRendere r_RenderOverflo wButtonBackgrou nd(ByVal sender As
    Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
    Handles Me.RenderOverfl owButtonBackgro und

    'Dim br As New Drawing2D.Linea rGradientBrush( e.Item.Bounds,
    Color.FromArgb( 200, 200, 200), Color.FromArgb( 170, 170, 170),
    Drawing2D.Linea rGradientMode.V ertical)

    ' Dim brHover As New Drawing2D.Linea rGradientBrush( e.Item.Bounds,
    Color.FromArgb( 200, 200, 250), Color.FromArgb( 170, 170, 230),
    Drawing2D.Linea rGradientMode.V ertical)

    If Not e.Item.Selected = False Then

    DrawRoundedRect angle(e.Graphic s, 1, 1, e.Item.Width - 2, e.Item.Height - 4,
    5)

    End If



    If e.Item.Pressed = False Then

    e.Graphics.Draw String("7", New Font("Marlett", 7, FontStyle.Regul ar,
    GraphicsUnit.Po int), Brushes.DarkGra y, e.Item.Width - 14, e.Item.Height -
    11)

    If e.Item.Selected Then

    e.Graphics.Draw String("7", New Font("Marlett", 7, FontStyle.Regul ar,
    GraphicsUnit.Po int), Brushes.White, e.Item.Width - 15, e.Item.Height - 12)

    Else

    e.Graphics.Draw String("7", New Font("Marlett", 7, FontStyle.Regul ar,
    GraphicsUnit.Po int), Brushes.Black, e.Item.Width - 15, e.Item.Height - 12)

    End If



    Else

    e.Graphics.Draw String("7", New Font("Marlett", 7, FontStyle.Regul ar,
    GraphicsUnit.Po int), Brushes.White, e.Item.Width - 14, e.Item.Height - 11)

    End If

    End Sub

    <DebuggerStepTh rough()Private Sub MoneyMenuRender er_RenderSepara tor(ByVal
    sender As Object, ByVal e As
    System.Windows. Forms.ToolStrip SeparatorRender EventArgs) Handles
    Me.RenderSepara tor

    If e.Vertical = False Then

    e.Graphics.Draw Line(New Pen(Color.White , 1), i_Margin, 3,
    e.Item.Bounds.W idth, 3)

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(145, 145, 145), 1), i_Margin, 2,
    e.Item.Bounds.W idth, 2)

    Else

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(145, 145, 145), 1), 1, 2, 1,
    e.Item.Bounds.H eight - 4)

    e.Graphics.Draw Line(New Pen(Color.White , 1), 2, 2, 2, e.Item.Bounds.H eight -
    4)

    End If

    End Sub

    Private Sub GrayGradRendere r_RenderSplitBu ttonBackground( ByVal sender As
    Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
    Handles Me.RenderSplitB uttonBackground

    If e.Item.Selected = False Then

    e.Graphics.Draw String("u", New Font("Marlett", 8, FontStyle.Regul ar,
    GraphicsUnit.Po int), Brushes.Black, e.Item.Width - 14, e.Item.Height - 18)

    Else

    DrawRoundedRect angle(e.Graphic s, 0, 0, e.Item.Width - 2, e.Item.Height - 2,
    5)

    e.Graphics.Draw String("u", New Font("Marlett", 8, FontStyle.Regul ar,
    GraphicsUnit.Po int), Brushes.White, e.Item.Width - 14, e.Item.Height - 18)

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(255, 3, 86, 205)), e.Item.Width -
    13, e.Item.Height - 2, e.Item.Width - 13, e.Item.Height - 22)

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(255, 33, 117, 232)),
    e.Item.Width - 12, e.Item.Height - 2, e.Item.Width - 12, e.Item.Height - 22)

    End If



    End Sub





    'renders background of strip

    <DebuggerStepTh rough()Private Sub
    MoneyMenuRender er_RenderToolSt ripBackground(B yVal sender As Object, ByVal e
    As System.Windows. Forms.ToolStrip RenderEventArgs ) Handles
    Me.RenderToolSt ripBackground

    If My.Computer.Scr een.BitsPerPixe l 8 Then

    Dim sbDark As New SolidBrush(Colo r.FromArgb(145, 145, 145))

    Dim sbLight As New SolidBrush(Colo r.FromArgb(255, 255, 255))

    Dim br As New Drawing2D.Linea rGradientBrush( e.AffectedBound s,
    Color.FromArgb( 236, 236, 236), Color.FromArgb( 200, 200, 200),
    Drawing2D.Linea rGradientMode.V ertical)

    e.Graphics.Fill Rectangle(br, e.AffectedBound s)

    br.Dispose()

    Else

    e.Graphics.Fill Rectangle(Drawi ng.SystemBrushe s.Control, e.AffectedBound s)

    End If

    End Sub

    <DebuggerStepTh rough()Private Sub
    MoneyMenuRender er_RenderToolSt ripBorder(ByVal sender As Object, ByVal e As
    System.Windows. Forms.ToolStrip RenderEventArgs ) Handles
    Me.RenderToolSt ripBorder

    If TypeOf e.ToolStrip Is ToolStripDropDo wnMenu Then

    e.Graphics.Draw Rectangle(New Pen(Color.FromA rgb(145, 145, 145), 1), 0, 0,
    e.AffectedBound s.Width - 1, e.AffectedBound s.Height - 1)

    ElseIf TypeOf e.ToolStrip Is StatusStrip Then

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(255, 255, 255), 1), 0, 0,
    e.AffectedBound s.Width, 0)

    Else

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(255, 255, 255), 1), 0, 0,
    e.AffectedBound s.Width, 0)

    e.Graphics.Draw Line(New Pen(Color.FromA rgb(145, 145, 145), 0), 0,
    e.AffectedBound s.Height - 1, e.AffectedBound s.Width,
    e.AffectedBound s.Height - 1)

    End If

    End Sub



    Public Sub DrawRoundedRect angle(ByVal objGraphics As Graphics, _

    ByVal m_intxAxis As Integer, _

    ByVal m_intyAxis As Integer, _

    ByVal m_intWidth As Integer, _

    ByVal m_intHeight As Integer, _

    ByVal m_diameter As Integer)

    If My.Computer.Scr een.BitsPerPixe l 8 Then

    Dim i_Alpha As Integer = 255



    objGraphics.Smo othingMode = Drawing2D.Smoot hingMode.HighQu ality

    objGraphics.Com positingMode = Drawing2D.Compo sitingMode.Sour ceOver

    objGraphics.Com positingQuality = Drawing2D.Compo sitingQuality.H ighQuality

    'Dim g As Graphics

    Dim BaseRect As New RectangleF(m_in txAxis, m_intyAxis, m_intWidth,
    m_intHeight)

    Dim ArcRect As New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
    m_diameter))

    Dim br As New Drawing2D.Linea rGradientBrush( New Rectangle(m_int xAxis,
    m_intyAxis, m_intWidth, m_intHeight), Color.FromArgb( i_Alpha, 40, 130, 234),
    Color.FromArgb( i_Alpha, 1, 95, 228), Drawing2D.Linea rGradientMode.V ertical)

    Dim p As New Drawing2D.Graph icsPath

    p.StartFigure()

    'top left Arc

    p.AddArc(ArcRec t, 180, 90)

    p.AddLine(m_int xAxis + CInt(m_diameter / 2), m_intyAxis, m_intxAxis +
    m_intWidth - CInt(m_diameter / 2), m_intyAxis)

    ' top right arc

    ArcRect.X = BaseRect.Right - m_diameter

    p.AddArc(ArcRec t, 270, 90)

    p.AddLine(m_int xAxis + m_intWidth, m_intyAxis + CInt(m_diameter / 2),
    m_intxAxis + m_intWidth, m_intyAxis + m_intHeight - CInt(m_diameter / 2))

    ' bottom right arc

    ArcRect.Y = BaseRect.Bottom - m_diameter

    p.AddArc(ArcRec t, 0, 90)

    p.AddLine(m_int xAxis + CInt(m_diameter / 2), _

    m_intyAxis + m_intHeight, _

    m_intxAxis + m_intWidth - CInt(m_diameter / 2), _

    m_intyAxis + m_intHeight)

    ' bottom left arc

    ArcRect.X = BaseRect.Left

    p.AddArc(ArcRec t, 90, 90)

    p.AddLine( _

    m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _

    m_intxAxis, _

    m_intyAxis + m_intHeight - CInt(m_diameter / 2))

    p.CloseAllFigur es()

    objGraphics.Fil lPath(br, p)

    ' draw lines to add depth

    Dim pHlight As New Pen(Color.FromA rgb(i_Alpha, 64, 144, 236))

    Dim pHLightTop As New Pen(Color.FromA rgb(i_Alpha, 33, 117, 232))

    Dim pShad As New Pen(Color.FromA rgb(i_Alpha, 3, 86, 205))

    ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
    m_diameter))

    'top left Arc

    objGraphics.Dra wArc(pHLightTop , ArcRect, 180, 90)

    objGraphics.Dra wLine(pHLightTo p, m_intxAxis + CInt(m_diameter / 2),
    m_intyAxis, m_intxAxis + m_intWidth - CInt(m_diameter / 2), m_intyAxis)

    ' top right arc

    ArcRect.X = BaseRect.Right - m_diameter

    objGraphics.Dra wArc(pShad, ArcRect, 270, 90)

    objGraphics.Dra wLine(pShad, m_intxAxis + m_intWidth, m_intyAxis +
    CInt(m_diameter / 2), m_intxAxis + m_intWidth, m_intyAxis + m_intHeight -
    CInt(m_diameter / 2))



    ' bottom right arc

    ArcRect.Y = BaseRect.Bottom - m_diameter

    objGraphics.Dra wArc(pShad, ArcRect, 0, 90)

    objGraphics.Dra wLine(pShad, m_intxAxis + CInt(m_diameter / 2), _

    m_intyAxis + m_intHeight, _

    m_intxAxis + m_intWidth - CInt(m_diameter / 2), _

    m_intyAxis + m_intHeight)

    ' bottom left arc

    ArcRect.X = BaseRect.Left

    objGraphics.Dra wArc(pHLightTop , ArcRect, 90, 90)

    objGraphics.Dra wLine(pHLightTo p, _

    m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _

    m_intxAxis, _

    m_intyAxis + m_intHeight - CInt(m_diameter / 2))

    ' draw inner lighting

    m_diameter = m_diameter - 1

    ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
    m_diameter))

    ArcRect.X = ArcRect.X + 1

    ArcRect.Y = ArcRect.Y + 1

    'top left Arc

    objGraphics.Dra wArc(pHlight, ArcRect, 180, 90)

    objGraphics.Dra wLine(pHlight, m_intxAxis + CInt(m_diameter / 2) + 1,
    m_intyAxis + 1, m_intxAxis + m_intWidth - CInt(m_diameter / 2) + 1,
    m_intyAxis + 1)

    ' bottom left arc

    ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
    m_diameter))

    ArcRect.X = BaseRect.Left + 1

    ArcRect.Y = m_intHeight + BaseRect.Height - m_diameter - 1

    objGraphics.Dra wArc(pHlight, ArcRect, 90, 90)

    objGraphics.Dra wLine(pHlight, _

    m_intxAxis + 1, m_intyAxis + CInt(m_diameter / 2), _

    m_intxAxis + 1, _

    m_intyAxis + m_intHeight - CInt(m_diameter / 2))

    Else

    objGraphics.Fil lRectangle(Draw ing.SystemBrush es.Highlight, New
    RectangleF(m_in txAxis, m_intyAxis, m_intWidth, m_intHeight))

    End If

    End Sub



    End Class


    Comment

    • gene kelley

      #3
      Re: ToolStrip Border

      On Mon, 28 Aug 2006 09:08:38 -0400, "Smokey Grindle" <nospam@dontspa mme.comwrote:
      >Here's an example of a renderer I wrote (not optimized)
      >
      >
      >Imports System.Drawing
      >
      >Imports System.Drawing. Drawing2D
      >
      >Imports System.Windows. Forms
      >
      >Public Class GrayGradRendere r
      >
      >Inherits ToolStripRender er
      >
      >Dim sbDark As New SolidBrush(Colo r.FromArgb(145, 145, 145))
      >
      >Dim sbLight As New SolidBrush(Colo r.FromArgb(255, 255, 255))
      >
      >Dim i_Margin As Integer = -1
      >
      ><DebuggerStepT hrough()Private Sub MoneyMenuRender er_RenderArrow( ByVal
      >sender As Object, ByVal e As
      >System.Windows .Forms.ToolStri pArrowRenderEve ntArgs) Handles Me.RenderArrow
      >
      >Dim rect As Rectangle = e.ArrowRectangl e
      >
      >rect.Y = rect.Y + 1
      >
      >rect.Height = rect.Height - 1
      >
      >If e.Item.Selected Or e.Item.Pressed Then
      >
      >ControlPaint.D rawMenuGlyph(e. Graphics, rect, MenuGlyph.Arrow ,
      >Color.FromArgb (0, 255, 254, 249), Color.FromArgb( 0, 80, 80, 80))
      >
      >Else
      >
      >ControlPaint.D rawMenuGlyph(e. Graphics, rect, MenuGlyph.Arrow ,
      >Color.FromArgb (0, 255, 254, 249), Color.FromArgb( 0, 91, 91, 91))
      >
      >End If
      >
      >End Sub
      >
      >Private Sub GrayGradRendere r_RenderButtonB ackground(ByVal sender As Object,
      >ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args) Handles
      >Me.RenderButto nBackground
      >
      >Dim radius As Integer = 3
      >
      >' check for selected checked items
      >
      >If TypeOf e.Item Is ToolStripButton Then
      >
      >If CType(e.Item, ToolStripButton ).Checked = True Then
      >
      >e.Graphics.Fil lRectangle(New SolidBrush(Colo r.FromArgb(40, Color.DarkBlue) ),
      >0, 0, e.Item.Width - 1, e.Item.Height - 2)
      >
      >e.Graphics.Dra wRectangle(New Pen(Color.FromA rgb(200, Color.DarkBlue) ), 0, 0,
      >e.Item.Width - 1, e.Item.Height - 2)
      >
      >End If
      >
      >End If
      >
      >If e.Item.Selected = True Then
      >
      >DrawRoundedRec tangle(e.Graphi cs, 0, 0, e.Item.Width - 2, e.Item.Height - 2,
      >5)
      >
      >End If
      >
      >End Sub
      >
      >Private Sub GrayGradRendere r_RenderDropDow nButtonBackgrou nd(ByVal sender As
      >Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
      >Handles Me.RenderDropDo wnButtonBackgro und
      >
      >If e.Item.Selected = True Then
      >
      >DrawRoundedRec tangle(e.Graphi cs, 0, 0, e.Item.Width - 2, e.Item.Height - 2,
      >5)
      >
      >End If
      >
      >End Sub
      >
      >Private Sub GrayGradRendere r_RenderGrip(By Val sender As Object, ByVal e As
      >System.Windows .Forms.ToolStri pGripRenderEven tArgs) Handles Me.RenderGrip
      >
      >If e.GripStyle = ToolStripGripSt yle.Visible Then
      >
      >If e.GripDisplaySt yle = ToolStripGripDi splayStyle.Vert ical Then
      >
      >If TypeOf e.ToolStrip Is MenuStrip Then
      >
      >ControlPaint.D rawBorder3D(e.G raphics, New Rectangle(0, 2,
      >e.GripBounds.W idth, e.GripBounds.He ight - 2), Border3DStyle.R aisedInner)
      >
      >Else
      >
      >ControlPaint.D rawBorder3D(e.G raphics, New Rectangle(0, 2,
      >e.GripBounds.W idth, e.GripBounds.He ight - 4), Border3DStyle.R aisedInner)
      >
      >End If
      >
      >Else
      >
      >If TypeOf e.ToolStrip Is MenuStrip Then
      >
      >ControlPaint.D rawBorder3D(e.G raphics, New Rectangle(0, 0,
      >e.GripBounds.W idth - 3, e.GripBounds.He ight), Border3DStyle.R aisedInner)
      >
      >Else
      >
      >ControlPaint.D rawBorder3D(e.G raphics, New Rectangle(2, 0,
      >e.GripBounds.W idth - 2, e.GripBounds.He ight), Border3DStyle.R aisedInner)
      >
      >End If
      >
      >End If
      >
      >End If
      >
      >End Sub
      >
      ><DebuggerStepT hrough()Private Sub
      >MoneyMenuRende rer_RenderImage Margin(ByVal sender As Object, ByVal e As
      >System.Windows .Forms.ToolStri pRenderEventArg s) Handles Me.RenderImageM argin
      >
      >i_Margin = e.AffectedBound s.Width
      >
      >If My.Computer.Scr een.BitsPerPixe l 8 Then
      >
      >Dim br As New Drawing2D.Linea rGradientBrush( e.AffectedBound s,
      >Color.FromArgb (255, 255, 255), Color.FromArgb( 210, 210, 210),
      >Drawing2D.Line arGradientMode. Horizontal)
      >
      >e.Graphics.Fil lRectangle(br, e.AffectedBound s)
      >
      >Else
      >
      >e.Graphics.Fil lRectangle(New SolidBrush(Colo r.White), 0, 0,
      >e.AffectedBoun ds.Width, e.AffectedBound s.Height)
      >
      >End If
      >
      >
      >
      >e.Graphics.Dra wLine(New Pen(Color.White , 1), i_Margin - 1, 0, i_Margin - 1,
      >e.AffectedBoun ds.Height)
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(145, 145, 145), 1), i_Margin - 2,
      >0, i_Margin - 2, e.AffectedBound s.Height)
      >
      >
      >
      >End Sub
      >
      ><DebuggerStepT hrough()Protect ed Overrides Sub OnRenderItemTex t(ByVal e As
      >System.Windows .Forms.ToolStri pItemTextRender EventArgs)
      >
      >If e.Item.Selected And Not e.Item.Pressed Then
      >
      >e.TextColor = Color.White
      >
      >ElseIf e.Item.Selected And e.Item.Pressed Then
      >
      >e.TextColor = Color.White
      >
      >Else
      >
      >e.TextColor = Color.Black
      >
      >End If
      >
      >MyBase.OnRende rItemText(e)
      >
      >End Sub
      >
      >
      >
      ><DebuggerStepT hrough()Private Sub MoneyMenuRender er_RenderItemCh eck(ByVal
      >sender As Object, ByVal e As
      >System.Windows .Forms.ToolStri pItemImageRende rEventArgs) Handles
      >Me.RenderItemC heck
      >
      >If e.Item.Pressed Then
      >
      >ControlPaint.D rawMenuGlyph(e. Graphics, e.ImageRectangl e,
      >MenuGlyph.Chec kmark, Color.FromArgb( 0, 0, 0), Color.FromArgb( 0, 0, 0, 0))
      >
      >End If
      >
      >End Sub
      >
      >' renders menu over background
      >
      ><DebuggerStepT hrough()Private Sub
      >MoneyMenuRende rer_RenderMenuI temBackground(B yVal sender As Object, ByVal e
      >As System.Windows. Forms.ToolStrip ItemRenderEvent Args) Handles
      >Me.RenderMenuI temBackground
      >
      >Dim i_Alpha As Integer = 255
      >
      >If e.Item.Selected Or e.Item.Pressed Then
      >
      >DrawRoundedRec tangle(e.Graphi cs, 0, 0, e.Item.Bounds.W idth - 2,
      >e.Item.Bounds. Height - 2, 4)
      >
      >End If
      >
      >End Sub
      >
      >Private Sub GrayGradRendere r_RenderOverflo wButtonBackgrou nd(ByVal sender As
      >Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
      >Handles Me.RenderOverfl owButtonBackgro und
      >
      >'Dim br As New Drawing2D.Linea rGradientBrush( e.Item.Bounds,
      >Color.FromArgb (200, 200, 200), Color.FromArgb( 170, 170, 170),
      >Drawing2D.Line arGradientMode. Vertical)
      >
      >' Dim brHover As New Drawing2D.Linea rGradientBrush( e.Item.Bounds,
      >Color.FromArgb (200, 200, 250), Color.FromArgb( 170, 170, 230),
      >Drawing2D.Line arGradientMode. Vertical)
      >
      >If Not e.Item.Selected = False Then
      >
      >DrawRoundedRec tangle(e.Graphi cs, 1, 1, e.Item.Width - 2, e.Item.Height - 4,
      >5)
      >
      >End If
      >
      >
      >
      >If e.Item.Pressed = False Then
      >
      >e.Graphics.Dra wString("7", New Font("Marlett", 7, FontStyle.Regul ar,
      >GraphicsUnit.P oint), Brushes.DarkGra y, e.Item.Width - 14, e.Item.Height -
      >11)
      >
      >If e.Item.Selected Then
      >
      >e.Graphics.Dra wString("7", New Font("Marlett", 7, FontStyle.Regul ar,
      >GraphicsUnit.P oint), Brushes.White, e.Item.Width - 15, e.Item.Height - 12)
      >
      >Else
      >
      >e.Graphics.Dra wString("7", New Font("Marlett", 7, FontStyle.Regul ar,
      >GraphicsUnit.P oint), Brushes.Black, e.Item.Width - 15, e.Item.Height - 12)
      >
      >End If
      >
      >
      >
      >Else
      >
      >e.Graphics.Dra wString("7", New Font("Marlett", 7, FontStyle.Regul ar,
      >GraphicsUnit.P oint), Brushes.White, e.Item.Width - 14, e.Item.Height - 11)
      >
      >End If
      >
      >End Sub
      >
      ><DebuggerStepT hrough()Private Sub MoneyMenuRender er_RenderSepara tor(ByVal
      >sender As Object, ByVal e As
      >System.Windows .Forms.ToolStri pSeparatorRende rEventArgs) Handles
      >Me.RenderSepar ator
      >
      >If e.Vertical = False Then
      >
      >e.Graphics.Dra wLine(New Pen(Color.White , 1), i_Margin, 3,
      >e.Item.Bounds. Width, 3)
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(145, 145, 145), 1), i_Margin, 2,
      >e.Item.Bounds. Width, 2)
      >
      >Else
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(145, 145, 145), 1), 1, 2, 1,
      >e.Item.Bounds. Height - 4)
      >
      >e.Graphics.Dra wLine(New Pen(Color.White , 1), 2, 2, 2, e.Item.Bounds.H eight -
      >4)
      >
      >End If
      >
      >End Sub
      >
      >Private Sub GrayGradRendere r_RenderSplitBu ttonBackground( ByVal sender As
      >Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
      >Handles Me.RenderSplitB uttonBackground
      >
      >If e.Item.Selected = False Then
      >
      >e.Graphics.Dra wString("u", New Font("Marlett", 8, FontStyle.Regul ar,
      >GraphicsUnit.P oint), Brushes.Black, e.Item.Width - 14, e.Item.Height - 18)
      >
      >Else
      >
      >DrawRoundedRec tangle(e.Graphi cs, 0, 0, e.Item.Width - 2, e.Item.Height - 2,
      >5)
      >
      >e.Graphics.Dra wString("u", New Font("Marlett", 8, FontStyle.Regul ar,
      >GraphicsUnit.P oint), Brushes.White, e.Item.Width - 14, e.Item.Height - 18)
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(255, 3, 86, 205)), e.Item.Width -
      >13, e.Item.Height - 2, e.Item.Width - 13, e.Item.Height - 22)
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(255, 33, 117, 232)),
      >e.Item.Width - 12, e.Item.Height - 2, e.Item.Width - 12, e.Item.Height - 22)
      >
      >End If
      >
      >
      >
      >End Sub
      >
      >
      >
      >
      >
      >'renders background of strip
      >
      ><DebuggerStepT hrough()Private Sub
      >MoneyMenuRende rer_RenderToolS tripBackground( ByVal sender As Object, ByVal e
      >As System.Windows. Forms.ToolStrip RenderEventArgs ) Handles
      >Me.RenderToolS tripBackground
      >
      >If My.Computer.Scr een.BitsPerPixe l 8 Then
      >
      >Dim sbDark As New SolidBrush(Colo r.FromArgb(145, 145, 145))
      >
      >Dim sbLight As New SolidBrush(Colo r.FromArgb(255, 255, 255))
      >
      >Dim br As New Drawing2D.Linea rGradientBrush( e.AffectedBound s,
      >Color.FromArgb (236, 236, 236), Color.FromArgb( 200, 200, 200),
      >Drawing2D.Line arGradientMode. Vertical)
      >
      >e.Graphics.Fil lRectangle(br, e.AffectedBound s)
      >
      >br.Dispose()
      >
      >Else
      >
      >e.Graphics.Fil lRectangle(Draw ing.SystemBrush es.Control, e.AffectedBound s)
      >
      >End If
      >
      >End Sub
      >
      ><DebuggerStepT hrough()Private Sub
      >MoneyMenuRende rer_RenderToolS tripBorder(ByVa l sender As Object, ByVal e As
      >System.Windows .Forms.ToolStri pRenderEventArg s) Handles
      >Me.RenderToolS tripBorder
      >
      >If TypeOf e.ToolStrip Is ToolStripDropDo wnMenu Then
      >
      >e.Graphics.Dra wRectangle(New Pen(Color.FromA rgb(145, 145, 145), 1), 0, 0,
      >e.AffectedBoun ds.Width - 1, e.AffectedBound s.Height - 1)
      >
      >ElseIf TypeOf e.ToolStrip Is StatusStrip Then
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(255, 255, 255), 1), 0, 0,
      >e.AffectedBoun ds.Width, 0)
      >
      >Else
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(255, 255, 255), 1), 0, 0,
      >e.AffectedBoun ds.Width, 0)
      >
      >e.Graphics.Dra wLine(New Pen(Color.FromA rgb(145, 145, 145), 0), 0,
      >e.AffectedBoun ds.Height - 1, e.AffectedBound s.Width,
      >e.AffectedBoun ds.Height - 1)
      >
      >End If
      >
      >End Sub
      >
      >
      >
      >Public Sub DrawRoundedRect angle(ByVal objGraphics As Graphics, _
      >
      >ByVal m_intxAxis As Integer, _
      >
      >ByVal m_intyAxis As Integer, _
      >
      >ByVal m_intWidth As Integer, _
      >
      >ByVal m_intHeight As Integer, _
      >
      >ByVal m_diameter As Integer)
      >
      >If My.Computer.Scr een.BitsPerPixe l 8 Then
      >
      >Dim i_Alpha As Integer = 255
      >
      >
      >
      >objGraphics.Sm oothingMode = Drawing2D.Smoot hingMode.HighQu ality
      >
      >objGraphics.Co mpositingMode = Drawing2D.Compo sitingMode.Sour ceOver
      >
      >objGraphics.Co mpositingQualit y = Drawing2D.Compo sitingQuality.H ighQuality
      >
      >'Dim g As Graphics
      >
      >Dim BaseRect As New RectangleF(m_in txAxis, m_intyAxis, m_intWidth,
      >m_intHeight)
      >
      >Dim ArcRect As New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
      >m_diameter))
      >
      >Dim br As New Drawing2D.Linea rGradientBrush( New Rectangle(m_int xAxis,
      >m_intyAxis, m_intWidth, m_intHeight), Color.FromArgb( i_Alpha, 40, 130, 234),
      >Color.FromArgb (i_Alpha, 1, 95, 228), Drawing2D.Linea rGradientMode.V ertical)
      >
      >Dim p As New Drawing2D.Graph icsPath
      >
      >p.StartFigure( )
      >
      >'top left Arc
      >
      >p.AddArc(ArcRe ct, 180, 90)
      >
      >p.AddLine(m_in txAxis + CInt(m_diameter / 2), m_intyAxis, m_intxAxis +
      >m_intWidth - CInt(m_diameter / 2), m_intyAxis)
      >
      >' top right arc
      >
      >ArcRect.X = BaseRect.Right - m_diameter
      >
      >p.AddArc(ArcRe ct, 270, 90)
      >
      >p.AddLine(m_in txAxis + m_intWidth, m_intyAxis + CInt(m_diameter / 2),
      >m_intxAxis + m_intWidth, m_intyAxis + m_intHeight - CInt(m_diameter / 2))
      >
      >' bottom right arc
      >
      >ArcRect.Y = BaseRect.Bottom - m_diameter
      >
      >p.AddArc(ArcRe ct, 0, 90)
      >
      >p.AddLine(m_in txAxis + CInt(m_diameter / 2), _
      >
      >m_intyAxis + m_intHeight, _
      >
      >m_intxAxis + m_intWidth - CInt(m_diameter / 2), _
      >
      >m_intyAxis + m_intHeight)
      >
      >' bottom left arc
      >
      >ArcRect.X = BaseRect.Left
      >
      >p.AddArc(ArcRe ct, 90, 90)
      >
      >p.AddLine( _
      >
      >m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _
      >
      >m_intxAxis, _
      >
      >m_intyAxis + m_intHeight - CInt(m_diameter / 2))
      >
      >p.CloseAllFigu res()
      >
      >objGraphics.Fi llPath(br, p)
      >
      >' draw lines to add depth
      >
      >Dim pHlight As New Pen(Color.FromA rgb(i_Alpha, 64, 144, 236))
      >
      >Dim pHLightTop As New Pen(Color.FromA rgb(i_Alpha, 33, 117, 232))
      >
      >Dim pShad As New Pen(Color.FromA rgb(i_Alpha, 3, 86, 205))
      >
      >ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
      >m_diameter))
      >
      >'top left Arc
      >
      >objGraphics.Dr awArc(pHLightTo p, ArcRect, 180, 90)
      >
      >objGraphics.Dr awLine(pHLightT op, m_intxAxis + CInt(m_diameter / 2),
      >m_intyAxis, m_intxAxis + m_intWidth - CInt(m_diameter / 2), m_intyAxis)
      >
      >' top right arc
      >
      >ArcRect.X = BaseRect.Right - m_diameter
      >
      >objGraphics.Dr awArc(pShad, ArcRect, 270, 90)
      >
      >objGraphics.Dr awLine(pShad, m_intxAxis + m_intWidth, m_intyAxis +
      >CInt(m_diamete r / 2), m_intxAxis + m_intWidth, m_intyAxis + m_intHeight -
      >CInt(m_diamete r / 2))
      >
      >
      >
      >' bottom right arc
      >
      >ArcRect.Y = BaseRect.Bottom - m_diameter
      >
      >objGraphics.Dr awArc(pShad, ArcRect, 0, 90)
      >
      >objGraphics.Dr awLine(pShad, m_intxAxis + CInt(m_diameter / 2), _
      >
      >m_intyAxis + m_intHeight, _
      >
      >m_intxAxis + m_intWidth - CInt(m_diameter / 2), _
      >
      >m_intyAxis + m_intHeight)
      >
      >' bottom left arc
      >
      >ArcRect.X = BaseRect.Left
      >
      >objGraphics.Dr awArc(pHLightTo p, ArcRect, 90, 90)
      >
      >objGraphics.Dr awLine(pHLightT op, _
      >
      >m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _
      >
      >m_intxAxis, _
      >
      >m_intyAxis + m_intHeight - CInt(m_diameter / 2))
      >
      >' draw inner lighting
      >
      >m_diameter = m_diameter - 1
      >
      >ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
      >m_diameter))
      >
      >ArcRect.X = ArcRect.X + 1
      >
      >ArcRect.Y = ArcRect.Y + 1
      >
      >'top left Arc
      >
      >objGraphics.Dr awArc(pHlight, ArcRect, 180, 90)
      >
      >objGraphics.Dr awLine(pHlight, m_intxAxis + CInt(m_diameter / 2) + 1,
      >m_intyAxis + 1, m_intxAxis + m_intWidth - CInt(m_diameter / 2) + 1,
      >m_intyAxis + 1)
      >
      >' bottom left arc
      >
      >ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
      >m_diameter))
      >
      >ArcRect.X = BaseRect.Left + 1
      >
      >ArcRect.Y = m_intHeight + BaseRect.Height - m_diameter - 1
      >
      >objGraphics.Dr awArc(pHlight, ArcRect, 90, 90)
      >
      >objGraphics.Dr awLine(pHlight, _
      >
      >m_intxAxis + 1, m_intyAxis + CInt(m_diameter / 2), _
      >
      >m_intxAxis + 1, _
      >
      >m_intyAxis + m_intHeight - CInt(m_diameter / 2))
      >
      >Else
      >
      >objGraphics.Fi llRectangle(Dra wing.SystemBrus hes.Highlight, New
      >RectangleF(m_i ntxAxis, m_intyAxis, m_intWidth, m_intHeight))
      >
      >End If
      >
      >End Sub
      >
      >
      >
      >End Class
      >
      Well, I don't really have a clue as to how your response answers my question.

      According to the Help file, I need to use the following, but I have no idea how to use it:
      Protected Overrides Sub OnRenderToolStr ipBorder(ByVal e As _
      System.Windows. Forms.ToolStrip RenderEventArgs )
      MyBase.OnRender ToolStripBorder (e)

      End Sub

      Anyone?

      Gene

      Comment

      • Smokey Grindle

        #4
        Re: ToolStrip Border

        look at my example it shows the usage there, I used that same exact event as
        an event, you dont have to override it, you can do it as either an event or
        override



        "gene kelley" <okay@by.mewrot e in message
        news:lne7f2pif2 8ri34h9i6nufqlo dem6fp6ip@4ax.c om...
        On Mon, 28 Aug 2006 09:08:38 -0400, "Smokey Grindle"
        <nospam@dontspa mme.comwrote:
        >
        >>Here's an example of a renderer I wrote (not optimized)
        >>
        >>
        >>Imports System.Drawing
        >>
        >>Imports System.Drawing. Drawing2D
        >>
        >>Imports System.Windows. Forms
        >>
        >>Public Class GrayGradRendere r
        >>
        >>Inherits ToolStripRender er
        >>
        >>Dim sbDark As New SolidBrush(Colo r.FromArgb(145, 145, 145))
        >>
        >>Dim sbLight As New SolidBrush(Colo r.FromArgb(255, 255, 255))
        >>
        >>Dim i_Margin As Integer = -1
        >>
        >><DebuggerStep Through()Privat e Sub MoneyMenuRender er_RenderArrow( ByVal
        >>sender As Object, ByVal e As
        >>System.Window s.Forms.ToolStr ipArrowRenderEv entArgs) Handles Me.RenderArrow
        >>
        >>Dim rect As Rectangle = e.ArrowRectangl e
        >>
        >>rect.Y = rect.Y + 1
        >>
        >>rect.Height = rect.Height - 1
        >>
        >>If e.Item.Selected Or e.Item.Pressed Then
        >>
        >>ControlPaint. DrawMenuGlyph(e .Graphics, rect, MenuGlyph.Arrow ,
        >>Color.FromArg b(0, 255, 254, 249), Color.FromArgb( 0, 80, 80, 80))
        >>
        >>Else
        >>
        >>ControlPaint. DrawMenuGlyph(e .Graphics, rect, MenuGlyph.Arrow ,
        >>Color.FromArg b(0, 255, 254, 249), Color.FromArgb( 0, 91, 91, 91))
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>Private Sub GrayGradRendere r_RenderButtonB ackground(ByVal sender As
        >>Object,
        >>ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args) Handles
        >>Me.RenderButt onBackground
        >>
        >>Dim radius As Integer = 3
        >>
        >>' check for selected checked items
        >>
        >>If TypeOf e.Item Is ToolStripButton Then
        >>
        >>If CType(e.Item, ToolStripButton ).Checked = True Then
        >>
        >>e.Graphics.Fi llRectangle(New SolidBrush(Colo r.FromArgb(40,
        >>Color.DarkBlu e)),
        >>0, 0, e.Item.Width - 1, e.Item.Height - 2)
        >>
        >>e.Graphics.Dr awRectangle(New Pen(Color.FromA rgb(200, Color.DarkBlue) ), 0,
        >>0,
        >>e.Item.Widt h - 1, e.Item.Height - 2)
        >>
        >>End If
        >>
        >>End If
        >>
        >>If e.Item.Selected = True Then
        >>
        >>DrawRoundedRe ctangle(e.Graph ics, 0, 0, e.Item.Width - 2, e.Item.Height -
        >>2,
        >>5)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>Private Sub GrayGradRendere r_RenderDropDow nButtonBackgrou nd(ByVal sender
        >>As
        >>Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
        >>Handles Me.RenderDropDo wnButtonBackgro und
        >>
        >>If e.Item.Selected = True Then
        >>
        >>DrawRoundedRe ctangle(e.Graph ics, 0, 0, e.Item.Width - 2, e.Item.Height -
        >>2,
        >>5)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>Private Sub GrayGradRendere r_RenderGrip(By Val sender As Object, ByVal e As
        >>System.Window s.Forms.ToolStr ipGripRenderEve ntArgs) Handles Me.RenderGrip
        >>
        >>If e.GripStyle = ToolStripGripSt yle.Visible Then
        >>
        >>If e.GripDisplaySt yle = ToolStripGripDi splayStyle.Vert ical Then
        >>
        >>If TypeOf e.ToolStrip Is MenuStrip Then
        >>
        >>ControlPaint. DrawBorder3D(e. Graphics, New Rectangle(0, 2,
        >>e.GripBounds. Width, e.GripBounds.He ight - 2), Border3DStyle.R aisedInner)
        >>
        >>Else
        >>
        >>ControlPaint. DrawBorder3D(e. Graphics, New Rectangle(0, 2,
        >>e.GripBounds. Width, e.GripBounds.He ight - 4), Border3DStyle.R aisedInner)
        >>
        >>End If
        >>
        >>Else
        >>
        >>If TypeOf e.ToolStrip Is MenuStrip Then
        >>
        >>ControlPaint. DrawBorder3D(e. Graphics, New Rectangle(0, 0,
        >>e.GripBounds. Width - 3, e.GripBounds.He ight), Border3DStyle.R aisedInner)
        >>
        >>Else
        >>
        >>ControlPaint. DrawBorder3D(e. Graphics, New Rectangle(2, 0,
        >>e.GripBounds. Width - 2, e.GripBounds.He ight), Border3DStyle.R aisedInner)
        >>
        >>End If
        >>
        >>End If
        >>
        >>End If
        >>
        >>End Sub
        >>
        >><DebuggerStep Through()Privat e Sub
        >>MoneyMenuRend erer_RenderImag eMargin(ByVal sender As Object, ByVal e As
        >>System.Window s.Forms.ToolStr ipRenderEventAr gs) Handles
        >>Me.RenderImag eMargin
        >>
        >>i_Margin = e.AffectedBound s.Width
        >>
        >>If My.Computer.Scr een.BitsPerPixe l 8 Then
        >>
        >>Dim br As New Drawing2D.Linea rGradientBrush( e.AffectedBound s,
        >>Color.FromArg b(255, 255, 255), Color.FromArgb( 210, 210, 210),
        >>Drawing2D.Lin earGradientMode .Horizontal)
        >>
        >>e.Graphics.Fi llRectangle(br, e.AffectedBound s)
        >>
        >>Else
        >>
        >>e.Graphics.Fi llRectangle(New SolidBrush(Colo r.White), 0, 0,
        >>e.AffectedBou nds.Width, e.AffectedBound s.Height)
        >>
        >>End If
        >>
        >>
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.White , 1), i_Margin - 1, 0, i_Margin -
        >>1,
        >>e.AffectedBou nds.Height)
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(145, 145, 145), 1), i_Margin -
        >>2,
        >>0, i_Margin - 2, e.AffectedBound s.Height)
        >>
        >>
        >>
        >>End Sub
        >>
        >><DebuggerStep Through()Protec ted Overrides Sub OnRenderItemTex t(ByVal e
        >>As
        >>System.Window s.Forms.ToolStr ipItemTextRende rEventArgs)
        >>
        >>If e.Item.Selected And Not e.Item.Pressed Then
        >>
        >>e.TextColor = Color.White
        >>
        >>ElseIf e.Item.Selected And e.Item.Pressed Then
        >>
        >>e.TextColor = Color.White
        >>
        >>Else
        >>
        >>e.TextColor = Color.Black
        >>
        >>End If
        >>
        >>MyBase.OnRend erItemText(e)
        >>
        >>End Sub
        >>
        >>
        >>
        >><DebuggerStep Through()Privat e Sub
        >>MoneyMenuRend erer_RenderItem Check(ByVal
        >>sender As Object, ByVal e As
        >>System.Window s.Forms.ToolStr ipItemImageRend erEventArgs) Handles
        >>Me.RenderItem Check
        >>
        >>If e.Item.Pressed Then
        >>
        >>ControlPaint. DrawMenuGlyph(e .Graphics, e.ImageRectangl e,
        >>MenuGlyph.Che ckmark, Color.FromArgb( 0, 0, 0), Color.FromArgb( 0, 0, 0, 0))
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>' renders menu over background
        >>
        >><DebuggerStep Through()Privat e Sub
        >>MoneyMenuRend erer_RenderMenu ItemBackground( ByVal sender As Object, ByVal e
        >>As System.Windows. Forms.ToolStrip ItemRenderEvent Args) Handles
        >>Me.RenderMenu ItemBackground
        >>
        >>Dim i_Alpha As Integer = 255
        >>
        >>If e.Item.Selected Or e.Item.Pressed Then
        >>
        >>DrawRoundedRe ctangle(e.Graph ics, 0, 0, e.Item.Bounds.W idth - 2,
        >>e.Item.Bounds .Height - 2, 4)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>Private Sub GrayGradRendere r_RenderOverflo wButtonBackgrou nd(ByVal sender
        >>As
        >>Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
        >>Handles Me.RenderOverfl owButtonBackgro und
        >>
        >>'Dim br As New Drawing2D.Linea rGradientBrush( e.Item.Bounds,
        >>Color.FromArg b(200, 200, 200), Color.FromArgb( 170, 170, 170),
        >>Drawing2D.Lin earGradientMode .Vertical)
        >>
        >>' Dim brHover As New Drawing2D.Linea rGradientBrush( e.Item.Bounds,
        >>Color.FromArg b(200, 200, 250), Color.FromArgb( 170, 170, 230),
        >>Drawing2D.Lin earGradientMode .Vertical)
        >>
        >>If Not e.Item.Selected = False Then
        >>
        >>DrawRoundedRe ctangle(e.Graph ics, 1, 1, e.Item.Width - 2, e.Item.Height -
        >>4,
        >>5)
        >>
        >>End If
        >>
        >>
        >>
        >>If e.Item.Pressed = False Then
        >>
        >>e.Graphics.Dr awString("7", New Font("Marlett", 7, FontStyle.Regul ar,
        >>GraphicsUnit. Point), Brushes.DarkGra y, e.Item.Width - 14, e.Item.Height -
        >>11)
        >>
        >>If e.Item.Selected Then
        >>
        >>e.Graphics.Dr awString("7", New Font("Marlett", 7, FontStyle.Regul ar,
        >>GraphicsUnit. Point), Brushes.White, e.Item.Width - 15, e.Item.Height - 12)
        >>
        >>Else
        >>
        >>e.Graphics.Dr awString("7", New Font("Marlett", 7, FontStyle.Regul ar,
        >>GraphicsUnit. Point), Brushes.Black, e.Item.Width - 15, e.Item.Height - 12)
        >>
        >>End If
        >>
        >>
        >>
        >>Else
        >>
        >>e.Graphics.Dr awString("7", New Font("Marlett", 7, FontStyle.Regul ar,
        >>GraphicsUnit. Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 11)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >><DebuggerStep Through()Privat e Sub
        >>MoneyMenuRend erer_RenderSepa rator(ByVal
        >>sender As Object, ByVal e As
        >>System.Window s.Forms.ToolStr ipSeparatorRend erEventArgs) Handles
        >>Me.RenderSepa rator
        >>
        >>If e.Vertical = False Then
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.White , 1), i_Margin, 3,
        >>e.Item.Bounds .Width, 3)
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(145, 145, 145), 1), i_Margin,
        >>2,
        >>e.Item.Bounds .Width, 2)
        >>
        >>Else
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(145, 145, 145), 1), 1, 2, 1,
        >>e.Item.Bounds .Height - 4)
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.White , 1), 2, 2, 2,
        >>e.Item.Bounds .Height -
        >>4)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>Private Sub GrayGradRendere r_RenderSplitBu ttonBackground( ByVal sender As
        >>Object, ByVal e As System.Windows. Forms.ToolStrip ItemRenderEvent Args)
        >>Handles Me.RenderSplitB uttonBackground
        >>
        >>If e.Item.Selected = False Then
        >>
        >>e.Graphics.Dr awString("u", New Font("Marlett", 8, FontStyle.Regul ar,
        >>GraphicsUnit. Point), Brushes.Black, e.Item.Width - 14, e.Item.Height - 18)
        >>
        >>Else
        >>
        >>DrawRoundedRe ctangle(e.Graph ics, 0, 0, e.Item.Width - 2, e.Item.Height -
        >>2,
        >>5)
        >>
        >>e.Graphics.Dr awString("u", New Font("Marlett", 8, FontStyle.Regul ar,
        >>GraphicsUnit. Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 18)
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(255, 3, 86, 205)),
        >>e.Item.Widt h -
        >>13, e.Item.Height - 2, e.Item.Width - 13, e.Item.Height - 22)
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(255, 33, 117, 232)),
        >>e.Item.Widt h - 12, e.Item.Height - 2, e.Item.Width - 12, e.Item.Height -
        >>22)
        >>
        >>End If
        >>
        >>
        >>
        >>End Sub
        >>
        >>
        >>
        >>
        >>
        >>'renders background of strip
        >>
        >><DebuggerStep Through()Privat e Sub
        >>MoneyMenuRend erer_RenderTool StripBackground (ByVal sender As Object, ByVal
        >>e
        >>As System.Windows. Forms.ToolStrip RenderEventArgs ) Handles
        >>Me.RenderTool StripBackground
        >>
        >>If My.Computer.Scr een.BitsPerPixe l 8 Then
        >>
        >>Dim sbDark As New SolidBrush(Colo r.FromArgb(145, 145, 145))
        >>
        >>Dim sbLight As New SolidBrush(Colo r.FromArgb(255, 255, 255))
        >>
        >>Dim br As New Drawing2D.Linea rGradientBrush( e.AffectedBound s,
        >>Color.FromArg b(236, 236, 236), Color.FromArgb( 200, 200, 200),
        >>Drawing2D.Lin earGradientMode .Vertical)
        >>
        >>e.Graphics.Fi llRectangle(br, e.AffectedBound s)
        >>
        >>br.Dispose( )
        >>
        >>Else
        >>
        >>e.Graphics.Fi llRectangle(Dra wing.SystemBrus hes.Control, e.AffectedBound s)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >><DebuggerStep Through()Privat e Sub
        >>MoneyMenuRend erer_RenderTool StripBorder(ByV al sender As Object, ByVal e As
        >>System.Window s.Forms.ToolStr ipRenderEventAr gs) Handles
        >>Me.RenderTool StripBorder
        >>
        >>If TypeOf e.ToolStrip Is ToolStripDropDo wnMenu Then
        >>
        >>e.Graphics.Dr awRectangle(New Pen(Color.FromA rgb(145, 145, 145), 1), 0, 0,
        >>e.AffectedBou nds.Width - 1, e.AffectedBound s.Height - 1)
        >>
        >>ElseIf TypeOf e.ToolStrip Is StatusStrip Then
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(255, 255, 255), 1), 0, 0,
        >>e.AffectedBou nds.Width, 0)
        >>
        >>Else
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(255, 255, 255), 1), 0, 0,
        >>e.AffectedBou nds.Width, 0)
        >>
        >>e.Graphics.Dr awLine(New Pen(Color.FromA rgb(145, 145, 145), 0), 0,
        >>e.AffectedBou nds.Height - 1, e.AffectedBound s.Width,
        >>e.AffectedBou nds.Height - 1)
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>
        >>
        >>Public Sub DrawRoundedRect angle(ByVal objGraphics As Graphics, _
        >>
        >>ByVal m_intxAxis As Integer, _
        >>
        >>ByVal m_intyAxis As Integer, _
        >>
        >>ByVal m_intWidth As Integer, _
        >>
        >>ByVal m_intHeight As Integer, _
        >>
        >>ByVal m_diameter As Integer)
        >>
        >>If My.Computer.Scr een.BitsPerPixe l 8 Then
        >>
        >>Dim i_Alpha As Integer = 255
        >>
        >>
        >>
        >>objGraphics.S moothingMode = Drawing2D.Smoot hingMode.HighQu ality
        >>
        >>objGraphics.C ompositingMode = Drawing2D.Compo sitingMode.Sour ceOver
        >>
        >>objGraphics.C ompositingQuali ty = Drawing2D.Compo sitingQuality.H ighQuality
        >>
        >>'Dim g As Graphics
        >>
        >>Dim BaseRect As New RectangleF(m_in txAxis, m_intyAxis, m_intWidth,
        >>m_intHeight )
        >>
        >>Dim ArcRect As New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
        >>m_diameter) )
        >>
        >>Dim br As New Drawing2D.Linea rGradientBrush( New Rectangle(m_int xAxis,
        >>m_intyAxis, m_intWidth, m_intHeight), Color.FromArgb( i_Alpha, 40, 130,
        >>234),
        >>Color.FromArg b(i_Alpha, 1, 95, 228),
        >>Drawing2D.Lin earGradientMode .Vertical)
        >>
        >>Dim p As New Drawing2D.Graph icsPath
        >>
        >>p.StartFigure ()
        >>
        >>'top left Arc
        >>
        >>p.AddArc(ArcR ect, 180, 90)
        >>
        >>p.AddLine(m_i ntxAxis + CInt(m_diameter / 2), m_intyAxis, m_intxAxis +
        >>m_intWidth - CInt(m_diameter / 2), m_intyAxis)
        >>
        >>' top right arc
        >>
        >>ArcRect.X = BaseRect.Right - m_diameter
        >>
        >>p.AddArc(ArcR ect, 270, 90)
        >>
        >>p.AddLine(m_i ntxAxis + m_intWidth, m_intyAxis + CInt(m_diameter / 2),
        >>m_intxAxis + m_intWidth, m_intyAxis + m_intHeight - CInt(m_diameter / 2))
        >>
        >>' bottom right arc
        >>
        >>ArcRect.Y = BaseRect.Bottom - m_diameter
        >>
        >>p.AddArc(ArcR ect, 0, 90)
        >>
        >>p.AddLine(m_i ntxAxis + CInt(m_diameter / 2), _
        >>
        >>m_intyAxis + m_intHeight, _
        >>
        >>m_intxAxis + m_intWidth - CInt(m_diameter / 2), _
        >>
        >>m_intyAxis + m_intHeight)
        >>
        >>' bottom left arc
        >>
        >>ArcRect.X = BaseRect.Left
        >>
        >>p.AddArc(ArcR ect, 90, 90)
        >>
        >>p.AddLine( _
        >>
        >>m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _
        >>
        >>m_intxAxis, _
        >>
        >>m_intyAxis + m_intHeight - CInt(m_diameter / 2))
        >>
        >>p.CloseAllFig ures()
        >>
        >>objGraphics.F illPath(br, p)
        >>
        >>' draw lines to add depth
        >>
        >>Dim pHlight As New Pen(Color.FromA rgb(i_Alpha, 64, 144, 236))
        >>
        >>Dim pHLightTop As New Pen(Color.FromA rgb(i_Alpha, 33, 117, 232))
        >>
        >>Dim pShad As New Pen(Color.FromA rgb(i_Alpha, 3, 86, 205))
        >>
        >>ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
        >>m_diameter) )
        >>
        >>'top left Arc
        >>
        >>objGraphics.D rawArc(pHLightT op, ArcRect, 180, 90)
        >>
        >>objGraphics.D rawLine(pHLight Top, m_intxAxis + CInt(m_diameter / 2),
        >>m_intyAxis, m_intxAxis + m_intWidth - CInt(m_diameter / 2), m_intyAxis)
        >>
        >>' top right arc
        >>
        >>ArcRect.X = BaseRect.Right - m_diameter
        >>
        >>objGraphics.D rawArc(pShad, ArcRect, 270, 90)
        >>
        >>objGraphics.D rawLine(pShad, m_intxAxis + m_intWidth, m_intyAxis +
        >>CInt(m_diamet er / 2), m_intxAxis + m_intWidth, m_intyAxis + m_intHeight -
        >>CInt(m_diamet er / 2))
        >>
        >>
        >>
        >>' bottom right arc
        >>
        >>ArcRect.Y = BaseRect.Bottom - m_diameter
        >>
        >>objGraphics.D rawArc(pShad, ArcRect, 0, 90)
        >>
        >>objGraphics.D rawLine(pShad, m_intxAxis + CInt(m_diameter / 2), _
        >>
        >>m_intyAxis + m_intHeight, _
        >>
        >>m_intxAxis + m_intWidth - CInt(m_diameter / 2), _
        >>
        >>m_intyAxis + m_intHeight)
        >>
        >>' bottom left arc
        >>
        >>ArcRect.X = BaseRect.Left
        >>
        >>objGraphics.D rawArc(pHLightT op, ArcRect, 90, 90)
        >>
        >>objGraphics.D rawLine(pHLight Top, _
        >>
        >>m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _
        >>
        >>m_intxAxis, _
        >>
        >>m_intyAxis + m_intHeight - CInt(m_diameter / 2))
        >>
        >>' draw inner lighting
        >>
        >>m_diameter = m_diameter - 1
        >>
        >>ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
        >>m_diameter) )
        >>
        >>ArcRect.X = ArcRect.X + 1
        >>
        >>ArcRect.Y = ArcRect.Y + 1
        >>
        >>'top left Arc
        >>
        >>objGraphics.D rawArc(pHlight, ArcRect, 180, 90)
        >>
        >>objGraphics.D rawLine(pHlight , m_intxAxis + CInt(m_diameter / 2) + 1,
        >>m_intyAxis + 1, m_intxAxis + m_intWidth - CInt(m_diameter / 2) + 1,
        >>m_intyAxis + 1)
        >>
        >>' bottom left arc
        >>
        >>ArcRect = New RectangleF(Base Rect.Location, New SizeF(m_diamete r,
        >>m_diameter) )
        >>
        >>ArcRect.X = BaseRect.Left + 1
        >>
        >>ArcRect.Y = m_intHeight + BaseRect.Height - m_diameter - 1
        >>
        >>objGraphics.D rawArc(pHlight, ArcRect, 90, 90)
        >>
        >>objGraphics.D rawLine(pHlight , _
        >>
        >>m_intxAxis + 1, m_intyAxis + CInt(m_diameter / 2), _
        >>
        >>m_intxAxis + 1, _
        >>
        >>m_intyAxis + m_intHeight - CInt(m_diameter / 2))
        >>
        >>Else
        >>
        >>objGraphics.F illRectangle(Dr awing.SystemBru shes.Highlight, New
        >>RectangleF(m_ intxAxis, m_intyAxis, m_intWidth, m_intHeight))
        >>
        >>End If
        >>
        >>End Sub
        >>
        >>
        >>
        >>End Class
        >>
        >
        Well, I don't really have a clue as to how your response answers my
        question.
        >
        According to the Help file, I need to use the following, but I have no
        idea how to use it:
        Protected Overrides Sub OnRenderToolStr ipBorder(ByVal e As _
        System.Windows. Forms.ToolStrip RenderEventArgs )
        MyBase.OnRender ToolStripBorder (e)
        >
        End Sub
        >
        Anyone?
        >
        Gene

        Comment

        • gene kelley

          #5
          Re: ToolStrip Border

          On Tue, 29 Aug 2006 08:34:39 -0400, "Smokey Grindle" <nospam@dontspa mme.comwrote:
          >look at my example it shows the usage there, I used that same exact event as
          >an event, you dont have to override it, you can do it as either an event or
          >override
          Well, I thank you for your time and reply. But as I previously noted, I don't understand your
          example.

          I would have thought that this would be a simple matter. I wound up with a "kludge" fix by drawing
          a 3 pixel line at each end of the ToolStrip which covers up the rounded edges.

          Gene

          Comment

          Working...