Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
Graphics/GDI+
drawing a triangle on a toolbarbutton
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="lottoman2000" data-source="post: 6148" data-attributes="member: 2259"><p>I was able to draw a triangle on a toolbarbutton to simulate a drop </p><p>down button without having the extra button beside my dropdownbutton. </p><p>I have overrrided the onpaint event for the form. that only problem is when I click on the button ( a context menu shows up) the triangle disappears. I also overrided mouse up, down, hover, leave events and made them to call me.invalidate. </p><p></p><p></p><p>The button style is: PushButton</p><p></p><p></p><p></p><p>Here is my code </p><p><span style="font-size: 10px"><span style="color: #0000ff">Protected</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Overrides</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Sub</span></span><span style="font-size: 10px"> OnPaint(</span><span style="font-size: 10px"><span style="color: #0000ff">ByVal</span></span><span style="font-size: 10px"> e </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> System.Windows.Forms.PaintEventArgs)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> g </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> Graphics </span></p><p><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> tbb </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> ToolBarButton</span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> brush </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> SolidBrush = </span><span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> SolidBrush(Color.Black)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">Dim</span></span><span style="font-size: 10px"> Points(2) </span><span style="font-size: 10px"><span style="color: #0000ff">As</span></span><span style="font-size: 10px"> Point</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">Points(0) = </span><span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> Point(tbbArchive.Rectangle.Right - 10, tbbArchive.Rectangle.Bottom / 2)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">Points(1) = </span><span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> Point(tbbArchive.Rectangle.Right - 7, (tbbArchive.Rectangle.Bottom / 2) - 3)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">Points(2) = </span><span style="font-size: 10px"><span style="color: #0000ff">New</span></span><span style="font-size: 10px"> Point(tbbArchive.Rectangle.Right - 13, (tbbArchive.Rectangle.Bottom / 2) - 3)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">g = </span><span style="font-size: 10px"><span style="color: #0000ff">Me</span></span><span style="font-size: 10px">.ToolBar1.CreateGraphics</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px">g.FillPolygon(brush, Points)</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span></p><p><span style="font-size: 10px"><span style="color: #008000"></span></span><span style="font-size: 10px">g.Dispose()</span></p><p><span style="font-size: 10px"></span></p><p><span style="font-size: 10px"></span><span style="font-size: 10px"><span style="color: #0000ff">End</span></span> <span style="font-size: 10px"><span style="color: #0000ff">Sub</span></span></p><p></p><p><span style="font-size: 10px"><span style="color: #0000ff"> </span></span></p><p><span style="font-size: 10px"><span style="color: #0000ff"></span></span>Any help is appreciated.</p></blockquote><p></p>
[QUOTE="lottoman2000, post: 6148, member: 2259"] I was able to draw a triangle on a toolbarbutton to simulate a drop down button without having the extra button beside my dropdownbutton. I have overrrided the onpaint event for the form. that only problem is when I click on the button ( a context menu shows up) the triangle disappears. I also overrided mouse up, down, hover, leave events and made them to call me.invalidate. The button style is: PushButton Here is my code [size=2][color=#0000ff]Protected[/color][/size][size=2] [/size][size=2][color=#0000ff]Overrides[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] OnPaint([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Windows.Forms.PaintEventArgs) [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] g [/size][size=2][color=#0000ff]As[/color][/size][size=2] Graphics [/size] [size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] tbb [/size][size=2][color=#0000ff]As[/color][/size][size=2] ToolBarButton [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] brush [/size][size=2][color=#0000ff]As[/color][/size][size=2] SolidBrush = [/size][size=2][color=#0000ff]New[/color][/size][size=2] SolidBrush(Color.Black) [/size][size=2][color=#0000ff]Dim[/color][/size][size=2] Points(2) [/size][size=2][color=#0000ff]As[/color][/size][size=2] Point Points(0) = [/size][size=2][color=#0000ff]New[/color][/size][size=2] Point(tbbArchive.Rectangle.Right - 10, tbbArchive.Rectangle.Bottom / 2) Points(1) = [/size][size=2][color=#0000ff]New[/color][/size][size=2] Point(tbbArchive.Rectangle.Right - 7, (tbbArchive.Rectangle.Bottom / 2) - 3) Points(2) = [/size][size=2][color=#0000ff]New[/color][/size][size=2] Point(tbbArchive.Rectangle.Right - 13, (tbbArchive.Rectangle.Bottom / 2) - 3) g = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].ToolBar1.CreateGraphics g.FillPolygon(brush, Points) [/size][size=2][color=#008000] [/color][/size][size=2]g.Dispose() [/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size] [size=2][color=#0000ff][/color][/size] [size=2][color=#0000ff] [/color][/size]Any help is appreciated. [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
Graphics/GDI+
drawing a triangle on a toolbarbutton
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom