is there a way to make a form's picture property picture stretch along with the form?
Printable View
is there a way to make a form's picture property picture stretch along with the form?
Use bitblt or stretchbit API.
You can use the Forms PaintPicture() Method, i.e.VB Code:
Option Explicit Private Sub Form_Load() Picture = LoadPicture("C:\SomeFile.bmp") End Sub Private Sub Form_Paint() If Picture.Handle = 0 Then Exit Sub ' An Error Could Occur if the Form Size ' Becomes Invalid for the Paint Operation. On Error GoTo Paint_Error ' Size the Form Picture to fit the ' Dimensions of the form. PaintPicture _ Picture, _ 0, 0, _ ScaleWidth, ScaleHeight, _ 0, 0, _ ScaleX(Picture.Width, vbHimetric, ScaleMode), _ ScaleY(Picture.Height, vbHimetric, ScaleMode) Paint_Error: End Sub Private Sub Form_Resize() ' Force the Form to Call the ' Paint Method on a Resize, as it ' will not always call a Paint when ' Down-sizing a Form. Form_Paint End Sub
You could also just place a picture in an image box and size it to the form sizeVB Code:
Option Explicit Private Sub Form_Load() Image1.Stretch = True Image1.Picture = LoadPicture("C:\my picture.bmp") End Sub Private Sub Form_Resize() Image1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight Image1.ZOrder 1 End Sub