Results 1 to 8 of 8

Thread: [RESOLVED] Loading Container array with controls

  1. #1

    Thread Starter
    Lively Member CADman's Avatar
    Join Date
    Aug 2007
    Posts
    92

    Resolved [RESOLVED] Loading Container array with controls

    I want to programatically load a container (frame) that will have other controls such as labels, textboxes and an image. When I load the frame(x) the controls do not seem to appear. I am making them visible. How to put them into the newly made frame?

    Cadman
    Edit: using VB 6.0
    Edit: this is for a game
    Last edited by CADman; Jan 29th, 2009 at 03:22 PM.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: Loading Container array with controls

    Without seeing your code, it is hard to tell what is wrong with it.

    At a guess, I would assume you are missing a line like this:
    Code:
    Set ChildControl.Container = ContainerControl

  3. #3
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Loading Container array with controls

    Or a call to the SetParent API, depending on your language of choice.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  4. #4

    Thread Starter
    Lively Member CADman's Avatar
    Join Date
    Aug 2007
    Posts
    92

    Re: Loading Container array with controls

    At runtime I create a frame and add a few controls into it, all index 0.
    Can I then:
    load frame1(#)
    load frame1(#).container.text1(#) ?

    or do I:
    dim ChildControl as control
    for loop here
    Set ChildControl.Container = frame1(#)
    load ChildControl.Container.container.text1(#) ?
    next

    Cadman

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Loading Container array with controls

    Load the frame first & modify its properties as needed

    Load each child control
    Set ChildControl.Container = Frame1(n)
    Set/Adjust child control properties (visible, left, top, etc)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Lively Member CADman's Avatar
    Join Date
    Aug 2007
    Posts
    92

    Re: Loading Container array with controls

    Option Explicit
    Dim ChildControl As Control '<--- or should be 'as container'?

    private sub form_load()
    me.show
    dim I as integer
    for I=1 to 3
    Load Frame1(I)
    FraFrame1I).Visible = 1 'should use True instead but I like positive True's
    Frame1(I).Left = FraFrame1I - 1).Left + 2000
    Set ChildControl.Container = Frame1(I) '<--- error here
    Load ChildControl.Container.label1(I)
    ChildControl.Container.label1(I).Left = 200
    ChildControl.Container.label1(I).Visible = 1
    Next
    End Sub

    Edit: I have already created the frame and label as index 0
    error 91: Obj var or With block var not set
    Last edited by CADman; Jan 30th, 2009 at 10:18 AM.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Loading Container array with controls

    Try this and modify it as needed
    Code:
    For I = 1 To 3
       Load Frame(i)
       Frame(i).Visible = True
       Frame(i).Left = Frame(i-1).Left + 200
    
       Load Label1(UBound(Label1)+1)
       Set Label1(UBound(Label1)).Container = Frame(i)
       With Label1(Ubound(Label1))
             .Left = 200 + xxxx ' each needs to be offset on Left/Top
             .Top = xxxx          ' else they will overlap each other
             . Caption = "something"
             .Visible = True
        End With
    Next
    Last edited by LaVolpe; Jan 30th, 2009 at 10:59 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Lively Member CADman's Avatar
    Join Date
    Aug 2007
    Posts
    92

    Re: Loading Container array with controls

    Bingo! You guys are great. I have many games that use arrays of
    containers with controls and I've always had to create them at design
    time...until now. So we load the child control first and then assign its
    container. Thanks a lot. Cadman

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