1 Attachment(s)
[Resolved] - problem while drawing rectangles
Hi there,
I wanna draw rectangles on a picture box, as we do in paintBrush Application. I m able to draw rectangle but only filled one not an empty one, how to do this.
for eg. i m attaching an image showing two type of rectangles that i wanna draw.
What, if i wanna draw same kinda rounded rectangle and circles.
plz help.
thanx in advance
harry
Re: problem while drawing rectangles
Empty Box
VB Code:
Picture1.Line(10, 10)-Step(100, 30), RGB(0, 0, 0), B
Filled Box
VB Code:
Picture1.Line(10, 10)-Step(100, 30), RGB(0, 0, 0), BF
Circle
VB Code:
Picture1.Circle(50, 50), 10, RGB(0, 0, 0)
Rounded Rectangle (not filled)
VB Code:
'// Uhm...
Private Function Radians(ByVal deg as single) As single
Dim Pi as single
Pi = 3.14159265358979
Radians = deg * (Pi / 180)
End Funtion
Private Sub Form_Load()
Dim rWidth as integer
Dim rHeight as integer
Dim rCorner as integer
Dim rX as integer
Dim rY as integer
Dim lC as long
rWidth = 100 '// width of the rectangle
rHeight = 50 '// height of the rectangle
rCorner = 5 '// corner radius
rX = 10 '// left position of rectangle
rY = 10 '// top position of rectangle
lC = RGB(126, 0, 0) '// rectangle color
'// top left corner
Picture1.Circle (rX + rCorner, rY + rCorner), rCorner, lC, Radians(90), Radians(180)
'// top right corner
Picture1.Circle (rX + rWidth - rCorner, rY + rCorner), rCorner, lC, Radians(0), Radians(90)
'// bottom left corner
Picture1.Circle (rX + rCorner, rY + rHeight - rCorner), rCorner, lC, Radians(180), Radians(270)
'// bottom right corner
Picture1.Circle (rX + rWidth - rCorner, rY + rHeight - rCorner), rCorner, lC, Radians(270), Radians(360)
'// top line
Picture1.Line (rX + rCorner, rY)-Step(rWidth - (rCorner * 2), 0), lC
'// bottom line
Picture1.Line (rX + rCorner, rY + rHeight)-Step(rWidth - (rCorner * 2), 0), lC
'// left line
Picture1.Line (rX, rY + rCorner)-Step(0, rHeight - (rCorner * 2)), lC
'// right line
Picture1.Line (rX + rWidth, rY + rCorner)-Step(0, rHeight - (rCorner * 2)), lC
End Sub
Re: problem while drawing rectangles
I tried this method, it give me black colour inside the rectangle. but i want it to be transparent i.e. only outline (only 4 lines)
plz help
harry
Re: problem while drawing rectangles
It gives you filled rect because the Picturebox fillstyle property is set so SOLID (0)
Change to transparent:
You also can do it at design time.
Re: problem while drawing rectangles
thanx alot friends,
now i'm using gdi APIs for making all the stuffs.
plz tell me 1 thing, if i'm drawing a filled RoundRectangle / ellipse / rectangle then how to allow the user to select his own colour.
plz reply soon
thanx in advance
harry
Re: problem while drawing rectangles
If you're using the GDI, there should be a param that specifies the color. Just have the user choose a color, and pass it in as this param. It will be the CreateSolidBrush that's got this param (I think. Too much VB.NET GDI+)
Re: problem while drawing rectangles
thanx alot friends,
ur replies worked out for me.
thanx alot