|
-
Mar 30th, 2000, 01:07 AM
#1
Thread Starter
Lively Member
As usual I think I'm losing my marbles. I've started messing about with something that I've steered well clear of since I started with VB about 6 months ago. APIs and picture boxes. I felt I should do something about it, so I started messing about getting comfortable with them before I started doing anything complicated - experimenting with BitBlt and SetPixelV when I noticed something a bit wierd
Maybe someone could explain:-
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 0 Then
Else:
SetPixelV Picture1.hdc, X, Y, vbBlack
End If
End Sub
now this doesn't really do ne thing out of the ordinary - it just fills in the pixels in the picture box as your mouse moves across it, providing one of the mouse buttons is depressed. Having done that, if you drag another window across the picture box, the little drawing you've made in the picture box vanishes!!!!!
Whoooooo - spooky
Can somebody please explain why??? I would also be muchos grateful if someone could also suggest a suitable solution to my disappearing image solution
Thanx guys 
Sam
-
Mar 30th, 2000, 09:49 PM
#2
Frenzied Member
It's because your auto redraw is set to false, when you drag something across the picture box windows draws it on the pictureboxes DC and then takes it away again as it moves, vb then has to redraw the picture box but as it doesn't know about your API calls is doesn't redraw them (I don't think it redraws if you PSet either)
If you set Autoredraw to true then picture1.hDC will give you a handle to a persistant DC which it bitblts onto the window when it redraws, wo you won't wipe the Picture box with dragging controls.
Hope this helps
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|