Results 1 to 4 of 4

Thread: background picture

  1. #1

    Thread Starter
    Member mafia_geek's Avatar
    Join Date
    Jan 2002
    Location
    California
    Posts
    45

    background picture

    is there a way to make a form's picture property picture stretch along with the form?
    -mafia_geek-

    Condito, Ergo Sum

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Use bitblt or stretchbit API.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can use the Forms PaintPicture() Method, i.e.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Picture = LoadPicture("C:\SomeFile.bmp")
    5. End Sub
    6.  
    7. Private Sub Form_Paint()
    8.     If Picture.Handle = 0 Then Exit Sub
    9.    
    10.     ' An Error Could Occur if the Form Size
    11.     ' Becomes Invalid for the Paint Operation.
    12.     On Error GoTo Paint_Error
    13.    
    14.     ' Size the Form Picture to fit the
    15.     ' Dimensions of the form.
    16.     PaintPicture _
    17.         Picture, _
    18.         0, 0, _
    19.         ScaleWidth, ScaleHeight, _
    20.         0, 0, _
    21.         ScaleX(Picture.Width, vbHimetric, ScaleMode), _
    22.         ScaleY(Picture.Height, vbHimetric, ScaleMode)
    23.        
    24. Paint_Error:
    25. End Sub
    26.  
    27. Private Sub Form_Resize()
    28.     ' Force the Form to Call the
    29.     ' Paint Method on a Resize, as it
    30.     ' will not always call a Paint when
    31.     ' Down-sizing a Form.
    32.     Form_Paint
    33. End Sub

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    You could also just place a picture in an image box and size it to the form size
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Image1.Stretch = True
    5.     Image1.Picture = LoadPicture("C:\my picture.bmp")
    6. End Sub
    7.  
    8. Private Sub Form_Resize()
    9.     Image1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
    10.     Image1.ZOrder 1
    11. 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