473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linear gradient background does not repaint correctly.

My current code paints a rectangular area at the top (under the menu and
tool strip) and bottom (top of the status strip) of the main form with a
linear gradient. The problem is that when the form is resized or maximized
for that matter, the form still displays the last areas that were painted
with gradient. Basically the form does not erase the last graphics that
were painted to the form and just paints over it with the new. My code is
as follows in the form paint event.

----------------------

Private Sub frmMain_Paint(B yVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Me.Paint

'declare rectangle dimensions for areas to be painted. Areas will be 64
pixels high.
Dim rectTop As New Rectangle(0, (mainMenu.Heigh t + tsSearchBar.Hei ght),
Me.Width, 64)
Dim rectBottom As New Rectangle(0, (Me.Height - (64 +
ssMessages.Heig ht)), Me.Width, 64)

'declare brushes for linear gradient.
Dim brushTop As New LinearGradientB rush(rectTop, Color.SlateGray ,
Color.Transpare nt, LinearGradientM ode.Vertical)
Dim brushBottom As New LinearGradientB rush(rectBottom ,
Color.Transpare nt, Color.DarkGray, LinearGradientM ode.Vertical)

'paint areas with gradients upon form refreshes and repaints
e.Graphics.Fill Rectangle(brush Top, rectTop)
e.Graphics.Fill Rectangle(brush Bottom, rectBottom)

brushTop.Dispos e()
brushBottom.Dis pose()

End Sub

----------------------

If anyone can help me solve why this is happening, I'd be much appreciative.
I'm pretty sure that the problem is something simple that I just can't see.
Thanks in advanced.

Mar 4 '08 #1
1 1863
"Bryon" <re**********@g mail.comschrieb
My current code paints a rectangular area at the top (under the menu
and tool strip) and bottom (top of the status strip) of the main
form with a linear gradient. The problem is that when the form is
resized or maximized for that matter, the form still displays the
last areas that were painted with gradient. Basically the form does
not erase the last graphics that were painted to the form and just
paints over it with the new. My code is as follows in the form
paint event.
[...]
Only revealed areas are repainted. Try

Me.SetStyle(Con trolStyles.Resi zeRedraw, True)

in the Form's constructor. Anywhere else, additionally call
Me.Updatestyles .
Armin

Mar 4 '08 #2

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

Similar topics

5
2435
by: Woody Splawn | last post by:
I have a webform where I would like to have the background color for the webform be a gradient in blue. How do I do this? What is the easiest way? What is the way most used by other developers? Do you draw it with code or attach a .gif file as a background or what? Does one way or the other have an effect on speed? Thank You
0
4452
by: Don | last post by:
I'm making a custom control that has a multiline textbox on it. I want to make the textbox have a gradient background. On my custom control's Paint event I call a routine that draws a gradient on the textbox's background, but the gradient starts appearing at the bottom of the textbox after the last line of text. It's almost as if VB draws the gradient on the entire textbox, then blanks out the part of the textbox that actually displays...
2
7587
by: Dean Slindee | last post by:
It appears that I have two routines that don't play well together! First routine: a form's background is shaded with a gradient color. Second routine: then, the background of all labels on the form are made transparent. What results is the label's backcolor appearing as blocks of 'control' colored background. Setting the label's backcolor to color.transparent does not make it transparent (evidently the text is repainted with a...
1
6298
by: Robert W. | last post by:
In my WinForms app I've long been able to create a linear gradient effect by just intercepting the PaintEventHandler event. But I'd now like to create an inherited user control, specifically of a panel. I thought I was on the right track and did achieve the effect ... until I started putting some controls on the panel. Then I got an "Invalid parameter" error but don't understand what it's referring to. Based on examples I've found,...
0
1042
by: Dan Baumbach | last post by:
I'm working on a toolbar for IE. I have everything working well but I'm unable to get the toolbar to have the same gradient background under XP that other toolbars on IE have. To start with, I don't see any documentation to get the colors for the gradient on IE. Is there one? My toolbar has the TBSTYLE_TRANSPARENT but it uses the defined background color brush of the parent window as its background rather that really being truely...
4
5889
by: Jon Slaughter | last post by:
I'm drawing a linear gradient and its very "banded". The colors are far enough part that it should be plenty smooth enough but I always get the same number of bands regardless. I've tried to set g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality;
1
1660
by: madladuk | last post by:
Hi all. Does anyone have any example of how to do a gradient background whilst moving over graphics and text like the Microsoft web site. On the MS site when you select an area a window popup and as you hover over the sections it fill in a nice gradient background, any assistance? Thanks
6
6170
by: moondaddy | last post by:
I want to fill the entire background of a page with a gradient. As a test, I first filled with a solid color like this: <body style="background-color: #ccffff;" > and the entire page was this color. next I replaced that with a gradient style like this: <body style="filter:
9
8145
by: Eric Lindsay | last post by:
How do you provide a consistent gradient fill as a background in a liquid layout? If I make a gradient fill image say 1000 pixels wide (and repeat it down the page) to suit a typical computer display, then only a small portion of the gradient will show if the viewpoint is a smaller PDA or phone display. On the other hand, if viewed full screen on a 1920 pixel wide display, I would run out of gradient on one or both sides of the page....
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8957
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.