Solved

Expand a form to show all of picture

Posted on 2014-07-21
28
132 Views
Last Modified: 2014-07-22
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
0
Comment
Question by:isnoend2001
  • 14
  • 14
28 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40211698
Me.Height = picShowPic(2).Height + picShowPic(2).Top + 50 + (Me.Height - Me.ScaleHeight) 'size the form
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40211725
And to show the whole picture and not just the height then do this instead of the above.

' The four parts of the following are Left, top, Width, height
Me.Move Me.Left, _
        Me.Top, _
        picShowPic(2).Width + picShowPic(2).Left + 50, _
        picShowPic(2).Height + picShowPic(2).Top + 50 + (Me.Height - Me.ScaleHeight)

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 40211813
Thanks, Martin Liss, but the form does not grow taller to show the whole pic.
the bottom of the pic is cut off
See attached form
command1 runs the resizing
0
 

Author Comment

by:isnoend2001
ID: 40211818
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40211888
Attaching the frm and frx files are not enough for me to open the project but in the form you still have your old code

        picShowPic(2).AutoSize = True
        Me.Height = picShowPic(2).Top + picShowPic(2).Height + 50 'size the form
        Me.Top = Screen.Height / 2 - Me.Height / 2
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40211916
Here are before and after pictures. Please ignore what's in the pictures and take my word for it that the whole picture is shown.

The code I used was.

Private Sub Command1_Click()
picShowPic(2).AutoSize = True
'Me.Height = picShowPic(2).Height + picShowPic(2).Top + 50 + (Me.Height - Me.ScaleHeight) 'size the form
' The four parts of the following are Left, top, Width, height
Me.Move Me.Left, _
        Me.Top, _
        picShowPic(2).Width + picShowPic(2).Left + 50, _
        picShowPic(2).Height + picShowPic(2).Top + 50 + (Me.Height - Me.ScaleHeight)
Me.Top = Screen.Height / 2 - Me.Height / 2
End Sub

Open in new window

BeforeAfter
0
 

Author Comment

by:isnoend2001
ID: 40211930
thanks Martin Liss
I do not need the width adjusted only the form made taller.
Did you see the form i uploaded ?
0
 

Author Comment

by:isnoend2001
ID: 40211945
On the form i uploaded click cmdShowPic(1) then look at pic
click Command1 the form is shorter
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40211947
I did see the form but as I said I can't run it because you didn't include the whole project. In any case if you don't need to make the form wider then just do this.

Private Sub Command1_Click()
picShowPic(2).AutoSize = True
Me.Height = picShowPic(2).Height + picShowPic(2).Top + 50 + (Me.Height - Me.ScaleHeight) 'size the form
Me.Top = Screen.Height / 2 - Me.Height / 2
End Sub

Open in new window

0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40211954
On the form i uploaded click cmdShowPic(1) then look at pic
I can't without the whole project.
0
 

Author Closing Comment

by:isnoend2001
ID: 40211995
Sorry martin i forgot about the activex Command buttons, but i think i found the issue I was showing index 1
was trying to adjust index 2. If i have more issues i will replace the the activex with vb buttons.The project is huge with tons of activex controls
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40212016
I'm confused. I assume that this is a VB6 project and if it is what do you mean when you say "i will replace the the activex with vb buttons"?
0
 

Author Comment

by:isnoend2001
ID: 40212062
The form i sent had these command buttons
 http://www.namtuk.com/MyCommandButton-for-ActiveX.aspx
to upload for you i would replace the array of MyButtons with vb command buttons
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40212104
OK, thanks, and now I understand.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:isnoend2001
ID: 40212337
Thanks Martin Liss
I changed the command buttons, but for some reason the form will not go tall enough to show the whole pic
see attached
RoofPics.zip
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40212383
That attachment only contains the form again. If you want to attach a picture then just click this button.Click it
0
 

Author Comment

by:isnoend2001
ID: 40212410
I am curious the picture Was Included in a picture box on the form.
Was it not ?
0
 

Author Comment

by:isnoend2001
ID: 40212418
RoofPic.jpg
0
 

Author Comment

by:isnoend2001
ID: 40212464
I downloaded the zip and the image was included
click the button that says "click me" to show image
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40212615
A person can only open the app if they have the non-vb controls on your PC and I don't.
0
 

Author Comment

by:isnoend2001
ID: 40212673
The only controls on the form are:
Picture box and command buttons.
You do not have these ?
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40212827
I'm sorry but I didn't realize that you changed the form and if I change

        Me.Height = picShowPic(1).Height + picShowPic(1).Top + 50 'size the form

to

        Me.Height = picShowPic(1).Height + picShowPic(1).Top + 50 + (Me.Height - Me.ScaleHeight) 'size the form

it works. Is there anything else I can do for you?

BTW I need a pergola built for my patio. Do you want to do it?
0
 

Author Comment

by:isnoend2001
ID: 40213021
Thanks that fixed it
Re:
BTW I need a pergola built for my patio. Do you want to do it?
Thanks, but no I,m too old (66)
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40213036
Hey I'm 73:)
0
 

Author Comment

by:isnoend2001
ID: 40213106
Getting old sucks i dug a 50 ft waterline to garden last week took me 3 days instead of a few hours
Glad to be back using vb.I can kinda read vb code
Asked about 15 questions last week using jquery
To make this page:
http://roofgenius.com/Roof-Pitch-Calculator.asp
I read this line of code and thought "Are these people from earth"
t2 = ""||/^(\d+)?([.]?\d{0,2})?$/.test(text)===false?t2 = "Input Numbers Only":t2="";
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40213121
Lol, I hope there are comments, however back in the day (1985?) I used to program in APL which, believe it or not, stood for A Programming Language. Google APL is you want to see some complex code!
0
 

Author Comment

by:isnoend2001
ID: 40213140
At least vb reading kinda makes sense
L←S⌽(−(⍴L)+0,X)↑L    
    A←((1↑⍴L),X)↑L      
   N←0 1↓DLTB(0,X)↓L
Totally unreadable
Wish i knew as much about coding vb6 as i do roofing
When i had my roofing company i wrote a roof estimating program using Lotus123 and it was readable.
I am glad you are here
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40213146
Thanks. Given my age I'm glad I'm here too:)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now