I have a picturebox over a picturebox. pb1 is a png file. I filled the image with a solid color and cut out a square for the transparent region. pb2 is under pb1 and I load an image into pb2. The object is to move the pb2 around under pb1. The problem is that when I set pb1's parent to = pb2, they seem to fuse together, so if I move pb2, pb1 moves. Can this be done?
Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Parent = PictureBoxClipper Me.KeyPreview = True End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Clear the default name OpenFileDialog1.FileName = "" 'Set the Filter. OpenFileDialog1.Filter = "All Image Types|*.bmp;*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff|BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff" Me.OpenFileDialog1.ShowDialog() Me.PictureBoxZoom.ImageLocation = Me.OpenFileDialog1.FileName() PictureBoxClipper.Parent = PictureBoxZoom Me.PictureBoxZoom.Show() End Sub Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown Select Case e.KeyCode Case Keys.Left Me.PictureBoxZoom.Left -= 1 Case Keys.Up Me.PictureBoxZoom.Top -= 1 Case Keys.Right Me.PictureBoxZoom.Left += 1 Case Keys.Down Me.PictureBoxZoom.Top += 1 End Select End Sub Private Sub Button1_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles Button1.PreviewKeyDown Select Case e.KeyCode Case Keys.Left, Keys.Up, Keys.Right, Keys.Down e.IsInputKey = True End Select End Sub End Class




Reply With Quote
