[VB2010] - can i use Graphics in a class?

  • Thread starter Thread starter Cambalinho
  • Start date Start date
C

Cambalinho

Guest
Public Class test1

Property rec As Rectangle
Private s As Graphics

Sub Show(ByRef a As IntPtr)
rec = New Rectangle(0, 0, 100, 100)
s.FromHwnd(a)
s.DrawRectangle(Pens.Blue, rec)
s.Dispose()
End Sub
End Class

in

s.FromHwnd(a)

i recive a warning: "Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated."

but in run-time i get an error in:

s.DrawRectangle(Pens.Blue, rec)

error message:

"NullReferenceException - the object reference wasnt define like 1 object instance"

heres how i use rhe class:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New test1
a.Show(Me.Handle)
End Sub

can anyone tell me where im wrong?

(im learning the classs now)

Continue reading...
 
Back
Top