I would like to add a number of identically sized transparent images to a PictureBox, and control the stacking-order in which they are displayed.
Dim objGraphics As Graphics
Dim imgBAC As Image = Bitmap.FromFile("C:\bac.gif")
Dim imgITU As Image = Bitmap.FromFile("C:\itu.gif")
Dim imgNAM As Image = Bitmap.FromFile("C:\nam.gif")
Public Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
PictureBox1.BackgroundImage = imgBAC
objGraphics = e.Graphics
objGraphics.DrawImage(imgITU, New Rectangle(0, 0, imgITU.Width, imgITU.Height))
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = imgNAM
End Sub
When this is run, the image 'imgBAC' is correctly drawn as the background of the scene, and the image 'imgITU' is drawn on top of it.
When the button is clicked, it adds the image 'imgNAM', but places it between the other two, rather than on top of the two. How to change this?
Now imagine I had, say, 5 images. I would like to learn how to dictate the stacking order of images when they are loaded (i.e. 1,2,5,4,3). I would also like to know if, after the images had been loaded, I can then turn one off to leave (1,2,4,3) or change the position of one image in the stack (2,1,4,3).
Thanks in advance for your help, Tim.
Aucun commentaire:
Enregistrer un commentaire