Home All Groups Group Topic Archive Search About
Author
6 Oct 2006 4:22 PM
Lucas Napzchyr
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

im testing around a little with system.drawing.
I setup a Form to paint on it.

The problem: Paintig on a form or else is ok, but if my form lose the
handle by switching into an other app or showing an dialog on my form
will erase the drawed things.

Here we go: How i can save it :) or how to solve that my drawed form
will not erased?

Regards, Lucas


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFJoLdRzxqsJWDX28RAjhnAJ49NAVO1I9dzei/eE0FIafct4k4IgCfQphu
3LVas32+wCDrEhXZ1/aIq90=
=Mx3k
-----END PGP SIGNATURE-----

Author
6 Oct 2006 4:31 PM
Robinson
Show quote Hide quote
"Lucas Napzchyr" <lucas-napzc***@gmx.de> wrote in message
news:UnvVg.11975$Mv1.8996@newsfe04.ams...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> im testing around a little with system.drawing.
> I setup a Form to paint on it.
>
> The problem: Paintig on a form or else is ok, but if my form lose the
> handle by switching into an other app or showing an dialog on my form
> will erase the drawed things.
>
> Here we go: How i can save it :) or how to solve that my drawed form
> will not erased?
>
> Regards, Lucas
>

Handle the "Paint" event of the form to do your painting.
Author
7 Oct 2006 12:04 AM
Herfried K. Wagner [MVP]
"Robinson" <toomuchspamhaspassed@myinboxtoomuchtoooften.com> schrieb:
>> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
7 Oct 2006 7:23 AM
Lucas Napzchyr
Herfried K. Wagner [MVP] schrieb:
> "Robinson" <toomuchspamhaspassed@myinboxtoomuchtoooften.com> schrieb:
>>> 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.CreateGraphics()
    Dim test1 As System.Windows.Forms.PaintEventArgs
    Dim rc As Rectangle

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        mymouse.Click1Pos = New Point(e.X, e.Y)
        rc = New Rectangle(mymouse.Click1Pos.X, mymouse.Click1Pos.Y, 50, 50)
        'desk.DrawRectangle(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(desk, desk.DrawRectangle(New Pen(Color.Black,
10), rc))
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        mymouse.MousePos = New Point(e.X, e.Y)
    End Sub
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint

    End Sub
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        desk.DrawRectangle(New Pen(Color.Black, 10), rc)
    End Sub 'OnPaint
End Class

###########################################################################

Greets, Lucas
Author
8 Oct 2006 9:54 AM
Stuart Nathan
Create a bitmap and draw on it and then use it as your background image.
But the Overrides onpaint event should persist the drawing