Results 1 to 17 of 17

Thread: [RESOLVED] Expand a form to show all of picture

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved [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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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

  3. #3

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Expand a form to show all of picture

    Tweek it


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  6. #6

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  8. #8

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Expand a form to show all of picture

    Yes I have code to find and allow for the taskbar it could be anywhere
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Expand a form to show all of picture

    If the image is too big you'll probably want to provide scrollbars too.

  10. #10
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Expand a form to show all of picture

    Quote Originally Posted by isnoend07 View Post
    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.

  11. #11

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  12. #12
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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.

  13. #13

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Expand a form to show all of picture

    Thanks See attached click the button that says "click me" to show image
    Attached Files Attached Files
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  14. #14
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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

  15. #15

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Expand a form to show all of picture

    Name:  Wrong Pic.jpg
Views: 120
Size:  83.1 KB
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  16. #16
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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.
    Attached Files Attached Files

  17. #17
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Expand a form to show all of picture

    MarkT's 1st change (post 14) works for me


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

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