473,758 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom Rounded Rectangle Usercontrol does not redraw controls on it. Please help.

I made a custom runded rectangle usercontrol. I used a function i found on
the internet. the function works fine(see "GetRoundRe ct" below).
I use the fullowing code to make my usercontrol rounded....
*************** *************** *************** ********
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim x1 As Integer = 0
Dim x2 As Integer = Me.ClientSize.W idth
Dim iHeight As Int32 = Me.Height
Dim iWidth As Int32 = Me.Width
If bCurveSided Then
Dim eg As New ExtendedGraphic s(e.Graphics)
Dim rf As New RectangleF()
With rf
.Width = iWidth
.Height = iHeight
.X = 1
.Y = 0
End With
Me.Region = New Region(eg.GetRo undedRect(rf, 5))
End If
End Sub

Public Function GetRoundedRect( ByVal baseRect As RectangleF, ByVal
radius As Single) As GraphicsPath
If radius <= 0 Then
Dim mPath As GraphicsPath = New GraphicsPath()
mPath.AddRectan gle(baseRect)
mPath.CloseFigu re()
Return mPath
End If
If radius >= (Math.Min(baseR ect.Width, baseRect.Height )) / 2 Then
Return GetCapsule(base Rect)
End If
Dim diameter As Single = radius * 2
Dim sizeF As SizeF = New SizeF(diameter, diameter)
Dim arc As RectangleF = New RectangleF(base Rect.Location, sizeF)
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arc , 180, 90)
arc.X = baseRect.Right - diameter
path.AddArc(arc , 270, 90)
arc.Y = baseRect.Bottom - diameter
path.AddArc(arc , 0, 90)
arc.X = baseRect.Left
path.AddArc(arc , 90, 90)
path.CloseFigur e()
Return path
End Function
*************** *************** ********

My question is...why is it when i use my custom rounded usercontrol and put
some textboxes on it. The controls on my usercontrol does not redraw
properly? i have to manualy tell my usercontrol to repaint itself. like....
Me.Refresh. Plrease help!
Jul 21 '05 #1
2 2201
What are ExtendedGraphic s() and GetCapsule()?

Why not:
Me.Region = New Region(GetRound edRect(rf, 5))

and what happens if you add the following to your OnPaint method?
MyBase.OnPaint( e)

I would recommend setting the region in the usercontrols OnResize method
rather than in the OnPaint method.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jose Michael Meo R. Barrido" <mi**@rdmsinc.n et> wrote in message
news:e4******** ********@TK2MSF TNGP11.phx.gbl. ..
I made a custom runded rectangle usercontrol. I used a function i found on
the internet. the function works fine(see "GetRoundRe ct" below).
I use the fullowing code to make my usercontrol rounded....
*************** *************** *************** ********
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim x1 As Integer = 0
Dim x2 As Integer = Me.ClientSize.W idth
Dim iHeight As Int32 = Me.Height
Dim iWidth As Int32 = Me.Width
If bCurveSided Then
Dim eg As New ExtendedGraphic s(e.Graphics)
Dim rf As New RectangleF()
With rf
.Width = iWidth
.Height = iHeight
.X = 1
.Y = 0
End With
Me.Region = New Region(eg.GetRo undedRect(rf, 5))
End If
End Sub

Public Function GetRoundedRect( ByVal baseRect As RectangleF, ByVal
radius As Single) As GraphicsPath
If radius <= 0 Then
Dim mPath As GraphicsPath = New GraphicsPath()
mPath.AddRectan gle(baseRect)
mPath.CloseFigu re()
Return mPath
End If
If radius >= (Math.Min(baseR ect.Width, baseRect.Height )) / 2 Then
Return GetCapsule(base Rect)
End If
Dim diameter As Single = radius * 2
Dim sizeF As SizeF = New SizeF(diameter, diameter)
Dim arc As RectangleF = New RectangleF(base Rect.Location, sizeF)
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arc , 180, 90)
arc.X = baseRect.Right - diameter
path.AddArc(arc , 270, 90)
arc.Y = baseRect.Bottom - diameter
path.AddArc(arc , 0, 90)
arc.X = baseRect.Left
path.AddArc(arc , 90, 90)
path.CloseFigur e()
Return path
End Function
*************** *************** ********

My question is...why is it when i use my custom rounded usercontrol and
put some textboxes on it. The controls on my usercontrol does not redraw
properly? i have to manualy tell my usercontrol to repaint itself.
like.... Me.Refresh. Plrease help!

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 26/11/2004
Jul 21 '05 #2
thanks for your advice. i'm gonna try that :-)

"Mick Doherty"
<EX***********@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]> wrote in
message news:O2******** ********@TK2MSF TNGP10.phx.gbl. ..
What are ExtendedGraphic s() and GetCapsule()?

Why not:
Me.Region = New Region(GetRound edRect(rf, 5))

and what happens if you add the following to your OnPaint method?
MyBase.OnPaint( e)

