Results 1 to 6 of 6

Thread: Bubble machine

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    25

    Bubble machine

    Hello! I am making a program that when I press the start button on the form, objects start at the bottom of the panel and float up to the top. When the objects reach the top then they are supposed to pop. I already have objects in my bin - debug folder to use. I am just not certain at where to start or how to create this object in code. I would really appreciate any help. This is a homework assignment, and I am only in a beginning Visual Basic class.
    Attached Files Attached Files
    Last edited by Joacim Andersson; May 4th, 2013 at 10:10 PM. Reason: Removed binaries from ZIP file

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Bubble machine

    I can't speak for everyone but I'm sure that there are a number of like-minded people here. Personally, I will never download, extract, open and then peruse a project with no specific idea of what I'm looking for as a first option. The first option should always be your providing a full and clear description of exactly what the issue is and just the relevant code right in your post, so that we don't have to go anywhere or do anything extra to see all the information we need. If we need the full code then we can ask for it but going that way first up tends to mean less work for you but more work for us. You may still get the help you want with your post as is but you have more chance if you make the effort to make it easier for us by providing all that is important and filtering out all that isn't.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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

    Re: Bubble machine

    Binaries removed from attachment. PNG (and other possible resource) files and pure code files remaining.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    25

    Re: Bubble machine

    I am sorry. I am making a project that makes bubbles appear in a panel. When they get to the top they need to pop. I have "png" files for the balloons. I am having trouble with the code to create the balloons from the "png" file.

    Dim myPNG As New Image("Andy.png", "NoAndy.png")
    Graphics.DrawImage(myPNG, 150, 200)

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Bubble machine

    Graphics.DrawImage(myPNG, 150, 200)
    Again you've left us with very little to go on but looking at this line I'm guessing that the problem is that you are not nominating the drawing surface. All graphics are drawn 'on' a specific surface. You mentioned a panel so for Panel P1 ....

    vb.net Code:
    1. ' create graphics object associated with the panel
    2.         Dim g As Graphics = Graphics.FromHwnd(P1.Handle)
    3. ' then draw to the panel
    4.          g.DrawImage(myPNG, 150, 200)
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Bubble machine

    Firstly, you need to create the Image objects correctly. I would suggest declaring a member variable for each one and calling Image.FromFile once for each one. You can reuse those Image objects as many times as you like.

    As for drawing those Images on the form, unless you have a very good reason not to, you should draw on a PictureBox in preference to any other control because it is already optimised for GDI+ drawing.

    Dunfiddlin is quite correct about the fact that you need to get a Graphics object from the control you want to draw but incorrect about how to get it. If you want to draw on a control then handle that control's Paint event and do all your drawing in that event handler. It provides a Graphics object already and avoids issues like your drawing disappearing at inconvenient times. Follow the CodeBank link in my signature and check out my threads on Drawing for examples.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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