Results 1 to 5 of 5

Thread: can i use the same frame to display multiple forms?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    81

    can i use the same frame to display multiple forms?

    What I would like to do is setup a menu system, so for the main form you will have a top navigation linking to different forms, but instead of loading a new form, I would like it if all info from that form would display in a frame, is this possible?

    So if I have 3 button on my main page, button 1 links to form2, button 2 links to form 3, button 3 links to form 4 etc, so if I click button 1 form 2 will be displayed in the frame and so on.

  2. #2

  3. #3
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    294

    Re: can i use the same frame to display multiple forms?

    Could you copy and paste the controls/code from the other forms onto 3 different pictureboxes on the main form, then when the buttons are clicked just set the visible property of the picturebox to true to show it.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    81

    Re: can i use the same frame to display multiple forms?

    Quote Originally Posted by MartinLiss
    Do you want to show more than one form in the frame at the same time?
    no just one form at one time

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: can i use the same frame to display multiple forms?

    Code:
    Option Explicit
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    
    Private Sub Command1_Click()
    UnloadOtherForms
    Form2.Show
    SetParent Form2.hWnd, Frame1.hWnd
    
    End Sub
    
    
    Private Sub Command2_Click()
    UnloadOtherForms
    Form3.Show
    SetParent Form3.hWnd, Frame1.hWnd
    
    End Sub
    
    Public Sub UnloadOtherForms()
        Dim frm As Form
        
        For Each frm In Forms
            If frm.Name <> "Form1" Then
                Unload frm
                Set frm = Nothing
            End If
        Next
        
    End Sub

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