Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cut & paste graphics from less that the whole picture / box???

Status
Not open for further replies.

Cresby

Programmer
Aug 15, 2002
287
GB
Anyone know an easy way to cut and paste a subset/block of a graphic / picture box?

The application is to scroll without bloating the image size and adding to the processing time, even if I bite on the bullet and convert what I have to be easier to put into a box instead of the MDI form.

I used to do this in QB2.5 by accessing memory with BLOAD and BSAVE which is long gone as a feature.

 
Have a look at Paintpicture.

Here an example to create a horizontal scrolling Picture:
Create a form with 2 pictureboxes and one Timer on it (Timer set to any Interval try 100). Paste the following code into the form:
Code:
Private lngmTPX As Long
Private lngmWidth As Long
Private lngmHeight As Long
Private lngmWidth2 As Long

Private Sub Form_Load()
    lngmTPX = Screen.TwipsPerPixelX
    lngmWidth = Picture1.ScaleWidth
    lngmHeight = Picture1.ScaleHeight
    lngmWidth2 = lngmWidth - lngmTPX
    Picture2.Height = Picture1.Height
End Sub

Private Sub Timer1_Timer()
    
    Picture2.PaintPicture Picture1.Picture, 0, 0, lngmTPX, lngmHeight, _
        0, 0, lngmTPX, lngmHeight
    Picture2.Picture = Picture2.Image
    Picture1.PaintPicture Picture1.Picture, 0, 0, lngmWidth2, lngmHeight, _
        lngmTPX, 0, lngmWidth2, lngmHeight
    Picture1.Picture = Picture1.Image
    Picture1.PaintPicture Picture2.Picture, lngmWidth2, 0, _
        lngmWidth, lngmHeight, _
        0, 0, lngmTPX, lngmHeight
End Sub


hope this helps
Andreas
 
Will look again when I am home but thanx, my first thought is if it works for 2 contiguous blocks then the principle would extend to a multiplicity of blocks. I could maybe use array objects? Presume Paintpicture is a code example.
Thanx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top