[RESOLVED] Expand a form to show all of picture
Private Sub Command1_Click()
picShowPic(2).AutoSize = True
Me.Height = picShowPic(2).Top + picShowPic(2).Height + 50 'size the form
Me.Top = Screen.Height / 2 - Me.Height / 2
End Sub
I cannot get the form to grow taller to display all the picturebox contents
what is wrong?
using vb6
Re: Expand a form to show all of picture
See if something like this works
Code:
Private Sub Command1_Click()
With Picture1
.AutoSize = True
.Picture = LoadPicture("c:\summit.jpg")
.Move 0
Me.Width = .Width + (Me.Width - Me.ScaleWidth)
Me.Height = .Top + .Height + (Me.Height - Me.ScaleHeight)
End With
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
End Sub
Re: Expand a form to show all of picture
thanks MarkT
But that does not work. The bottom of the pic is cut off.
The width is fine only need to adjust form height so all of pic shows
Re: Expand a form to show all of picture
Re: Expand a form to show all of picture
There are tons of things to deal with here.
The user may have multiple monitors. The Screen object only returns metrics for the primary monitor and these do not take Toolbars (such as the Taskbar) into account.
The user might change things during program execution such as the height of caption bars and thickness of borders. He might even drag the window from the first monitor it was open on to another monitor or change the resolution of the current monitor.
Unless you want to address all of these issues you are far better off letting the user resize your Forms and then adjust your controls to fit within the available client area.
Re: Expand a form to show all of picture
Thanks
I think I will give a option to This Program best viewed in 1280x 800 and let the user resize the forms, but i want the whole pic to be visible in 1280x800
Re: Expand a form to show all of picture
Might be tough. Most users do not auto-hide the Taskbar plus you have a caption bar and Form borders.
Re: Expand a form to show all of picture
Yes I have code to find and allow for the taskbar it could be anywhere
Re: Expand a form to show all of picture
If the image is too big you'll probably want to provide scrollbars too.
Re: Expand a form to show all of picture
Quote:
Originally Posted by
isnoend07
thanks MarkT
But that does not work. The bottom of the pic is cut off.
The width is fine only need to adjust form height so all of pic shows
How big is your picture? Keep in mind there are limits to form sizes. Can you attach a stripped down version of your app that shows your problem? The code I posted works fine on my machine.
Re: Expand a form to show all of picture
i have a stripped down version, but i cannot seem to see how to attach it
only buttons i see are Quote,video, image,link,smiley and text formating
Re: Expand a form to show all of picture
If you go to advanced then if you scroll down you will see a Manage Attachment button. If you click that you can upload your project zipped.
1 Attachment(s)
Re: Expand a form to show all of picture
Thanks See attached click the button that says "click me" to show image
Re: Expand a form to show all of picture
Update the CenterPic sub and you should be fine.
Code:
Sub CenterPic(Index As Integer)
picShowPic(Index).Top = picContainer.Top + picContainer.Height + lblShowPic.Height + 200
picShowPic(Index).Left = Me.ScaleWidth / 2 - picShowPic(Index).Width / 2
picShowPic(Index).Visible = True
' if you want padding under the image add a little extra
Me.Height = picShowPic(Index).Top + picShowPic(Index).Height + (Me.Height - Me.ScaleHeight)
End Sub
1 Attachment(s)
Re: Expand a form to show all of picture
1 Attachment(s)
Re: Expand a form to show all of picture
If this doesn't work then there is some kind of difference between your machine and mine that is causing problem. If on the other hand it does work then you need to try and find where you missed the changes I told you about.
Re: Expand a form to show all of picture
MarkT's 1st change (post 14) works for me