Solved

Scrolling

Posted on 2000-04-03
14
304 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
  • 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
 
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 50 total points
ID: 2682900
this code shows how to make a form scrollable:
http://www.thescarms.com/VBasic/ScrollForm.htm
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

9 Experts available now in Live!

Get 1:1 Help Now