Solved

The ScrollBar of the MDI From ???

Posted on 2002-07-15
13
397 Views
Last Modified: 2008-03-10
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
Comment
Question by:turquito
  • 5
  • 4
  • 2
  • +2
13 Comments
 

Expert Comment

by:wensinkg
ID: 7156932
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
 
LVL 3

Accepted Solution

by:
schworak earned 150 total points
ID: 7158268
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
 

Expert Comment

by:wensinkg
ID: 7158451
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
 

Author Comment

by:turquito
ID: 7172676
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
 
LVL 3

Expert Comment

by:schworak
ID: 7172790
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
 
LVL 3

Expert Comment

by:schworak
ID: 7172792
Please reject wensinkg's answer as it will not work.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Expert Comment

by:wensinkg
ID: 7172804
If it wasn't clear before I ADMIT MY MISTAKE!
0
 
LVL 3

Expert Comment

by:schworak
ID: 7173045
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
 

Expert Comment

by:wensinkg
ID: 7173184
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
 

Author Comment

by:turquito
ID: 7194845
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
 
LVL 3

Expert Comment

by:schworak
ID: 7194915
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 8012467
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
 
LVL 1

Expert Comment

by:Computer101
ID: 8095545
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now