Results 1 to 6 of 6

Thread: Working with images

  1. #1

    Thread Starter
    Hyperactive Member New to VB 6's Avatar
    Join Date
    Apr 2002
    Posts
    362

    Question Working with images

    I'm not sure how to say this, so bare with me...

    I would to know how to use the same image over and over.
    By this I mean use the same image mutiple times kind of like the old sim city game, where you could click on a building and place it some where in the city and then click the building again and get another building to place in the city.

    i.e I click a button and I get a new image that I can move.

    I know how to move images around on a form, so that's not the problem. what I need to know is how to get "image1, ...2, ...3, ...4, etc. out of image(0) or image(i)
    [VBCODE]
    Option Explicit
    Dim XXX As Porn
    Dim Wife As Nag

    Private Sub *****_Resize()
    On Error Resume Next
    Get Viagra
    End Sub
    [/VBCODE]

  2. #2
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Use a PictureBox Array and keep loading a new instance of teh control.

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  3. #3
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Something like this..maybe
    VB Code:
    1. Dim blnFlag As Boolean
    2. Private Sub Form_Load()
    3.     Picture1(0).Picture = LoadPicture("C:\windows\circles.bmp")
    4.     Picture1(0).AutoSize = True
    5.     Picture1(0).ScaleMode = Me.ScaleMode
    6. End Sub
    7.  
    8.  
    9. Private Sub Picture1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    10.     Load Picture1(Picture1.UBound + 1)
    11.     Picture1(Picture1.UBound).Visible = True
    12.     blnFlag = True
    13. End Sub
    14.  
    15. Private Sub Picture1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    16. If blnFlag Then
    17.     Picture1(Picture1.UBound).Move X, Y
    18. End If
    19. End Sub
    20.  
    21. Private Sub Picture1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    22. If blnFlag Then
    23.     Picture1(Picture1.UBound).Left = X
    24.     Picture1(Picture1.UBound).Top = Y
    25.     blnFlag = False
    26. End If
    27. End Sub

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  4. #4

    Thread Starter
    Hyperactive Member New to VB 6's Avatar
    Join Date
    Apr 2002
    Posts
    362
    it says the the UBound data member isn't found...
    [VBCODE]
    Option Explicit
    Dim XXX As Porn
    Dim Wife As Nag

    Private Sub *****_Resize()
    On Error Resume Next
    Get Viagra
    End Sub
    [/VBCODE]

  5. #5
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    In teh properties of teh PictureBox, set its index to "0" (zero). That will convert the PictuerBox into an array of PictureBoxes with the same name.

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  6. #6

    Thread Starter
    Hyperactive Member New to VB 6's Avatar
    Join Date
    Apr 2002
    Posts
    362
    maybe I should have said that I want to produce new images like the way VB controls are produced.

    Click the button of the tool you want and draw the image size on the form and the image appears. except I want to do this during runtime and without a control.

    Or better yet can the code you provided be adapted so that when I click on a Command button the image appears in a specific location so that I can move it later?

    or even can it be made so that the image a named as image1, image2, image3, etc, or something like that?

    I need to use the name in a label for instructions
    i.e. when the user clicks on the image the label reads
    move (item name).

    I know how to do these things:
    1.) move thing
    2.) display the text in a label
    3.) various other things

    I don't know how to:
    1.) make new images, buttons, shapes, etc. on the fly
    [VBCODE]
    Option Explicit
    Dim XXX As Porn
    Dim Wife As Nag

    Private Sub *****_Resize()
    On Error Resume Next
    Get Viagra
    End Sub
    [/VBCODE]

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