CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 1999
    Posts
    6

    dynamically creating a dialog

    Is it possibel to create a dialog at runtime.
    More precise, can I create an control, like a
    button, listbox, etc. , and place it on a
    form at runtime?

    thank´s hannes

    [email protected]


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: dynamically creating a dialog

    Prior to VB.Net you can only create a control by loading an instance of an existing control array.

    For example, suppose you want a form with 20 buttons on it - you create a form with 1 button on it and set it's Index property to zero.
    Then to load the others dynamically:

    private Sub Form_Load()

    Dim lIndex as Long

    for lIndex = 1 to 10
    Load Command1
    command1(lindex).Caption = "Button " & lindex
    command1(lIndex).Left = (Comman1(lIndex-1).Left + Command1(lIndex).width)
    Command1(lIndex).Visible = true
    next lIndex

    End Sub




    In VB.Net you can just create new controls willy-nilly at run time....(If you can keep the IDE running long enough so to do)

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: dynamically creating a dialog

    There is a way to create a single control at run time. Unfortunately, you can't ceate control arrays using this method with VB6.0 and earlier.
    There are simulated control array creation methods available. There is an example of Collection of class Objects posted on this forum By Cesare Cimperiali that performs this magic
    http://63.236.73.79/cgi-bin/bbs/wt/s...age=5&Limit=25

    John G

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

Featured