|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ToolStrip BorderThe 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.ToolStripProfessionalRenderer.OnRenderToolStripBorder(System.Windows.Forms.ToolStripRenderEventArgs), but do not call the base class. Can anyone explain or show an example of how the above is implemented? Thanks, Gene Here's an example of a renderer I wrote (not optimized)
Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms Public Class GrayGradRenderer Inherits ToolStripRenderer Dim sbDark As New SolidBrush(Color.FromArgb(145, 145, 145)) Dim sbLight As New SolidBrush(Color.FromArgb(255, 255, 255)) Dim i_Margin As Integer = -1 <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderArrow(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripArrowRenderEventArgs) Handles Me.RenderArrow Dim rect As Rectangle = e.ArrowRectangle 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.FromArgb(0, 255, 254, 249), Color.FromArgb(0, 80, 80, 80)) Else ControlPaint.DrawMenuGlyph(e.Graphics, rect, MenuGlyph.Arrow, Color.FromArgb(0, 255, 254, 249), Color.FromArgb(0, 91, 91, 91)) End If End Sub Private Sub GrayGradRenderer_RenderButtonBackground(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles Me.RenderButtonBackground 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.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.DarkBlue)), 0, 0, e.Item.Width - 1, e.Item.Height - 2) e.Graphics.DrawRectangle(New Pen(Color.FromArgb(200, Color.DarkBlue)), 0, 0, e.Item.Width - 1, e.Item.Height - 2) End If End If If e.Item.Selected = True Then DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - 2, 5) End If End Sub Private Sub GrayGradRenderer_RenderDropDownButtonBackground(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles Me.RenderDropDownButtonBackground If e.Item.Selected = True Then DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - 2, 5) End If End Sub Private Sub GrayGradRenderer_RenderGrip(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripGripRenderEventArgs) Handles Me.RenderGrip If e.GripStyle = ToolStripGripStyle.Visible Then If e.GripDisplayStyle = ToolStripGripDisplayStyle.Vertical Then If TypeOf e.ToolStrip Is MenuStrip Then ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 2, e.GripBounds.Width, e.GripBounds.Height - 2), Border3DStyle.RaisedInner) Else ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 2, e.GripBounds.Width, e.GripBounds.Height - 4), Border3DStyle.RaisedInner) End If Else If TypeOf e.ToolStrip Is MenuStrip Then ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 0, e.GripBounds.Width - 3, e.GripBounds.Height), Border3DStyle.RaisedInner) Else ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(2, 0, e.GripBounds.Width - 2, e.GripBounds.Height), Border3DStyle.RaisedInner) End If End If End If End Sub <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderImageMargin(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripRenderEventArgs) Handles Me.RenderImageMargin i_Margin = e.AffectedBounds.Width If My.Computer.Screen.BitsPerPixel > 8 Then Dim br As New Drawing2D.LinearGradientBrush(e.AffectedBounds, Color.FromArgb(255, 255, 255), Color.FromArgb(210, 210, 210), Drawing2D.LinearGradientMode.Horizontal) e.Graphics.FillRectangle(br, e.AffectedBounds) Else e.Graphics.FillRectangle(New SolidBrush(Color.White), 0, 0, e.AffectedBounds.Width, e.AffectedBounds.Height) End If e.Graphics.DrawLine(New Pen(Color.White, 1), i_Margin - 1, 0, i_Margin - 1, e.AffectedBounds.Height) e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), i_Margin - 2, 0, i_Margin - 2, e.AffectedBounds.Height) End Sub <DebuggerStepThrough()> Protected Overrides Sub OnRenderItemText(ByVal e As System.Windows.Forms.ToolStripItemTextRenderEventArgs) 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.OnRenderItemText(e) End Sub <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemImageRenderEventArgs) Handles Me.RenderItemCheck If e.Item.Pressed Then ControlPaint.DrawMenuGlyph(e.Graphics, e.ImageRectangle, MenuGlyph.Checkmark, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0, 0)) End If End Sub ' renders menu over background <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderMenuItemBackground(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles Me.RenderMenuItemBackground Dim i_Alpha As Integer = 255 If e.Item.Selected Or e.Item.Pressed Then DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Bounds.Width - 2, e.Item.Bounds.Height - 2, 4) End If End Sub Private Sub GrayGradRenderer_RenderOverflowButtonBackground(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles Me.RenderOverflowButtonBackground 'Dim br As New Drawing2D.LinearGradientBrush(e.Item.Bounds, Color.FromArgb(200, 200, 200), Color.FromArgb(170, 170, 170), Drawing2D.LinearGradientMode.Vertical) ' Dim brHover As New Drawing2D.LinearGradientBrush(e.Item.Bounds, Color.FromArgb(200, 200, 250), Color.FromArgb(170, 170, 230), Drawing2D.LinearGradientMode.Vertical) If Not e.Item.Selected = False Then DrawRoundedRectangle(e.Graphics, 1, 1, e.Item.Width - 2, e.Item.Height - 4, 5) End If If e.Item.Pressed = False Then e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, GraphicsUnit.Point), Brushes.DarkGray, e.Item.Width - 14, e.Item.Height - 11) If e.Item.Selected Then e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, GraphicsUnit.Point), Brushes.White, e.Item.Width - 15, e.Item.Height - 12) Else e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, GraphicsUnit.Point), Brushes.Black, e.Item.Width - 15, e.Item.Height - 12) End If Else e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, GraphicsUnit.Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 11) End If End Sub <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderSeparator(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripSeparatorRenderEventArgs) Handles Me.RenderSeparator If e.Vertical = False Then e.Graphics.DrawLine(New Pen(Color.White, 1), i_Margin, 3, e.Item.Bounds.Width, 3) e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), i_Margin, 2, e.Item.Bounds.Width, 2) Else e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), 1, 2, 1, e.Item.Bounds.Height - 4) e.Graphics.DrawLine(New Pen(Color.White, 1), 2, 2, 2, e.Item.Bounds.Height - 4) End If End Sub Private Sub GrayGradRenderer_RenderSplitButtonBackground(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles Me.RenderSplitButtonBackground If e.Item.Selected = False Then e.Graphics.DrawString("u", New Font("Marlett", 8, FontStyle.Regular, GraphicsUnit.Point), Brushes.Black, e.Item.Width - 14, e.Item.Height - 18) Else DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - 2, 5) e.Graphics.DrawString("u", New Font("Marlett", 8, FontStyle.Regular, GraphicsUnit.Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 18) e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 3, 86, 205)), e.Item.Width - 13, e.Item.Height - 2, e.Item.Width - 13, e.Item.Height - 22) e.Graphics.DrawLine(New Pen(Color.FromArgb(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 <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderToolStripBackground(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripRenderEventArgs) Handles Me.RenderToolStripBackground If My.Computer.Screen.BitsPerPixel > 8 Then Dim sbDark As New SolidBrush(Color.FromArgb(145, 145, 145)) Dim sbLight As New SolidBrush(Color.FromArgb(255, 255, 255)) Dim br As New Drawing2D.LinearGradientBrush(e.AffectedBounds, Color.FromArgb(236, 236, 236), Color.FromArgb(200, 200, 200), Drawing2D.LinearGradientMode.Vertical) e.Graphics.FillRectangle(br, e.AffectedBounds) br.Dispose() Else e.Graphics.FillRectangle(Drawing.SystemBrushes.Control, e.AffectedBounds) End If End Sub <DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderToolStripBorder(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripRenderEventArgs) Handles Me.RenderToolStripBorder If TypeOf e.ToolStrip Is ToolStripDropDownMenu Then e.Graphics.DrawRectangle(New Pen(Color.FromArgb(145, 145, 145), 1), 0, 0, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1) ElseIf TypeOf e.ToolStrip Is StatusStrip Then e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 255, 255), 1), 0, 0, e.AffectedBounds.Width, 0) Else e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 255, 255), 1), 0, 0, e.AffectedBounds.Width, 0) e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 0), 0, e.AffectedBounds.Height - 1, e.AffectedBounds.Width, e.AffectedBounds.Height - 1) End If End Sub Public Sub DrawRoundedRectangle(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.Screen.BitsPerPixel > 8 Then Dim i_Alpha As Integer = 255 objGraphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality objGraphics.CompositingMode = Drawing2D.CompositingMode.SourceOver objGraphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality 'Dim g As Graphics Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, m_intHeight) Dim ArcRect As New RectangleF(BaseRect.Location, New SizeF(m_diameter, m_diameter)) Dim br As New Drawing2D.LinearGradientBrush(New Rectangle(m_intxAxis, m_intyAxis, m_intWidth, m_intHeight), Color.FromArgb(i_Alpha, 40, 130, 234), Color.FromArgb(i_Alpha, 1, 95, 228), Drawing2D.LinearGradientMode.Vertical) Dim p As New Drawing2D.GraphicsPath p.StartFigure() 'top left Arc p.AddArc(ArcRect, 180, 90) p.AddLine(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 p.AddArc(ArcRect, 270, 90) p.AddLine(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 p.AddArc(ArcRect, 0, 90) p.AddLine(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 p.AddArc(ArcRect, 90, 90) p.AddLine( _ m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _ m_intxAxis, _ m_intyAxis + m_intHeight - CInt(m_diameter / 2)) p.CloseAllFigures() objGraphics.FillPath(br, p) ' draw lines to add depth Dim pHlight As New Pen(Color.FromArgb(i_Alpha, 64, 144, 236)) Dim pHLightTop As New Pen(Color.FromArgb(i_Alpha, 33, 117, 232)) Dim pShad As New Pen(Color.FromArgb(i_Alpha, 3, 86, 205)) ArcRect = New RectangleF(BaseRect.Location, New SizeF(m_diameter, m_diameter)) 'top left Arc objGraphics.DrawArc(pHLightTop, ArcRect, 180, 90) objGraphics.DrawLine(pHLightTop, 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.DrawArc(pShad, ArcRect, 270, 90) objGraphics.DrawLine(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.DrawArc(pShad, ArcRect, 0, 90) objGraphics.DrawLine(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.DrawArc(pHLightTop, ArcRect, 90, 90) objGraphics.DrawLine(pHLightTop, _ 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(BaseRect.Location, New SizeF(m_diameter, m_diameter)) ArcRect.X = ArcRect.X + 1 ArcRect.Y = ArcRect.Y + 1 'top left Arc objGraphics.DrawArc(pHlight, ArcRect, 180, 90) objGraphics.DrawLine(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(BaseRect.Location, New SizeF(m_diameter, m_diameter)) ArcRect.X = BaseRect.Left + 1 ArcRect.Y = m_intHeight + BaseRect.Height - m_diameter - 1 objGraphics.DrawArc(pHlight, ArcRect, 90, 90) objGraphics.DrawLine(pHlight, _ m_intxAxis + 1, m_intyAxis + CInt(m_diameter / 2), _ m_intxAxis + 1, _ m_intyAxis + m_intHeight - CInt(m_diameter / 2)) Else objGraphics.FillRectangle(Drawing.SystemBrushes.Highlight, New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, m_intHeight)) End If End Sub End Class
Show quote
Hide quote
On Mon, 28 Aug 2006 09:08:38 -0400, "Smokey Grindle" <nospam@dontspamme.com> wrote: Well, I don't really have a clue as to how your response answers my question. >Here's an example of a renderer I wrote (not optimized) > > >Imports System.Drawing > >Imports System.Drawing.Drawing2D > >Imports System.Windows.Forms > >Public Class GrayGradRenderer > >Inherits ToolStripRenderer > >Dim sbDark As New SolidBrush(Color.FromArgb(145, 145, 145)) > >Dim sbLight As New SolidBrush(Color.FromArgb(255, 255, 255)) > >Dim i_Margin As Integer = -1 > ><DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderArrow(ByVal >sender As Object, ByVal e As >System.Windows.Forms.ToolStripArrowRenderEventArgs) Handles Me.RenderArrow > >Dim rect As Rectangle = e.ArrowRectangle > >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.FromArgb(0, 255, 254, 249), Color.FromArgb(0, 80, 80, 80)) > >Else > >ControlPaint.DrawMenuGlyph(e.Graphics, rect, MenuGlyph.Arrow, >Color.FromArgb(0, 255, 254, 249), Color.FromArgb(0, 91, 91, 91)) > >End If > >End Sub > >Private Sub GrayGradRenderer_RenderButtonBackground(ByVal sender As Object, >ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles >Me.RenderButtonBackground > >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.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.DarkBlue)), >0, 0, e.Item.Width - 1, e.Item.Height - 2) > >e.Graphics.DrawRectangle(New Pen(Color.FromArgb(200, Color.DarkBlue)), 0, 0, >e.Item.Width - 1, e.Item.Height - 2) > >End If > >End If > >If e.Item.Selected = True Then > >DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - 2, >5) > >End If > >End Sub > >Private Sub GrayGradRenderer_RenderDropDownButtonBackground(ByVal sender As >Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) >Handles Me.RenderDropDownButtonBackground > >If e.Item.Selected = True Then > >DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - 2, >5) > >End If > >End Sub > >Private Sub GrayGradRenderer_RenderGrip(ByVal sender As Object, ByVal e As >System.Windows.Forms.ToolStripGripRenderEventArgs) Handles Me.RenderGrip > >If e.GripStyle = ToolStripGripStyle.Visible Then > >If e.GripDisplayStyle = ToolStripGripDisplayStyle.Vertical Then > >If TypeOf e.ToolStrip Is MenuStrip Then > >ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 2, >e.GripBounds.Width, e.GripBounds.Height - 2), Border3DStyle.RaisedInner) > >Else > >ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 2, >e.GripBounds.Width, e.GripBounds.Height - 4), Border3DStyle.RaisedInner) > >End If > >Else > >If TypeOf e.ToolStrip Is MenuStrip Then > >ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 0, >e.GripBounds.Width - 3, e.GripBounds.Height), Border3DStyle.RaisedInner) > >Else > >ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(2, 0, >e.GripBounds.Width - 2, e.GripBounds.Height), Border3DStyle.RaisedInner) > >End If > >End If > >End If > >End Sub > ><DebuggerStepThrough()> Private Sub >MoneyMenuRenderer_RenderImageMargin(ByVal sender As Object, ByVal e As >System.Windows.Forms.ToolStripRenderEventArgs) Handles Me.RenderImageMargin > >i_Margin = e.AffectedBounds.Width > >If My.Computer.Screen.BitsPerPixel > 8 Then > >Dim br As New Drawing2D.LinearGradientBrush(e.AffectedBounds, >Color.FromArgb(255, 255, 255), Color.FromArgb(210, 210, 210), >Drawing2D.LinearGradientMode.Horizontal) > >e.Graphics.FillRectangle(br, e.AffectedBounds) > >Else > >e.Graphics.FillRectangle(New SolidBrush(Color.White), 0, 0, >e.AffectedBounds.Width, e.AffectedBounds.Height) > >End If > > > >e.Graphics.DrawLine(New Pen(Color.White, 1), i_Margin - 1, 0, i_Margin - 1, >e.AffectedBounds.Height) > >e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), i_Margin - 2, >0, i_Margin - 2, e.AffectedBounds.Height) > > > >End Sub > ><DebuggerStepThrough()> Protected Overrides Sub OnRenderItemText(ByVal e As >System.Windows.Forms.ToolStripItemTextRenderEventArgs) > >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.OnRenderItemText(e) > >End Sub > > > ><DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderItemCheck(ByVal >sender As Object, ByVal e As >System.Windows.Forms.ToolStripItemImageRenderEventArgs) Handles >Me.RenderItemCheck > >If e.Item.Pressed Then > >ControlPaint.DrawMenuGlyph(e.Graphics, e.ImageRectangle, >MenuGlyph.Checkmark, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0, 0)) > >End If > >End Sub > >' renders menu over background > ><DebuggerStepThrough()> Private Sub >MoneyMenuRenderer_RenderMenuItemBackground(ByVal sender As Object, ByVal e >As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles >Me.RenderMenuItemBackground > >Dim i_Alpha As Integer = 255 > >If e.Item.Selected Or e.Item.Pressed Then > >DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Bounds.Width - 2, >e.Item.Bounds.Height - 2, 4) > >End If > >End Sub > >Private Sub GrayGradRenderer_RenderOverflowButtonBackground(ByVal sender As >Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) >Handles Me.RenderOverflowButtonBackground > >'Dim br As New Drawing2D.LinearGradientBrush(e.Item.Bounds, >Color.FromArgb(200, 200, 200), Color.FromArgb(170, 170, 170), >Drawing2D.LinearGradientMode.Vertical) > >' Dim brHover As New Drawing2D.LinearGradientBrush(e.Item.Bounds, >Color.FromArgb(200, 200, 250), Color.FromArgb(170, 170, 230), >Drawing2D.LinearGradientMode.Vertical) > >If Not e.Item.Selected = False Then > >DrawRoundedRectangle(e.Graphics, 1, 1, e.Item.Width - 2, e.Item.Height - 4, >5) > >End If > > > >If e.Item.Pressed = False Then > >e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >GraphicsUnit.Point), Brushes.DarkGray, e.Item.Width - 14, e.Item.Height - >11) > >If e.Item.Selected Then > >e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >GraphicsUnit.Point), Brushes.White, e.Item.Width - 15, e.Item.Height - 12) > >Else > >e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >GraphicsUnit.Point), Brushes.Black, e.Item.Width - 15, e.Item.Height - 12) > >End If > > > >Else > >e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >GraphicsUnit.Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 11) > >End If > >End Sub > ><DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderSeparator(ByVal >sender As Object, ByVal e As >System.Windows.Forms.ToolStripSeparatorRenderEventArgs) Handles >Me.RenderSeparator > >If e.Vertical = False Then > >e.Graphics.DrawLine(New Pen(Color.White, 1), i_Margin, 3, >e.Item.Bounds.Width, 3) > >e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), i_Margin, 2, >e.Item.Bounds.Width, 2) > >Else > >e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), 1, 2, 1, >e.Item.Bounds.Height - 4) > >e.Graphics.DrawLine(New Pen(Color.White, 1), 2, 2, 2, e.Item.Bounds.Height - >4) > >End If > >End Sub > >Private Sub GrayGradRenderer_RenderSplitButtonBackground(ByVal sender As >Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) >Handles Me.RenderSplitButtonBackground > >If e.Item.Selected = False Then > >e.Graphics.DrawString("u", New Font("Marlett", 8, FontStyle.Regular, >GraphicsUnit.Point), Brushes.Black, e.Item.Width - 14, e.Item.Height - 18) > >Else > >DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - 2, >5) > >e.Graphics.DrawString("u", New Font("Marlett", 8, FontStyle.Regular, >GraphicsUnit.Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 18) > >e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 3, 86, 205)), e.Item.Width - >13, e.Item.Height - 2, e.Item.Width - 13, e.Item.Height - 22) > >e.Graphics.DrawLine(New Pen(Color.FromArgb(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 > ><DebuggerStepThrough()> Private Sub >MoneyMenuRenderer_RenderToolStripBackground(ByVal sender As Object, ByVal e >As System.Windows.Forms.ToolStripRenderEventArgs) Handles >Me.RenderToolStripBackground > >If My.Computer.Screen.BitsPerPixel > 8 Then > >Dim sbDark As New SolidBrush(Color.FromArgb(145, 145, 145)) > >Dim sbLight As New SolidBrush(Color.FromArgb(255, 255, 255)) > >Dim br As New Drawing2D.LinearGradientBrush(e.AffectedBounds, >Color.FromArgb(236, 236, 236), Color.FromArgb(200, 200, 200), >Drawing2D.LinearGradientMode.Vertical) > >e.Graphics.FillRectangle(br, e.AffectedBounds) > >br.Dispose() > >Else > >e.Graphics.FillRectangle(Drawing.SystemBrushes.Control, e.AffectedBounds) > >End If > >End Sub > ><DebuggerStepThrough()> Private Sub >MoneyMenuRenderer_RenderToolStripBorder(ByVal sender As Object, ByVal e As >System.Windows.Forms.ToolStripRenderEventArgs) Handles >Me.RenderToolStripBorder > >If TypeOf e.ToolStrip Is ToolStripDropDownMenu Then > >e.Graphics.DrawRectangle(New Pen(Color.FromArgb(145, 145, 145), 1), 0, 0, >e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1) > >ElseIf TypeOf e.ToolStrip Is StatusStrip Then > >e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 255, 255), 1), 0, 0, >e.AffectedBounds.Width, 0) > >Else > >e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 255, 255), 1), 0, 0, >e.AffectedBounds.Width, 0) > >e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 0), 0, >e.AffectedBounds.Height - 1, e.AffectedBounds.Width, >e.AffectedBounds.Height - 1) > >End If > >End Sub > > > >Public Sub DrawRoundedRectangle(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.Screen.BitsPerPixel > 8 Then > >Dim i_Alpha As Integer = 255 > > > >objGraphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality > >objGraphics.CompositingMode = Drawing2D.CompositingMode.SourceOver > >objGraphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality > >'Dim g As Graphics > >Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, >m_intHeight) > >Dim ArcRect As New RectangleF(BaseRect.Location, New SizeF(m_diameter, >m_diameter)) > >Dim br As New Drawing2D.LinearGradientBrush(New Rectangle(m_intxAxis, >m_intyAxis, m_intWidth, m_intHeight), Color.FromArgb(i_Alpha, 40, 130, 234), >Color.FromArgb(i_Alpha, 1, 95, 228), Drawing2D.LinearGradientMode.Vertical) > >Dim p As New Drawing2D.GraphicsPath > >p.StartFigure() > >'top left Arc > >p.AddArc(ArcRect, 180, 90) > >p.AddLine(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 > >p.AddArc(ArcRect, 270, 90) > >p.AddLine(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 > >p.AddArc(ArcRect, 0, 90) > >p.AddLine(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 > >p.AddArc(ArcRect, 90, 90) > >p.AddLine( _ > >m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _ > >m_intxAxis, _ > >m_intyAxis + m_intHeight - CInt(m_diameter / 2)) > >p.CloseAllFigures() > >objGraphics.FillPath(br, p) > >' draw lines to add depth > >Dim pHlight As New Pen(Color.FromArgb(i_Alpha, 64, 144, 236)) > >Dim pHLightTop As New Pen(Color.FromArgb(i_Alpha, 33, 117, 232)) > >Dim pShad As New Pen(Color.FromArgb(i_Alpha, 3, 86, 205)) > >ArcRect = New RectangleF(BaseRect.Location, New SizeF(m_diameter, >m_diameter)) > >'top left Arc > >objGraphics.DrawArc(pHLightTop, ArcRect, 180, 90) > >objGraphics.DrawLine(pHLightTop, 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.DrawArc(pShad, ArcRect, 270, 90) > >objGraphics.DrawLine(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.DrawArc(pShad, ArcRect, 0, 90) > >objGraphics.DrawLine(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.DrawArc(pHLightTop, ArcRect, 90, 90) > >objGraphics.DrawLine(pHLightTop, _ > >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(BaseRect.Location, New SizeF(m_diameter, >m_diameter)) > >ArcRect.X = ArcRect.X + 1 > >ArcRect.Y = ArcRect.Y + 1 > >'top left Arc > >objGraphics.DrawArc(pHlight, ArcRect, 180, 90) > >objGraphics.DrawLine(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(BaseRect.Location, New SizeF(m_diameter, >m_diameter)) > >ArcRect.X = BaseRect.Left + 1 > >ArcRect.Y = m_intHeight + BaseRect.Height - m_diameter - 1 > >objGraphics.DrawArc(pHlight, ArcRect, 90, 90) > >objGraphics.DrawLine(pHlight, _ > >m_intxAxis + 1, m_intyAxis + CInt(m_diameter / 2), _ > >m_intxAxis + 1, _ > >m_intyAxis + m_intHeight - CInt(m_diameter / 2)) > >Else > >objGraphics.FillRectangle(Drawing.SystemBrushes.Highlight, New >RectangleF(m_intxAxis, m_intyAxis, m_intWidth, m_intHeight)) > >End If > >End Sub > > > >End Class > According to the Help file, I need to use the following, but I have no idea how to use it: Protected Overrides Sub OnRenderToolStripBorder(ByVal e As _ System.Windows.Forms.ToolStripRenderEventArgs) MyBase.OnRenderToolStripBorder(e) End Sub Anyone? Gene 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 Show quoteHide quote "gene kelley" <o***@by.me> wrote in message news:lne7f2pif28ri34h9i6nufqlodem6fp6ip@4ax.com... > On Mon, 28 Aug 2006 09:08:38 -0400, "Smokey Grindle" > <nospam@dontspamme.com> wrote: > >>Here's an example of a renderer I wrote (not optimized) >> >> >>Imports System.Drawing >> >>Imports System.Drawing.Drawing2D >> >>Imports System.Windows.Forms >> >>Public Class GrayGradRenderer >> >>Inherits ToolStripRenderer >> >>Dim sbDark As New SolidBrush(Color.FromArgb(145, 145, 145)) >> >>Dim sbLight As New SolidBrush(Color.FromArgb(255, 255, 255)) >> >>Dim i_Margin As Integer = -1 >> >><DebuggerStepThrough()> Private Sub MoneyMenuRenderer_RenderArrow(ByVal >>sender As Object, ByVal e As >>System.Windows.Forms.ToolStripArrowRenderEventArgs) Handles Me.RenderArrow >> >>Dim rect As Rectangle = e.ArrowRectangle >> >>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.FromArgb(0, 255, 254, 249), Color.FromArgb(0, 80, 80, 80)) >> >>Else >> >>ControlPaint.DrawMenuGlyph(e.Graphics, rect, MenuGlyph.Arrow, >>Color.FromArgb(0, 255, 254, 249), Color.FromArgb(0, 91, 91, 91)) >> >>End If >> >>End Sub >> >>Private Sub GrayGradRenderer_RenderButtonBackground(ByVal sender As >>Object, >>ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles >>Me.RenderButtonBackground >> >>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.FillRectangle(New SolidBrush(Color.FromArgb(40, >>Color.DarkBlue)), >>0, 0, e.Item.Width - 1, e.Item.Height - 2) >> >>e.Graphics.DrawRectangle(New Pen(Color.FromArgb(200, Color.DarkBlue)), 0, >>0, >>e.Item.Width - 1, e.Item.Height - 2) >> >>End If >> >>End If >> >>If e.Item.Selected = True Then >> >>DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - >>2, >>5) >> >>End If >> >>End Sub >> >>Private Sub GrayGradRenderer_RenderDropDownButtonBackground(ByVal sender >>As >>Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) >>Handles Me.RenderDropDownButtonBackground >> >>If e.Item.Selected = True Then >> >>DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - >>2, >>5) >> >>End If >> >>End Sub >> >>Private Sub GrayGradRenderer_RenderGrip(ByVal sender As Object, ByVal e As >>System.Windows.Forms.ToolStripGripRenderEventArgs) Handles Me.RenderGrip >> >>If e.GripStyle = ToolStripGripStyle.Visible Then >> >>If e.GripDisplayStyle = ToolStripGripDisplayStyle.Vertical Then >> >>If TypeOf e.ToolStrip Is MenuStrip Then >> >>ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 2, >>e.GripBounds.Width, e.GripBounds.Height - 2), Border3DStyle.RaisedInner) >> >>Else >> >>ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 2, >>e.GripBounds.Width, e.GripBounds.Height - 4), Border3DStyle.RaisedInner) >> >>End If >> >>Else >> >>If TypeOf e.ToolStrip Is MenuStrip Then >> >>ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(0, 0, >>e.GripBounds.Width - 3, e.GripBounds.Height), Border3DStyle.RaisedInner) >> >>Else >> >>ControlPaint.DrawBorder3D(e.Graphics, New Rectangle(2, 0, >>e.GripBounds.Width - 2, e.GripBounds.Height), Border3DStyle.RaisedInner) >> >>End If >> >>End If >> >>End If >> >>End Sub >> >><DebuggerStepThrough()> Private Sub >>MoneyMenuRenderer_RenderImageMargin(ByVal sender As Object, ByVal e As >>System.Windows.Forms.ToolStripRenderEventArgs) Handles >>Me.RenderImageMargin >> >>i_Margin = e.AffectedBounds.Width >> >>If My.Computer.Screen.BitsPerPixel > 8 Then >> >>Dim br As New Drawing2D.LinearGradientBrush(e.AffectedBounds, >>Color.FromArgb(255, 255, 255), Color.FromArgb(210, 210, 210), >>Drawing2D.LinearGradientMode.Horizontal) >> >>e.Graphics.FillRectangle(br, e.AffectedBounds) >> >>Else >> >>e.Graphics.FillRectangle(New SolidBrush(Color.White), 0, 0, >>e.AffectedBounds.Width, e.AffectedBounds.Height) >> >>End If >> >> >> >>e.Graphics.DrawLine(New Pen(Color.White, 1), i_Margin - 1, 0, i_Margin - >>1, >>e.AffectedBounds.Height) >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), i_Margin - >>2, >>0, i_Margin - 2, e.AffectedBounds.Height) >> >> >> >>End Sub >> >><DebuggerStepThrough()> Protected Overrides Sub OnRenderItemText(ByVal e >>As >>System.Windows.Forms.ToolStripItemTextRenderEventArgs) >> >>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.OnRenderItemText(e) >> >>End Sub >> >> >> >><DebuggerStepThrough()> Private Sub >>MoneyMenuRenderer_RenderItemCheck(ByVal >>sender As Object, ByVal e As >>System.Windows.Forms.ToolStripItemImageRenderEventArgs) Handles >>Me.RenderItemCheck >> >>If e.Item.Pressed Then >> >>ControlPaint.DrawMenuGlyph(e.Graphics, e.ImageRectangle, >>MenuGlyph.Checkmark, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0, 0)) >> >>End If >> >>End Sub >> >>' renders menu over background >> >><DebuggerStepThrough()> Private Sub >>MoneyMenuRenderer_RenderMenuItemBackground(ByVal sender As Object, ByVal e >>As System.Windows.Forms.ToolStripItemRenderEventArgs) Handles >>Me.RenderMenuItemBackground >> >>Dim i_Alpha As Integer = 255 >> >>If e.Item.Selected Or e.Item.Pressed Then >> >>DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Bounds.Width - 2, >>e.Item.Bounds.Height - 2, 4) >> >>End If >> >>End Sub >> >>Private Sub GrayGradRenderer_RenderOverflowButtonBackground(ByVal sender >>As >>Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) >>Handles Me.RenderOverflowButtonBackground >> >>'Dim br As New Drawing2D.LinearGradientBrush(e.Item.Bounds, >>Color.FromArgb(200, 200, 200), Color.FromArgb(170, 170, 170), >>Drawing2D.LinearGradientMode.Vertical) >> >>' Dim brHover As New Drawing2D.LinearGradientBrush(e.Item.Bounds, >>Color.FromArgb(200, 200, 250), Color.FromArgb(170, 170, 230), >>Drawing2D.LinearGradientMode.Vertical) >> >>If Not e.Item.Selected = False Then >> >>DrawRoundedRectangle(e.Graphics, 1, 1, e.Item.Width - 2, e.Item.Height - >>4, >>5) >> >>End If >> >> >> >>If e.Item.Pressed = False Then >> >>e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >>GraphicsUnit.Point), Brushes.DarkGray, e.Item.Width - 14, e.Item.Height - >>11) >> >>If e.Item.Selected Then >> >>e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >>GraphicsUnit.Point), Brushes.White, e.Item.Width - 15, e.Item.Height - 12) >> >>Else >> >>e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >>GraphicsUnit.Point), Brushes.Black, e.Item.Width - 15, e.Item.Height - 12) >> >>End If >> >> >> >>Else >> >>e.Graphics.DrawString("7", New Font("Marlett", 7, FontStyle.Regular, >>GraphicsUnit.Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 11) >> >>End If >> >>End Sub >> >><DebuggerStepThrough()> Private Sub >>MoneyMenuRenderer_RenderSeparator(ByVal >>sender As Object, ByVal e As >>System.Windows.Forms.ToolStripSeparatorRenderEventArgs) Handles >>Me.RenderSeparator >> >>If e.Vertical = False Then >> >>e.Graphics.DrawLine(New Pen(Color.White, 1), i_Margin, 3, >>e.Item.Bounds.Width, 3) >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), i_Margin, >>2, >>e.Item.Bounds.Width, 2) >> >>Else >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 1), 1, 2, 1, >>e.Item.Bounds.Height - 4) >> >>e.Graphics.DrawLine(New Pen(Color.White, 1), 2, 2, 2, >>e.Item.Bounds.Height - >>4) >> >>End If >> >>End Sub >> >>Private Sub GrayGradRenderer_RenderSplitButtonBackground(ByVal sender As >>Object, ByVal e As System.Windows.Forms.ToolStripItemRenderEventArgs) >>Handles Me.RenderSplitButtonBackground >> >>If e.Item.Selected = False Then >> >>e.Graphics.DrawString("u", New Font("Marlett", 8, FontStyle.Regular, >>GraphicsUnit.Point), Brushes.Black, e.Item.Width - 14, e.Item.Height - 18) >> >>Else >> >>DrawRoundedRectangle(e.Graphics, 0, 0, e.Item.Width - 2, e.Item.Height - >>2, >>5) >> >>e.Graphics.DrawString("u", New Font("Marlett", 8, FontStyle.Regular, >>GraphicsUnit.Point), Brushes.White, e.Item.Width - 14, e.Item.Height - 18) >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 3, 86, 205)), >>e.Item.Width - >>13, e.Item.Height - 2, e.Item.Width - 13, e.Item.Height - 22) >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(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 >> >><DebuggerStepThrough()> Private Sub >>MoneyMenuRenderer_RenderToolStripBackground(ByVal sender As Object, ByVal >>e >>As System.Windows.Forms.ToolStripRenderEventArgs) Handles >>Me.RenderToolStripBackground >> >>If My.Computer.Screen.BitsPerPixel > 8 Then >> >>Dim sbDark As New SolidBrush(Color.FromArgb(145, 145, 145)) >> >>Dim sbLight As New SolidBrush(Color.FromArgb(255, 255, 255)) >> >>Dim br As New Drawing2D.LinearGradientBrush(e.AffectedBounds, >>Color.FromArgb(236, 236, 236), Color.FromArgb(200, 200, 200), >>Drawing2D.LinearGradientMode.Vertical) >> >>e.Graphics.FillRectangle(br, e.AffectedBounds) >> >>br.Dispose() >> >>Else >> >>e.Graphics.FillRectangle(Drawing.SystemBrushes.Control, e.AffectedBounds) >> >>End If >> >>End Sub >> >><DebuggerStepThrough()> Private Sub >>MoneyMenuRenderer_RenderToolStripBorder(ByVal sender As Object, ByVal e As >>System.Windows.Forms.ToolStripRenderEventArgs) Handles >>Me.RenderToolStripBorder >> >>If TypeOf e.ToolStrip Is ToolStripDropDownMenu Then >> >>e.Graphics.DrawRectangle(New Pen(Color.FromArgb(145, 145, 145), 1), 0, 0, >>e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1) >> >>ElseIf TypeOf e.ToolStrip Is StatusStrip Then >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 255, 255), 1), 0, 0, >>e.AffectedBounds.Width, 0) >> >>Else >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(255, 255, 255), 1), 0, 0, >>e.AffectedBounds.Width, 0) >> >>e.Graphics.DrawLine(New Pen(Color.FromArgb(145, 145, 145), 0), 0, >>e.AffectedBounds.Height - 1, e.AffectedBounds.Width, >>e.AffectedBounds.Height - 1) >> >>End If >> >>End Sub >> >> >> >>Public Sub DrawRoundedRectangle(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.Screen.BitsPerPixel > 8 Then >> >>Dim i_Alpha As Integer = 255 >> >> >> >>objGraphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality >> >>objGraphics.CompositingMode = Drawing2D.CompositingMode.SourceOver >> >>objGraphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality >> >>'Dim g As Graphics >> >>Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, >>m_intHeight) >> >>Dim ArcRect As New RectangleF(BaseRect.Location, New SizeF(m_diameter, >>m_diameter)) >> >>Dim br As New Drawing2D.LinearGradientBrush(New Rectangle(m_intxAxis, >>m_intyAxis, m_intWidth, m_intHeight), Color.FromArgb(i_Alpha, 40, 130, >>234), >>Color.FromArgb(i_Alpha, 1, 95, 228), >>Drawing2D.LinearGradientMode.Vertical) >> >>Dim p As New Drawing2D.GraphicsPath >> >>p.StartFigure() >> >>'top left Arc >> >>p.AddArc(ArcRect, 180, 90) >> >>p.AddLine(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 >> >>p.AddArc(ArcRect, 270, 90) >> >>p.AddLine(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 >> >>p.AddArc(ArcRect, 0, 90) >> >>p.AddLine(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 >> >>p.AddArc(ArcRect, 90, 90) >> >>p.AddLine( _ >> >>m_intxAxis, m_intyAxis + CInt(m_diameter / 2), _ >> >>m_intxAxis, _ >> >>m_intyAxis + m_intHeight - CInt(m_diameter / 2)) >> >>p.CloseAllFigures() >> >>objGraphics.FillPath(br, p) >> >>' draw lines to add depth >> >>Dim pHlight As New Pen(Color.FromArgb(i_Alpha, 64, 144, 236)) >> >>Dim pHLightTop As New Pen(Color.FromArgb(i_Alpha, 33, 117, 232)) >> >>Dim pShad As New Pen(Color.FromArgb(i_Alpha, 3, 86, 205)) >> >>ArcRect = New RectangleF(BaseRect.Location, New SizeF(m_diameter, >>m_diameter)) >> >>'top left Arc >> >>objGraphics.DrawArc(pHLightTop, ArcRect, 180, 90) >> >>objGraphics.DrawLine(pHLightTop, 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.DrawArc(pShad, ArcRect, 270, 90) >> >>objGraphics.DrawLine(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.DrawArc(pShad, ArcRect, 0, 90) >> >>objGraphics.DrawLine(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.DrawArc(pHLightTop, ArcRect, 90, 90) >> >>objGraphics.DrawLine(pHLightTop, _ >> >>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(BaseRect.Location, New SizeF(m_diameter, >>m_diameter)) >> >>ArcRect.X = ArcRect.X + 1 >> >>ArcRect.Y = ArcRect.Y + 1 >> >>'top left Arc >> >>objGraphics.DrawArc(pHlight, ArcRect, 180, 90) >> >>objGraphics.DrawLine(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(BaseRect.Location, New SizeF(m_diameter, >>m_diameter)) >> >>ArcRect.X = BaseRect.Left + 1 >> >>ArcRect.Y = m_intHeight + BaseRect.Height - m_diameter - 1 >> >>objGraphics.DrawArc(pHlight, ArcRect, 90, 90) >> >>objGraphics.DrawLine(pHlight, _ >> >>m_intxAxis + 1, m_intyAxis + CInt(m_diameter / 2), _ >> >>m_intxAxis + 1, _ >> >>m_intyAxis + m_intHeight - CInt(m_diameter / 2)) >> >>Else >> >>objGraphics.FillRectangle(Drawing.SystemBrushes.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 OnRenderToolStripBorder(ByVal e As _ > System.Windows.Forms.ToolStripRenderEventArgs) > MyBase.OnRenderToolStripBorder(e) > > End Sub > > Anyone? > > Gene On Tue, 29 Aug 2006 08:34:39 -0400, "Smokey Grindle" <nospam@dontspamme.com> wrote: Well, I thank you for your time and reply. But as I previously noted, I don't understand your>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 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 |
|||||||||||||||||||||||