473,408 Members | 1,866 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,408 software developers and data experts.

Rectangles...I must be missing something. (Originally posted in .framework.drawing)

YYZ
Sorry for the multipost, but no one was responding in the other thread.
If any solution is forthcoming, I will return to the original thread
and post it there as well.

I've created a usercontrol and I'm trying to emulate the look of a mac
effect (just for showing some options to my boss) by using 2 gradient
rectangles. I'm having a LOT of trouble doing this, however, because I
keep getting a 1 or 2 pixel line showing up. Can someone look this
over and tell me what I might be doing wrong?

Usercontrol: the only code I have in here that is non-standard is this
(VB.Net 2003):

Private Sub ucHeader_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint
Dim c1 As System.Drawing.Color
Dim iMid As Integer

iMid = Me.Height / 2

Dim mBrush As New System.Drawing.Drawing2D.LinearGradientBrush( _
New System.drawing.Rectangle(0, 0, Me.Width, iMid), _
c1.FromArgb(255, 187, 215, 241), _
c1.FromArgb(255, 151, 197, 240), 90, False)
e.Graphics.FillRectangle(mBrush, New System.Drawing.Rectangle( _
0, 0, Me.Width, iMid))
Dim mBrush2 As New System.Drawing.Drawing2D.LinearGradientBrush( _
New System.drawing.Rectangle(0, 0, Me.Width, iMid), _
c1.FromArgb(255, 122, 182, 238), _
c1.FromArgb(255, 198, 253, 255), 90, False)
e.Graphics.FillRectangle(mBrush2, 0, iMid, Me.Width, iMid)
End Sub

I then have a main form that I just dropped my user control onto -- I
made the height 267 to test this...

If you run the example, it will show a light light blue line in the
middle -- this should NOT be there. I have experimented with all sorts
of variations for iMid -- adding 2 to it sometimes, subtracting 2, etc.
I can't get this to work.

I guess my first question is, when creating a brush, the rectangle that
I define, should that be 1 based or 0 based? Should I make the brush
as wide as the usercontrol? If I want to draw the usercontrol in 2
segments, like I have done, should I make the brush 1/2 the size? I
thought so...but now I'm way confused.

For the 2nd rectangle (the bottom half of the usercontrol), when
creating the brush, should the brush's y param be the middle of the
usercontrol, or should it be 0 or 1? The rest of the questions
apply...

I did read the documentation about how the FillRectangle method draws
the INTERIOR of the rectangle, and I thought that might be my problem,
but still couldn't make it work when creating my rectangle a few pixels
larger in both dimensions...

Any advice at all is greatly appreciated.

Matt

Nov 21 '05 #1
1 1677
YYZ
I found an answer of sorts in another group. There evidently is a bug
in the LinearGradientBrush object/method/whatever. I had to make the
rectangle of the brush one larger than the rectangle that I was
painting, because the brush wraps even when it doesn't need to.

Matt

Nov 21 '05 #2

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

Similar topics

7
by: Chris | last post by:
I'm using eight links listed horizontally as a menu on my site. I'm using font-variant:small-caps and they are padded so that they mimic buttons. My gripe is with the way IE handles the focus...
2
by: MS | last post by:
Is there a way of srawing rectangles on a form in code? Using the line method on a report works fine. Is there an eqivalent for a form? Cheers!
0
by: Jigar.Patel | last post by:
I have simple remoting server exposing following simple method. When I try to add webreference to this server in another project, it gives me following error: Custom tool error: Unable to import...
3
by: =?Utf-8?B?U3RldmVU?= | last post by:
I want to create tabs in the TabControl that are aligned on either the right or left side, but no text shows when doing this. Is there an issue here or a work around. Text for tabs on top or...
0
by: bienvankhat | last post by:
Hi, i want to simulate a led matrix panel. I create a 8x8 dot led matrix by drawing 64 rectangles in a small area. The panel is made up by 100 matrices. But the drawing process is very slow, it take...
7
by: ddecoste | last post by:
I have a need to add a visual representation to some data in Access. I need to draw a matix of squares inside another square. I have all the data that I need in a record in Access. The data...
11
by: Peter Webb | last post by:
I previously asked about two problems I had with some graphics - the first was that when I drew animation to a picturebox it wouldn't display when the Form loaded. It was suggested to me by...
6
by: Miro | last post by:
I can run an exe ( and its install ) i have created on my machine. The exe has a button that populates a dataset and then shoots it to a crystal report. But... Installing the setup.exe on my...
4
by: Miro | last post by:
<i have also added this reply to the other newsgroup - now that I have realizd ( and assuming ) it is not a localized error directly to vb.> I have found this link on the website:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.