Click to See Complete Forum and Search --> : using the picture box to paint
can i use the picture box to paint with a picture as a brush?
what is 'paintpicture' and how do i use it, and generally how do i draw on a picture box.
Boaz zemeR
To use a picture as a brush, use the BitBlt API and copy it to X and Y whenever the mouse is down.
To use the PaintPicture method, create a Form with a PictureBox and a CommandButton. Make sure that the ScaleMode property of everything is set to Pixel, and also make sure that there is a Picture in the PictureBox.
Now, add this code to the CommandButton
Private Sub Command1_Click()
Form1.PaintPicture Picture1.Picture, 0, 0, 100, 100
End Sub
how would you blit an image to a picbox(not an image control, but the contents of a picbox) like, you were paintihng it?
I tried this
[general declarations]
Dim hello As Long
Dim hello2 As Long
Dim this As POINTAPI
______________________________
Private Sub Picture1_Click()
'this.X = Picture1.CurrentX
'this.Y = Picture1.CurrentY
BitBlt Picture1.hdc, hello, hello2, 9, 9, Picture2.hdc, 0, 0, vbSrcCopy
End Sub
________________________________
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
hello = this.X
hello2 = this.Y
this.X = Picture1.CurrentX
this.Y = Picture1.CurrentY
End Sub
I tried this, but it blits it to 0,0
I tried some other things too with no luck :(
please help
thanks.
It copies to 0,0?? Where do you want it to copy to? Where ever the Mouse is when it is clicked?
yep. I want it to draw while the mouse is down, and draw whereever the mouse is dragged...
I can take care of that later.. i just need to know why it keeps copying to 0,0
ef2k
Jun 5th, 2000, 04:38 AM
to bzemer: i was working on the exact same thing, a paint program, well i still am, but anyways :)
here's the code i used:
Private Type POINTAPI
x As Double
y As Double
End Type
Dim point1 As POINTAPI
Dim point2 As POINTAPI
Dim pressed as Boolean
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
pressed = True
point1.x = x
point1.y = y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If pressed = True then
point2 = point1
point1.x = x
point1.y = y
Picture1.Line (point1.x, point1.y)-(point2.x, point2.y)
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
pressed = False
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.