I would recommend setting the region in the usercontrols OnResize method
rather than in the OnPaint method.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jose Michael Meo R. Barrido" <mi**@rdmsinc.n et> wrote in message
news:e4******** ********@TK2MSF TNGP11.phx.gbl. ..
I made a custom runded rectangle usercontrol. I used a function i found
on the internet. the function works fine(see "GetRoundRe ct" below).
I use the fullowing code to make my usercontrol rounded....
*************** *************** *************** ********
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim x1 As Integer = 0
Dim x2 As Integer = Me.ClientSize.W idth
Dim iHeight As Int32 = Me.Height
Dim iWidth As Int32 = Me.Width
If bCurveSided Then
Dim eg As New ExtendedGraphic s(e.Graphics)
Dim rf As New RectangleF()
With rf
.Width = iWidth
.Height = iHeight
.X = 1
.Y = 0
End With
Me.Region = New Region(eg.GetRo undedRect(rf, 5))
End If
End Sub

Public Function GetRoundedRect( ByVal baseRect As RectangleF, ByVal
radius As Single) As GraphicsPath
If radius <= 0 Then
Dim mPath As GraphicsPath = New GraphicsPath()
mPath.AddRectan gle(baseRect)
mPath.CloseFigu re()
Return mPath
End If
If radius >= (Math.Min(baseR ect.Width, baseRect.Height )) / 2 Then
Return GetCapsule(base Rect)
End If
Dim diameter As Single = radius * 2
Dim sizeF As SizeF = New SizeF(diameter, diameter)
Dim arc As RectangleF = New RectangleF(base Rect.Location, sizeF)
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arc , 180, 90)
arc.X = baseRect.Right - diameter
path.AddArc(arc , 270, 90)
arc.Y = baseRect.Bottom - diameter
path.AddArc(arc , 0, 90)
arc.X = baseRect.Left
path.AddArc(arc , 90, 90)
path.CloseFigur e()
Return path
End Function
*************** *************** ********

My question is...why is it when i use my custom rounded usercontrol and
put some textboxes on it. The controls on my usercontrol does not redraw
properly? i have to manualy tell my usercontrol to repaint itself.
like.... Me.Refresh. Plrease help!

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 26/11/2004

Jul 21 '05 #3

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

Similar topics

1
3598
by: jimfortune | last post by:
The following Access VBA function creates a string that can be used in a pdf stream to draw or fill a rectangle of a given color with rounded corners: 'Begin code----------- Public Function DrawRoundedRectangle(dblX As Double, dblY As Double, _ dblR As Double, dblW As Double, dblH As Double, _ dblThickness As Double, dblLineR As Double, dblLineG _ As Double, dblLineB As Double, boolFill As Boolean, dblFillR _ As Double, dblFillG As...
3
8005
by: Daisy | last post by:
I've started writing a listview, which currently draws my list to a pane, and onclick, works out which row you've clicked on, from the co-ordinates of the mouse, sets the .Selected property to the index of the item in my list, and onpaint, I draw this with a selected box over it. It's dawned on me, that this "list", being just text written to the pane, won't be able to recieve focus, and therefore, there's probably a better way of doing...
4
5676
by: | last post by:
Please, help. I created my contol, ButtonX, which subclasses System.Forms.Windows.Button class. I am doing my own paiting, by overriding OnPaint and OnPaintBackground (without calling base class's OnPaint & OnPaintBackground). My button has a shape of rectangle with rounded corners and is filled with gradient brush, where user specifies the gradient colors. The dilema I have now is how to paint the button when it's disabled (Enabled =...
8
3193
by: Tinus | last post by:
Hello all, I've create a custom control (UserControl) and have a custom Item Collection. The control is a custom calendar which is draw using the Graphics Rectangle etc. functions. It is drawn when the control is painted or resized. When the control is drawn it draws also the items found in the collection. So far so good.... I have 3 questions which I'm unable to find a solution
2
1968
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol rounded.... ***************************************************** Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim x1 As Integer = 0 Dim x2 As Integer = Me.ClientSize.Width Dim iHeight As Int32 = Me.Height Dim...
2
7856
by: Dino Buljubasic | last post by:
Hi, I have several panels that holds bunch of controls with information on my forms. My form has background image property set to an image that has borders defining where my panel comes and that border is rounded so when I set my panels border stile to none, the panel appear to have the rounded border (that comes from the forms background image. This looks really nice, but the problem is that my forms can not be resizable then, since...
15
6521
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
6
10839
by: moondaddy | last post by:
I need to be able to make polygons with rounded corners. This will be to draw group outlines around shapes in a diagramming tool in wpf. all angles in the polygon will be 90 degrees, but somehow I wanted to make the corners a bit rounded (otherwise it will look like an old legacy app). Is this possible in wpf? The reason I wanted to use a polygon was because I will bind an adorner to each point so the user can drag the corners around to...
4
2490
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried unsuccessfully in creating the whole pane as a user control and have succeeded in adding the pane and then dynamically adding the content which is a user control to the pane, dynamically within the page. However I would like to have a single pane...
0
9492
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
10076
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...
1
9885
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9740
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8744
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...
1
7287
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6564
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
5175
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...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.