Results 1 to 4 of 4

Thread: MdiForms- Form positions

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Sydney
    Posts
    4

    Question

    I have placecd a picture box with buttons on it on a mdi parent form to act like a toolbar.

    However, whenever a load a child form the child form sits behind the picture box. How can I make the new child form sit on top of the picture box.

    (I have tried using 'send to back')

  2. #2
    Guest
    Ok, I took a few minute night dream (like a day dream) and I dreamed this and I think I got it.

    pecky (I have tried using 'send to back')
    This method is exactly like the Bring To Front and Send To Back item's listed on the menu. It is called ZOrder.

    Here is how it works:

    Code:
    Picture1.ZOrder vbSendToBack
    Childform1.ZOrder vbBringToFront
    Hope that works.




  3. #3
    New Member
    Join Date
    Aug 2000
    Location
    Italy
    Posts
    9
    The Picture box control limits the available area for the MDI Child form in the MDI parent Form, so a "Classic" MDI child can overlap the Picturebox.
    Using Windows API it is possible to modify the behaviour of MDI Child form; e.g. you can put a MDI Child in the Picture box using the SetParent API function:

    Here's the code :
    Code:
    In the MDIForm parent :
    
    Private Sub MDIForm_Load()
        Form1.Show
        DoEvents
    End Sub
    
    Private Sub MDIForm_Unload(Cancel As Integer)
        Unload Form1
    End Sub
    In the Child form:
    Code:
    Private Sub Form_Load()
    
        On Error Resume Next
        DockWindow  ' Without this, crash on exit due to SetParent in DockWindow??
    End Sub
    
    Public Sub DockWindow()
        On Error Resume Next
               
        ' Some kind of problem with the Picture1.hwnd
        Call SetParent(Me.hWnd, MDIForm1.Picture1.hWnd)
        DoEvents
    End Sub
    And naturally the bas module with API declaration :
    Code:
    Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,_
    ByVal hWndNewParent As Long) As Long
    Mil

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374
    Dear Mil,

    I tried tried this code and generally it worked well.

    However, I could not give text boxes on a docked form focus by clicking on them - only by tabbing. They were otherwise locked.

    I also found that VB (not my application) crashes from time to time whereas it wasn't before. This code is great for my application if I can get it to work perfectly.

    Any ideas why I might be having these problems?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width