|
-
December 5th, 1999, 12:51 PM
#1
Help with resizing the PictureBox contorl if the Picture is too big.
I need to be able to have VB automatically make the picturebox go back to it's normal siz if the imported picture is too big. This is what I have so far
private Sub Picture1_Resize()
If Picture1.ScaleHeight > "33" Or Picture1.ScaleWidth > "41" then MsgBox "Too Big!", vbCritical
If Picture1.ScaleHeight > "33" Or Picture1.ScaleWidth > "41" then Picture1.ScaleHeight = (33) And Picture1.ScaleWidth = (41)
End Sub
can anyone help me? Thanks!
-
December 5th, 1999, 06:00 PM
#2
Re: Help with resizing the PictureBox contorl if the Picture is too big.
Something would have to occur to invoke the Resize event. Try the Paint event.
Also, try putting the loaded picture into an Image control (which would be on your PictureBox).
Then in the "Picture Paint" event, resize your Picture to equate with the size of the Image control.
Since the Image control will automatically resize to fit the picture.
If the picture is larger than the screen you will have to use a Scrollbar on the form to move the picture up and down,
and make the picture larger than the screen.
-
December 6th, 1999, 05:23 AM
#3
Re: Help with resizing the PictureBox contorl if the Picture is too big.
Try setting the Picture box's AutoSize Property to True, it should fire Resize event.
private Sub Picture1_Resize()
static bstillinside as boolean
if bStillInside then exit sub
bSitllInside = true
with Picture1
Debug.Assert .ScaleMode = VbPixels ' is my assumption correct?
If .ScaleHeight > "33" Or _
.ScaleWidth > "41" then
MsgBox "Too Big!", vbCritical
.Move .Left , .Top , 37 , 45
' this line will triger another _Resize Event, and we need to block it so that
' we dont end up in recursive loops
' Also, setting the scaleWidth will not change the size, instead it will make the ScaleMode to "User", and take those values
' You need to play around with the values.
' for width & height.
' it depends on the BorderStyle, and Appearence. If both are on then it is usally 3 Pixels
' Or try using GetWindowRect and GetClientRect, and maintain the same difference.
end if
' dont forget this:
bStillInside = false
End Sub
RK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|