Results 1 to 3 of 3

Thread: How do you create a sub form?

  1. #1
    Red Rush-In
    Guest

    How do you create a sub form?

    I am wanting to access a large number of forms from within a 'parent' form like in Access. There is a control that I have used that can load a form into itself by passing it the handle of the desired form.

    What are the API functions used to do this?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    2.  
    3. 'Insert the following code to your first form (named Form1):
    4.  
    5. Private Sub Form_Load()
    6. Load Form2
    7. Form2.Show
    8.  
    9. Private Sub Form_Load()
    10. 'Replace the 'Form1' below with the name of the 'Parent' Form
    11. Dim r As Long
    12. r = SetParent(Me.hWnd, Form1.hWnd)
    13. End Sub

  3. #3
    Red Rush-In
    Guest
    That works but now I'm having a few problems.

    I'm placing form2 inside a picture box. Whenever the picture box is resized I want the sub form to resize in order to fill the picture box. If I set form2 to vbMaximized it stays the size it was when it was loaded. If I resize form2 durring run time it disapears the second it is resized.

    I'm using this to implement an explorer style interface with the sub forms loadeding into the right pane.

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