Form Resizing and PictureClip Control

ElBarto666
03-24-2003, 07:27 AM
Hi !

I'm having a little problem here...
I have a form with a PictureClip control, PictureBox and horiz. and vert. scrollbars. What the program does is really simple: you see a part of the image in picturebox, you can use scrollbars to view rest of image. No probs here, but then I wanted to include form_resizing...

Again, no probs when resizing width or heigth separatly, but when you resize diagonaly the whole form is messed up ! The area around the picture is expanding, and that shouldn't happen. I tried refreshing or even reloading the image, but it didn't work.

I hope the problem is clear ? Any help would be appreciated ! :)

Flyguy
03-24-2003, 07:33 AM
Better share the resize code you already have.

ElBarto666
03-24-2003, 09:03 AM
Private Sub Form_Resize()
If Me.WindowState = vbMinimized Then 'anders error
Exit Sub
Else 'gmintXmax and gmintYmax are width and height of form
If (frmTest.ScaleWidth - scrVert.Width = gmintXmax) And (frmTest.ScaleHeight - scrHoriz.Height = gmintYmax) Then
frmTest.BorderStyle = 1 'fixed single

Else
'controls plaatsen
'vert.scrollbar.Width = 15
'horiz.scrollbar.height = 15
picDoel.Move 0, 0, frmTest.ScaleWidth - scrVert.Width, frmTest.ScaleHeight - scrHoriz.Height
scrVert.Move picDoel.Width, 0, scrVert.Width, picDoel.Height
scrHoriz.Move 0, picDoel.Height, picDoel.Width, scrHoriz.Height

'init scrollbars
scrHoriz.Value = 0
scrVert.Value = 0

'maximum van scrollbars instellen
scrHoriz.Max = picClipBron.Width - picDoel.Width
scrVert.Max = picClipBron.Height - picDoel.Height

If (frmTest.ScaleWidth > picClipBron.Width) And (frmTest.ScaleHeight > picClipBron.Height) Then
frmTest.ScaleHeight = picClipBron.Height
frmTest.ScaleWidth = picClipBron.Width
End If

'subprocedure oproepen
PictureClip
picDoel.Refresh
End If
End If
End Sub



Procedure PictureClip for showing part of image in Picturebox:

Private Sub PictureClip()
On Error GoTo err_PictureClip

'instellen linkerbovenhoek
picClipBron.ClipX = scrHoriz.Value
picClipBron.ClipY = scrVert.Value

'instellen breedte en hoogte
picClipBron.ClipHeight = picDoel.Height
picClipBron.ClipWidth = picDoel.Width

'ingestelde gebied selecteren
picDoel.Picture = picClipBron.Clip

Exit Sub

err_PictureClip:
MsgBox "Fout: PictureBox is groter dan PictureClip", vbOKOnly + vbCritical, "Fout"
picDoel.Picture = picClipBron.Picture
picDoel.Refresh
Form_Load
Resume Next
End Sub

Flyguy
03-24-2003, 03:50 PM
Shouldn't this:


If (frmTest.ScaleWidth > picClipBron.Width) And (frmTest.ScaleHeight > picClipBron.Height) Then
frmTest.ScaleHeight = picClipBron.Height
frmTest.ScaleWidth = picClipBron.Width
End If


be this:

If (frmTest.ScaleWidth > picClipBron.Width) Or (frmTest.ScaleHeight > picClipBron.Height) Then
frmTest.ScaleHeight = picClipBron.Height
frmTest.ScaleWidth = picClipBron.Width
End If

ElBarto666
03-24-2003, 04:26 PM
Hmm, never thought about it myself :) I can't try it right now, but even if it doesn't solve my problem I'd still say you're right.

ElBarto666
03-25-2003, 02:37 AM
Sorry Flyguy, made the little change but the "And" was correct.
I'm beginning to think this isn't necessarily a code-error. I searched this forum for help on scrollbars and found something about "flickering" of scrollbars...Or maybe it's the picturebox that messes things up.
Thanks for help btw ! :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum