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.
Last edited by Joacim Andersson; May 4th, 2013 at 10:10 PM.
Reason: Removed binaries from ZIP file
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.
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)
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:
' create graphics object associated with the panel
Dim g As Graphics = Graphics.FromHwnd(P1.Handle)
' then draw to the panel
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!
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.