Results 1 to 6 of 6

Thread: using the picture box to paint

  1. #1
    Guest

    Question

    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

  2. #2
    Guest
    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

    Code:
    Private Sub Command1_Click()
       Form1.PaintPicture Picture1.Picture, 0, 0, 100, 100
    End Sub

  3. #3
    Guest
    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

    Code:
    [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.

  4. #4
    Guest
    It copies to 0,0?? Where do you want it to copy to? Where ever the Mouse is when it is clicked?

  5. #5
    Guest
    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

  6. #6
    Junior Member
    Join Date
    Apr 2000
    Posts
    29
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width