Results 1 to 2 of 2

Thread: Creates a new form during run time, and copies objects over from an existing form.

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    Singapore
    Posts
    32

    Post

    Hi,
    Is it possible to
    Creates a new form during run time, and then copy objects over from an existing form onto the new form?
    Thanks.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    If you add an empty form to your project you can instanciate that form several times:

    Private Sub CreateForm()
    Dim frmNew As frmEmpty 'frmEmpty = the name of your empty form
    Set frmNew = New frmEmpty
    frmNew.Show
    End Sub

    You can MOVE controls from one form to an other using the SetParent API. There's a workaround here however if the control you want to copy is in a control array. Here's an example that moves a textbox from one form to the new when you click Command1:

    Private Declare Function SetParent _
    Lib "user32" ( _
    ByVal hWndChild As Long, _
    ByVal hWndNewParent As Long) As Long

    Private Sub Command1_Click()
    Dim frmNew As frmEmpty
    Dim iIndex%
    Set frmNew = New frmEmpty
    iIndex = Text1.Count
    Load Text1(iIndex)
    Text1(iIndex).Visible = True
    frmNew.Show

    Call SetParent(Text1(iIndex).hWnd, frmNew.hWnd)
    End Sub

    Good luck!



    [This message has been edited by Joacim Andersson (edited 12-16-1999).]

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