problem with drawing and mdiforms
-
Hi, I have created a form which I need to draw a triangle in it. I found a block of code in internet like this:
Dim Graph As Graphics
Dim Ps() As Point
Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
ReDim Ps(2)
Ps(0) = New Point(150, 25)
Ps(1) = New Point(150, 125)
Ps(2) = New Point(350, 125)
Graph.DrawPolygon(pen:=New Pen(Color.Black, Width:=1), points:=Ps)it is in paint event of form, it works when I load it by itself, but when I try to load it in a mdiParent form the triangle doesn't show up, can any one help me? also I'm new to vb.net so if there is a better way to draw things please tell me Thanks in advance
-
Hi, I have created a form which I need to draw a triangle in it. I found a block of code in internet like this:
Dim Graph As Graphics
Dim Ps() As Point
Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
ReDim Ps(2)
Ps(0) = New Point(150, 25)
Ps(1) = New Point(150, 125)
Ps(2) = New Point(350, 125)
Graph.DrawPolygon(pen:=New Pen(Color.Black, Width:=1), points:=Ps)it is in paint event of form, it works when I load it by itself, but when I try to load it in a mdiParent form the triangle doesn't show up, can any one help me? also I'm new to vb.net so if there is a better way to draw things please tell me Thanks in advance
-
Actually I changed
Graph = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)
to
Graph = Graphics.FromHwnd(hwnd:=Me.Handle)
and it works I just need to know what ' := ' does like
Width := 1
":=" sets parameters being passed to a method by name instead of relying on the order of parameters. You REALLY should be doing your form painting in its Paint event instead of creating your own Graphics object.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...