Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Scrolling

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
npnp
Asked:
npnp
  • 4
  • 3
  • 3
  • +4
1 Solution
 
riduceCommented:
I guess you mean 800x600??
0
 
npnpAuthor Commented:
Yeah!
0
 
PatrickVDCommented:
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!

 
Erick37Commented:
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
 
AshokKumarCommented:
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
 
wsh2Commented:
PatrickVD: Page Cannot be found.. <sigh>
0
 
AzraSoundCommented:
this code shows how to make a form scrollable:
http://www.thescarms.com/VBasic/ScrollForm.htm
0
 
PatrickVDCommented:
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
 
npnpAuthor Commented:
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
 
npnpAuthor Commented:
AshokKumar: Your code works fine too!  Again, I wish I could distribute points to all who replied. -- Norm
0
 
Erick37Commented:
The Timer control's Top property can't be read at runtime.
0
 
Erick37Commented:
Actually it seems you can't read the Top property of any control that is invisible at runtime.
0
 
PatrickVDCommented:
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
 
npnpAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
  • 3
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now