• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

The ScrollBar of the MDI From ???

I have a MDI Form (main) and the other form are very large an the have many controls. When i open this form of course put visible the scrollbar both.

My question is:

How i can manipulate this scrollbar when the control focus get out of the view limits without the the operator move the scrollbar manually ?.
0
turquito
Asked:
turquito
  • 5
  • 4
  • 2
  • +2
1 Solution
 
wensinkgCommented:
You might want to set the WindowState property on the child to vbMaximize.  This will "merge" the forms together and allow the MDI form to act like a window for the child.  It will also allow your user to tab between fields that are on the child and move the viewable area along with the field.
0
 
schworakCommented:
That won't work because once the inner form is maximized the scroll bars are removed from the MDI form.


If you really must control the scrollers of the MDI form I fear you may have to do some API calls.

There are a couple other solutions. You could put all your controls on a picture box within a form and keep the location of the current control within view by moving the picture box. I have done this on a couple projects.

Another way would also require a single API call to the SetParent function to take your existing form and make it a child of a picture box. You then move the picture box as described above and the form will follow and be inside the picture box. That isn't all that great though.
0
 
wensinkgCommented:
well, shows you how much there is to know about programming.  Even in Basic.  I usually don't attempt to put all of the controls on the same form unless I have to and then I use a tab control to separate them if I have to.  Thx, schworak.  You learn something new every day.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
turquitoAuthor Commented:
Well, may i didn´t more clear on my question, I will try to be specific.

I have a MAIN FORM ( MDIForm ), and the Form Child are more Width and Heigth that the Main Form, of course the Main Form put Visible the Scroll Bar ( H - V Scroll), I want manipulate this Scroll when the cursor move througth the From Child, something that the Web Page...
0
 
schworakCommented:
Here is an experiment to try. This may be what you are looking for....


Create a project.

1) MDIForm1 (your MDI form)
2) Form1 (your editable form)
   a) Place several text box controls on the form
   b) Each named Text1 (this is a control array)
   c) Space them out around the form as you like
3) Add the following code to Form1
4) Run the program making sure both forms load
5) Make sure the MDI form is smaller than Form1
6) Tab from text box to text box.
(not perfect but with a little adjusting to your own needs this should be about what you are after)


Option Explicit

Private Const SM_CYCAPTION = 4
Private Const SM_CXFRAME = 32
Private Const SM_CXHSCROLL = 21
Private Const SM_CYHSCROLL = 3
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Private Sub Text1_GotFocus(Index As Integer)
    Dim t As Long   ' Top
    Dim l As Long   ' Left
    Dim b As Long   ' Bottom
    Dim r As Long   ' Right
    Dim VW As Long  ' Viewable Width
    Dim VH As Long  ' Viewable Height
   
    VW = MDIForm1.ScaleWidth - GetSystemMetrics(SM_CXHSCROLL) * Screen.TwipsPerPixelX
    VH = MDIForm1.ScaleHeight - GetSystemMetrics(SM_CYHSCROLL) * Screen.TwipsPerPixelX
    l = Text1(Index).Left + Me.Left + GetSystemMetrics(SM_CXFRAME) * Screen.TwipsPerPixelX
    t = Text1(Index).Top + Me.Top + GetSystemMetrics(SM_CYCAPTION) * Screen.TwipsPerPixelX
    r = l + Text1(Index).Width
    b = t + Text1(Index).Height
    If l < 0 Then Me.Left = Me.Left - l
    If t < 0 Then Me.Top = Me.Top - t
    If r > VW Then Me.Left = Me.Left + VW - r
    If b > VH Then Me.Top = Me.Top + VH - t
End Sub
0
 
schworakCommented:
Please reject wensinkg's answer as it will not work.
0
 
wensinkgCommented:
If it wasn't clear before I ADMIT MY MISTAKE!
0
 
schworakCommented:
Wensinkg:

Sorry, the request to reject your answer wasn't an attack at you. The idea not working was an honist mistake. It even sounded good to me until I tried it.

I just wanted to get this question out of the LOCKED state that it is in at the moment.

Hope I didn't hurt any feelings, that wasn't my intension. Guess I should have explained a little more when I made the request myself.
0
 
wensinkgCommented:
That's OK.  I shouldn't have reacted so badly.  There are a lot of reasons that I can't go into here but... well you know, I'm sure.  The worst is that I am a MCP in Visual Basic and it is clear by the response from the requestor I didn't really understand what was needed.  I learn from my experiences and I now don't just jump in with an answer without asking for clarification when needed.  Thanks for understanding.
0
 
turquitoAuthor Commented:
mybe i was not clear on my question, i try explain again...

I have a MDIFrom how principal form, i need input many information and i divide this on several form (child), but i have some form(child) that are very large an activate the MDIform Scroll's, my question is :

If i have code on every textbox, when i pulse Enter the focus change on other textbox and sometimes this focus getout the view and i have pulse on the scroll...

I want that this form(child) can move how to do a Web Page, HOW I CAN DO THAT ????
0
 
schworakCommented:
Turguito, let me restate what you are looking for just so I can be sure I understand what you are trying to do. Correct me if I have this wrong.

1. You have form A which is your MDI form
2. You have form B which is larger than form A
3. You want the text box on form B to be visible on the screen when the user enteres (gets focus) on it.


I don't understand where the reference to WEB PAGE comes fromin your last comment unless you mean you want it to scroll up/down like a web page does when you move from field to field.

If the above assumptions are correct, the example I gave you will do exactly what you are asking.



If you want a single scroller on the side of the window and your form to fill all of the MDI form, you are not going to be able to make that work ever. Sorry. You would need to use another method more like placing a picture box on a form with a scroller and then putting your controls within that picture box. You can then scroll the picture box up/down.

When an MDI form has a child form maximized, the scrollers are gone. Always. The form must be of normal size in order for it to use the scroller bars.


Does this help any?
0
 
DanRollinsCommented:
Hi turquito,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept schworak's comment(s) as an answer.

turquito, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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