Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI scroll...child form position issue

Status
Not open for further replies.

ADPH

Programmer
Mar 14, 2008
8
US
I have a basic MDI form that loads maximized. It has two menu options. First option displays a MDI child form1 and the second option displays a MDI child form2. Both of these forms have no border and windowstate of normal. I want to be able to display form1, restore down MDI Parent form where scrollbars appear, scroll to the bottom and right, display form2 and have it display in the top left hand corner of the MDI parent form no matter where the scrollbars are at the time. Currently it seems to think the top left of the parent form is where ever the 'active', 'currently visible', window's top left is. Anybody with any experience with this issue, please let me know. VB 6 project.
 
Thought that a small sample project showing the problem might help get some dialog going. Thanks for your time.
 
<restore down MDI Parent form where scrollbars appear
I'm afraid I don't understand what this means. What's "restoring down"?
 
When a window is Maximized, there are usually three buttons in the top right corner...Close, Minimize, and Restore Down.
 
Oh, I see. I always called that just "restore," but sure enough, the tool tip text says "restore down." I'll see what I can find.
 
I understand. I was writing this post and I couldn't figure out what to call it, then I too saw the tooltip. May not get an answer to my problem, but I've learned something new today...lol

More info on my issue. I've learned that when scrolled, the top left position of...say form1, which was displayed when the MDI parent wasn't scrolled, goes into negative numbers, although not immediately.

See my uploaded project, if I uploaded it correctly. If you change the form2.top = 0 to form2.top = form1.top and the same with .left property, it doesn't work the first time you display form2, but if you click on form1 menu option and then again on form2, it displays form2 in the correct position.

Now if I can figure out how to get it there on the first press:)

I appreciate you looking into this with me!!!
 
Ok, I believe I understand what you're trying to do. This is a rough approximation of a solution:
Code:
Option Explicit
Public h As Long
Public w As Long

Private Sub MDIForm_Load()
With Me
    .Visible = False
    .WindowState = vbMaximized
    h = .ScaleHeight
    w = .ScaleWidth
    .WindowState = vbNormal
    .Visible = True
End With
End Sub

Private Sub mnuNew_Click()
Dim q As Form1
Set q = New Form1
Load q
q.Move Me.ScaleHeight - h, Me.ScaleWidth - w
End Sub
I only used one form for simplicity's sake. The basic idea is to capture the size of the maximized MDI form when you load it, then position the new form at negative xy coordinates relative to the downrestored form. You subtract the maximized MDI form's height and width from its current height and width, and use the resulting values as the negative coordinates at which to position your child form.

Of course, there's a good deal of tweaking to do (for example, when the user resizes the MDI form the size of the new child form will change too), but that's a basic course of action that should work for you.

HTH

Bob
 
Thanks Bob for your input and your time, but I don't think it hits the nail. In a nutshell here's what I need. I wanna use an MDI parent form and some MDI child forms. I want all my child forms to appear maximized, but if I truly maximize them, then when the user restores down the application there aren't any scrollbars. Therefore, I need the child forms to appear maximized yet still have scrollbars on the parent form when restored down. I say all this to say that I've accomplished everything above, although there's one issue remaining. When the application is restored down and the user opens another child form, the child forms position is off...ie it will not appear maximized when the user maximizes the application again. If you run the example code that you sent to me and create a new form when the application is restored down, then maximize the application, the child form does not appear in the upper left position, nor is it the approximate size of the parent form. Hope this clarifys the situation that I'm in. I could use help from anybody with any ideas. Thanks!!!!
 
For anybody that's interested in the solution to my example project, I've attached it. I don't want to take up too much room to explain it, cause it's not really what I would call a solution, more like a work around that works for me. Thanks Bob for the earlier help...got me thinking about some different ideas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top