Solved

how to show scrollbars for MDI child form

Posted on 1998-04-27
6
905 Views
Last Modified: 2008-02-01
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
Comment
Question by:dvenkat
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1431269
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
 

Accepted Solution

by:
clsmaster earned 30 total points
ID: 1431270
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
 

Author Comment

by:dvenkat
ID: 1431271
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
Industry Leaders: 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 6

Expert Comment

by:clifABB
ID: 1431272
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
 

Author Comment

by:dvenkat
ID: 1431273
Thanks "clifABB" and "clsmaster". It works!


0
 
LVL 6

Expert Comment

by:clifABB
ID: 1431274
Glad to be of service.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

740 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