Results 1 to 4 of 4

Thread: Dynamic Control Creation???

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Dynamic Control Creation???

    Hi all, I am making a tile based game, where various objects (picture boxes) move around the screen. All was well untill i tried to run my game our school computers. They are very slow, and the game played terribly.

    To get around this i made all my pictureboxes into shapes, and removed all lines with .picture in them. This is a really annoying as on most computers the game runs perfectly, and the shapes just make it look lame.


    What i want to know, is how can i have a messagebox appear, which asks the user if they want the pictures or not, and then create either a picturebox or a shape object, which the rest of my code will reference correctly.


    This is what i have tried so far...

    Dim Bang(1000) As Object ' don't know how to use dynamic arrays yet

    ~~~
    form1_load()

    a = MsgBox("Do you want to use pictures?", vbYesNo + vbQuestion, "Pictures")
    If a = vbYes Then
    UsePictures = True
    Else
    UsePictures = False
    End If

    If UsePictures = True Then
    Bang(0) = frmDocument.Controls.Add("vb.picturebox", "Bang", frmDocument)
    else
    Bang(0) = frmDocument.Controls.Add("vb.shape", "Bang", frmDocument)




    Any help would be much appreciated.

    ___
    SLH

  2. #2
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    first, put a picture box on the form.
    then set its index to 0.
    finally, use this code:

    Load picTest(1)
    with picTest(1)
    .top=0
    .left=0
    .height=1000
    .width=1000
    .picture=whatever
    .visible=true
    end with

    this will load a second picture box and set its properties. put it in a loop for more boxes.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  3. #3
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    oh yeah, i forgot to say that the pic box on the form should be named picTest as well, but with an index of 0 instead of 1.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  4. #4

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks for the help, but i have tried to use the method you discribed, but as i want the object type to vary (a picturebox, or a shape), while the name remains constant, i cannot just put one object on the form as an array and duplicate it.

    I want to, using a variable, at runtime either create a shape, or picturebox. I have referenced it using a pre-set name, so i want the created object to have that name (regardless of it's type).

    -Hope that made sense.

    Once again thanks in advance

    ___
    SLH

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