Go Premium for a chance to win a PS4. Enter to Win

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

how to show scrollbars for MDI child form

I have a MDI application with MDI child screens.

When I open MDI child screens in the App, I donot get vertical and horizantal scroll bars for child forms (making it look ugly, and hide several control in the form).

For example, when you open a doc. in WORD you get vert. & horiz. scrollbars for the document view automatically.

Though this is farily simple one, but I do not know how to do it (and also documentation is unhelpful).

Thanks for your answer,

D.Venkatesan Pillai
Senior Software Engineer
dvenkat@iptcorp.com or (dvenkat68@hotmail.com)
0
dvenkat
Asked:
dvenkat
  • 3
  • 2
1 Solution
 
clifABBCommented:
If you are talking about the scroll bars on the parent form, they should appear automatically when needed.

If you are talking about each child forms scroll bars, you have to add them yourself using VScrollBar & HScrollBar.
0
 
clsmasterCommented:
It's actually a bit harder than you would think.  Scrollbars do not automatically appear on forms (only on the MDI parent for).  What you can do is place a vertical scrollbar on the form and position it on the right side of the screen.  You can do the same if you need a horizontal scroll bar.
After that set the max property to the hight of the form and the min property to 0.  Name the scrollbar vScroll
Then set the tag property of the control to the top property on the control
Then in the code use the following:

sub vScroll_Change()
  vScroll_Scroll
end sub

sub vScroll_Scroll
  dim ctl as object

  on local error resume next
  for each ctl in Form1
    ctl.top = ctl.tag - scroll.value
  next
end sub

This will scroll each control on the form when the scrollbars are used.  A few notes:
1.  Set the Tabstop property of the scrollbar to False
2.  You must used the on local error resume next line because some controls namely menues will cause an error when this above code is used.  This line cause it to skip theses controls.
0
 
dvenkatAuthor Commented:
The problem still persists. The scrollbars also go hiding!

The issue is I paint the form at a size greater than the normal display size. (I expect the VB to automatically show a Scrool bar in this case, and evidently it does not).

Your code will not work in this case, because the scroll bar lie at a screen co-ordinate beyond normal display window size.

So please suggest me someother method or correct if I am wrong or misunderstood you.

Thanks

0
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.

 
clifABBCommented:
I will assume you are talking about scrollbars you have added to a child form.  In the form resize event of the child form add this code:
Private Sub Form_Resize()

  HScroll1.Move 0, Me.ScaleHeight - HScroll1.Height, Me.ScaleWidth - VScroll1.Width, HScroll1.Height

  VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight - HScroll1.Height

  HScroll1.ZOrder
  VScroll1.ZOrder
End Sub

This will keep your scrollbars visible and aligned to the bottom and right edges of the form.
0
 
dvenkatAuthor Commented:
Thanks "clifABB" and "clsmaster". It works!


0
 
clifABBCommented:
Glad to be of service.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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