-
ok I have a Picture box and I am useing the api
Private Declare Function LineTo Lib "gdi32" _
(ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long) As Long
to do my lines, so I do
dim RC as long
RC = LineTo(Picture1.hdc,100,100)
when I minimize, or move something over it, the line erases. I have a button to draw a line, and the function looks like this:
Picture1.AutoRedraw = False
Dim rc As Long
rc = LineTo(Picture1.hdc, 100, 100)
Picture1.AutoRedraw = True
but yet the pic still gets erased, any ways to stop this?
-
AutoRedraw
If you set AutoRedraw to false then the line will be drawn on the pictureBox but when the pictureBox is next refreshed (i.e. repainted) the line will disappear.
If you want the line to stay, Set AutoRedraw=True in the property of the picturebox or at the top of your sub.
Then after calling LineTo, call Picture1.Refresh to force VB to re-paint the PictureBox (VB doesn't know that an API call was made to do something in the PictureBox DC).
Hope it helps.