Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scrolling

Posted on 2000-04-03
14
Medium Priority
?
314 Views
Last Modified: 2010-05-02
A customer wants my app to fit in 640x480 and 600x800 screens.  It won't!  So - I figure to put the thing inside something with vertical and horizontal scroll bars.  Ideally, the entire form should be scrollable.  How can I do this?
Alternatively, what kind of container with scrolling can I put everything into? -- Norm
0
Comment
Question by:npnp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +4
14 Comments
 
LVL 1

Expert Comment

by:riduce
ID: 2681889
I guess you mean 800x600??
0
 

Author Comment

by:npnp
ID: 2681896
Yeah!
0
 
LVL 1

Expert Comment

by:PatrickVD
ID: 2681969
Hi,

Basically, you could use a picturebox to put all your controls on. Combined with some HScroll and VScroll control you could manage to scroll the picture box onto the form.
It will take some work to get to the results.
But, the following might save your day.
I once found a ScrollableBox UserControl on the web. I can't even remember where I found it, but its in source code, so you can have a peek at it or even use it in your project. All you need to do is copy and paste all the controls of your form to this container control... and voila, you got it scrolling, no matter which resolution you're running.
I copied a zipped version on one of my unused webspaces... just go get it !
http://club.euronet.be/patrick.vanden.driessche/scrollbox.zip
The file will remain online until the end of the week...
Let me know if the link should not work correctly, and I'll send it by email.

Hope this helps,

Patrick.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Expert Comment

by:Erick37
ID: 2682253
Another thing you can do is make your main form an MDIChild form.  Set its BorderStyle to 0 - None, and its caption to ""

When the form is shown inside the MDI form, scrollbars will automatically be functional.

e.g.

Private Sub MDIForm_Load()
    'Form1 is borderless
    Form1.Show
    Form1.Move 0, 0
    Me.BackColor = Form1.BackColor
End Sub
0
 

Expert Comment

by:AshokKumar
ID: 2682709
HI. Try this. Just copy this and paste in a module and then call it in each Form's Load event. In the form, set the tag as your current config. Size (Ex. 800x600 thenform1.tag=800)

Get back to me.


Public Sub resolutionmain(Frm As Form)
On Error Resume Next
Dim lviVal As Single
Select Case Screen.Height
Case 9200 To 13000
'When the resolution is increased from 640 to 1024.
If UCase(Trim(Frm.Tag)) = "640" Then
    'The ratio 1.6 is got from (1024/640)
    lviVal = Screen.Height / 7200
    For I = 0 To Frm.Controls.Count - 1
        Frm.Controls(I).Width = Frm.Controls(I).Width * lviVal
        Frm.Controls(I).Height = Frm.Controls(I).Height * lviVal
        If Frm.Controls(I).Left >= 0 Then Frm.Controls(I).Left = Frm.Controls(I).Left * lviVal
        If Frm.Controls(I).Top >= 0 Then Frm.Controls(I).Top = Frm.Controls(I).Top * lviVal
        If TypeOf Frm.Controls(I) Is Label Then
            Frm.Controls(I).Font.Size = Frm.Controls(I).Font.Size * lviVal
        End If
    Next
    Frm.Height = Frm.Height * lviVal
    Frm.Width = Frm.Width * lviVal
    Frm.Left = Frm.Left * lviVal
    Frm.Top = Frm.Top * lviVal
'When the resolution is increased from 800 to 1024.
ElseIf UCase(Trim(Frm.Tag)) = "800" Then
    'The ratio 1.28 is got from (1024/800)
    lviVal = Screen.Height / 9000
    For I = 0 To Frm.Controls.Count - 1
       Frm.Controls(I).Width = Frm.Controls(I).Width * lviVal
       Frm.Controls(I).Height = Frm.Controls(I).Height * lviVal
       If Frm.Controls(I).Left >= 0 Then Frm.Controls(I).Left = Frm.Controls(I).Left * lviVal
       If Frm.Controls(I).Top >= 0 Then Frm.Controls(I).Top = Frm.Controls(I).Top * lviVal
       If TypeOf Frm.Controls(I) Is Label Then
            Frm.Controls(I).Font.Size = Frm.Controls(I).Font.Size * lviVal
       End If
    Next
    Frm.Height = Frm.Height * lviVal
    Frm.Width = Frm.Width * lviVal
    Frm.Left = Frm.Left * lviVal
    Frm.Top = Frm.Top * lviVal
    Frm.FontSize = Frm.FontSize * lviVal
End If
Frm.Tag = "1024"

Case 8510 To 10000
'When the resolution is increased from 640 to 800.
If UCase(Trim(Frm.Tag)) = "640" Then
    lviVal = Screen.Height / 7200
    'The ratio 1.25 is got from (800/640)
    For I = 0 To Frm.Controls.Count - 1
        Frm.Controls(I).Width = Frm.Controls(I).Width * lviVal
        Frm.Controls(I).Height = Frm.Controls(I).Height * lviVal
        If Frm.Controls(I).Left >= 0 Then Frm.Controls(I).Left = Frm.Controls(I).Left * lviVal
        If Frm.Controls(I).Top >= 0 Then Frm.Controls(I).Top = Frm.Controls(I).Top * lviVal
        If TypeOf Frm.Controls(I) Is Label Then
           ' Frm.Controls(I).Font.Size = Frm.Controls(I).Font.Size * lviVal
        End If
    Next
    Frm.Height = Frm.Height * lviVal
    Frm.Width = Frm.Width * lviVal
    Frm.Left = Frm.Left * lviVal
    Frm.Top = Frm.Top * lviVal
    'When the resolution is decreased from 1024 to 800.
    Frm.Tag = "800"
