Herfried K. Wagner [MVP] schrieb:
"Robinson" <to************ ******@myinboxt oomuchtoooften. comschrieb:
>>Here we go: How i can save it :) or how to solve that my drawed form
will not erased?
Handle the "Paint" event of the form to do your painting.
... or override its 'OnPaint' method.
ok thanks for u'r answers but it's not running.
(Forgive me but i'm not very familiar with VB :) )
I tried both and in both cases the (in that example) rectangle
will erased on new 'Paint'. I'm sure i'm wrong handling the event
because i can't find an description for my problem on google :(
here a little code:
############### ############### ############### ############### ##########
Imports System.Drawing
Public Class Form1
Inherits System.Windows. Forms.Form
Structure MOUSE
Dim MousePos As Point
Dim Click1Pos As Point
End Structure
Dim mymouse As MOUSE
Dim desk As Graphics = Me.CreateGraphi cs()
Dim test1 As System.Windows. Forms.PaintEven tArgs
Dim rc As Rectangle
Private Sub Form1_MouseClic k(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles Me.MouseClick
mymouse.Click1P os = New Point(e.X, e.Y)
rc = New Rectangle(mymou se.Click1Pos.X, mymouse.Click1P os.Y, 50, 50)
'desk.DrawRecta ngle(New Pen(Color.Black , 10), rc)
'I tried this, but.. it produce an error: "error BC30491:
Expression does not produce a value."
'Call Form1_Paint(des k, desk.DrawRectan gle(New Pen(Color.Black ,
10), rc))
End Sub
Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles Me.MouseMove
mymouse.MousePo s = New Point(e.X, e.Y)
End Sub
Private Sub Form1_Paint(ByV al sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Me.Paint
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
desk.DrawRectan gle(New Pen(Color.Black , 10), rc)
End Sub 'OnPaint
End Class
############### ############### ############### ############### ###############
Greets, Lucas