lonlon_malon

Hi there,

I am trying to make a picturebox move over another in a program - one, a stationary red arrow, the other a moving green arrow. When the green arrow picture box moves over the red, you can clearly see that the green picturebox is only *pretending* to be transparent; you can see that the green picturebox is filling the empty spaces with the form's colour, and that box moving over the arrow beneath it. Basically, it looks fairly unprofessional.

Is there some way to fix this, so that you *only* see the green arrow moving over the red, and not the form's foreground colour with it

I hope that made sense; please let me know if I need to clarify.


Re: Visual Basic Express Edition Of Pictureboxes, Transparency, Movement and Backgrounds

lonlon_malon

Alright, I have found a partial solution to my problem. I have put the red arrows into the background of the form, and so the green arrows don't have that "boxy" problem anymore. HOWEVER, the program now moves really, really slowly.

Is there some sort of solution for this




Re: Visual Basic Express Edition Of Pictureboxes, Transparency, Movement and Backgrounds

nobugz

Not sure how that solved your problem. However, you'd typically want to do this by directly painting the arrows rather than using picture boxes. Check this thread...





Re: Visual Basic Express Edition Of Pictureboxes, Transparency, Movement and Backgrounds

Bruno Yu - MSFT

lonlon_malon,

Have you read the post titled Image Background Removal with the link: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1016243&SiteID=1

I think it helps. As nobugz said: You can do it with the Bitmap.MakeTransparent() method. I added a bitmap to the resources, named SampleBitmap, with a white background and added a panel to the form:

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim bmp As Bitmap = My.Resources.SampleBitmap
bmp.MakeTransparent(Color.White)
e.Graphics.DrawImage(bmp, New Rectangle(0, 0, Panel1.Width, Panel1.Height))
End Sub

There are lots of ways to tweak this code; in this example, I stretch the image to fit the panel. You can use other overloads of Graphics.DrawImage() to display it just the way you want it...

Hope that your problem has been solved :-)