473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Painting a Toolbars' background

I'm trying to gradient fill my toolbar background. I've derived a new
toolbar from the existing one, calling it GradientToolbar, I've set it's
style to userpaint and I've overridden the OnPaintBackground method and
OnPaint methods. Now, I've got a nice shiney background, but no toolbar
buttons (or anything come to think of it - none of the buttons are drawn)!
What am I missing here?
In the parent container "New" event, after InitialiseComponent, I write this
to set the toolbar style:
Dim theMethod As System.Reflection.MethodInfo =
ViewToolbar.GetType().GetMethod( _"SetStyle", _

Reflection.BindingFlags.NonPublic Or _

Reflection.BindingFlags.Instance)

theMethod.Invoke(ViewToolbar, New Object() { _
ControlStyles.AllPaintingInWmPaint
Or _
ControlStyles.DoubleBuffer Or _
ControlStyles.UserPaint, _
True})
........ and the toolbar class:
Imports System.Drawing.Drawing2D

Public Class GradientToolbar
Inherits ToolBar

Protected Overrides Sub OnPaintBackground(ByVal pevent As
System.Windows.Forms.PaintEventArgs)

Dim BackgroundColour As Brush

BackgroundColour = New LinearGradientBrush( _
New Point(0,
0), _
New Point(0,
Me.Height), _
Color.FromArgb(255,
180, 180, 180), _
Color.FromArgb(255,
100, 100, 100))

pevent.Graphics.FillRectangle(BackgroundColour,
pevent.ClipRectangle)

BackgroundColour.Dispose()

End Sub

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)

MyBase.OnPaint(e)

End Sub

End Class
Nov 21 '05 #1
0 806

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bill K | last post by:
I am developing a winforms project in vb.net. I have several forms that have a number of controls, grids, etc. When I load these as MDI child forms, they load slowly AND they paint/repaint on the...
3
by: cefrancke | last post by:
The only reason I ask is that no one has made this subject clear or given a definitive answer. What I would like to do is, after turning off all the menus/tbars/etc using the startup options. ...
4
by: Tim Bücker | last post by:
Hello. I want to paint some geometric shapes on the graphic context from a picture box. This picture box has dock style set to fill and is filling out the whole form. The form is maximized. This...
2
by: Robert Misiak | last post by:
Hi everyone- I've done a lot of searching around on the web and I'm sure the answer to this question is no, but I'll ask anyway. Is it possible to create an inherited MonthCalendar control and...
1
by: DigitalMythic | last post by:
Just to set the scene, I have a listbox in an application which im working on. The List box will have owner drawn items in it when it has items. To start with the listbox is empty. What Im...
2
by: jmdolinger | last post by:
Hi all, Sorry if this has been covered before, but is there anyway that one could remove menubars/toolbars from an existing browser window, without having to popup a new window using...
15
by: Neil | last post by:
So, I tried to copy a toolbar. I have a custom menu bar for a form. Tried to copy it so that I could modify the copy and use it with another form. With no direct way to copy it, I made a copy of...
4
by: Marina Levit | last post by:
I am trying to do some processing on a background thread while keeping the UI painting. However, this is a generic server side call routine - and it needs to block until the server side call...
1
by: desturrr | last post by:
I have been searching all over the sites, but i couldn't manage to get button or any other component on a image panel. There are some codes that says while painting the picture you can show...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.