ElseIf UCase(Trim(Frm.Tag)) = "1024" Then
    lviVal = Screen.Height / 11520
    'The ratio is got from (800/1024)
    For I = 0 To Frm.Controls.Count - 1
        Frm.Controls(I).Width = Frm.Controls(I).Width * lviVal
        Frm.Controls(I).Height = Frm.Controls(I).Height * lviVal
        If Frm.Controls(I).Left >= 0 Then Frm.Controls(I).Left = Frm.Controls(I).Left * lviVal
        If Frm.Controls(I).Top >= 0 Then Frm.Controls(I).Top = Frm.Controls(I).Top * lviVal
        If TypeOf Frm.Controls(I) Is Label Then
            Frm.Controls(I).Font.Size = Frm.Controls(I).Font.Size * lviVal
        End If
    Next
    Frm.Height = Frm.Height * lviVal
    Frm.Width = Frm.Width * lviVal
    Frm.Left = Frm.Left * lviVal
    Frm.Top = Frm.Top * lviVal
End If
'Tag to store the resolution.
Frm.Tag = "800"

Case Is < 8500

'When the resolution is increased from 640 to 800.
If UCase(Trim(Frm.Tag)) = "800" Then
    lviVal = Screen.Height / 9000
    'The ratio 1.25 is got from (800/640)
    For I = 0 To Frm.Controls.Count - 1
        Frm.Controls(I).Width = Frm.Controls(I).Width * lviVal
        Frm.Controls(I).Height = Frm.Controls(I).Height * lviVal
        If Frm.Controls(I).Left >= 0 Then Frm.Controls(I).Left = Frm.Controls(I).Left * lviVal
        If Frm.Controls(I).Top >= 0 Then Frm.Controls(I).Top = Frm.Controls(I).Top * lviVal
        If TypeOf Frm.Controls(I) Is Label Then
            Frm.Controls(I).Font.Size = Frm.Controls(I).Font.Size * lviVal
        End If
    Next
    Frm.Height = Frm.Height * lviVal
    Frm.Width = Frm.Width * lviVal
    Frm.Left = Frm.Left * lviVal
    Frm.Top = Frm.Top * lviVal
'When the resolution is decreased from 1024 to 800.
ElseIf UCase(Trim(Frm.Tag)) = "1024" Then
    lviVal = Screen.Height / 11520
    'The ratio is got from (800/1024)
    For I = 0 To Frm.Controls.Count - 1
        Frm.Controls(I).Width = Frm.Controls(I).Width * lviVal
        Frm.Controls(I).Height = Frm.Controls(I).Height * lviVal
        If Frm.Controls(I).Left >= 0 Then Frm.Controls(I).Left = Frm.Controls(I).Left * lviVal
        If Frm.Controls(I).Top >= 0 Then Frm.Controls(I).Top = Frm.Controls(I).Top * lviVal
        If TypeOf Frm.Controls(I) Is Label Then
            Frm.Controls(I).Font.Size = Frm.Controls(I).Font.Size * lviVal
        End If
        Frm.Height = Frm.Height * lviVal
        Frm.Width = Frm.Width * lviVal
        Frm.Left = Frm.Left * lviVal
        Frm.Top = Frm.Top * lviVal
    Next
End If
Frm.Tag = "640"
End Select
End Sub
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2682801
PatrickVD: Page Cannot be found.. <sigh>
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 2682900
this code shows how to make a form scrollable:
http://www.thescarms.com/VBasic/ScrollForm.htm
0
 
LVL 1

Expert Comment

by:PatrickVD
ID: 2683550
wsh2,
There are no pages to be found... it's a direct link to the file. It's works fine for me...
There is nothing else there except this file. I don't have any homepages, but I'm just using this space to share files with others...
If you can't get the file but are interested in it, mail me : PatrickVD@vbmail.net and I'll send it to you.

Cheers.
0
 

Author Comment

by:npnp
ID: 2684399
Gracious!  Wow!
Wish I could give points to all!
Thank you all very much.

AzraSound: Your code works fine.  I made it work horizontally too.  There is some control on my form for which "Top" cannot be determined at run time, says an error message.  I'll track that down myself and see why not.

PatrickVD: The link you gave does not work.  I'll e-mail you, if you don't mind.

Thanks to all again -- Norm
0
 

Author Comment

by:npnp
ID: 2684405
AshokKumar: Your code works fine too!  Again, I wish I could distribute points to all who replied. -- Norm
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2684441
The Timer control's Top property can't be read at runtime.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2684498
Actually it seems you can't read the Top property of any control that is invisible at runtime.
0
 
LVL 1

Expert Comment

by:PatrickVD
ID: 2686721
Hi all,

It seems I have some correction to make here... I made a small mistake in the URL of that downloadable file...
So if you're still interested in the ScrollBox Usercontrol, come and get it at :
http://club.euronet.be/patrick.vanden.driessche/ScrollBox.zip 
This one should be working fine. It seems that the filename is case sensitive...
Sorry for this.

Patrick.
0
 

Author Comment

by:npnp
ID: 2687341
AshokKumar:
Your "resolutionmain" sub is fine. I can make it work by "hard-wiring" form.tag.  How can I make it work automatically?  That is, how can I get the current value to set form.tag to, from the current screen settings?  I suppose there is an API function to get this number.  I have Dan Appleman's book, but there are so many APIs I don't know where to look. -- Norm
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

715 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