Solved

how to show scrollbars for MDI child form

Posted on 1998-04-27
6
850 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

770 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