Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to show scrollbars for MDI child form

Posted on 1998-04-27
6
Medium Priority
?
1,051 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 120 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 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