I have a picturebox control in a groupbox control on a VB winform app I'm developing under VS2010. I use the designer to add a MouseClick() event as you would normally. In my code I create a bitmap thus:
Dim bmSource As Bitmap = New Bitmap(nWidth, nHeight,System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
(sorry about the Hungarian notation!) and then create another bitmap which will be rendered into the above bitmap:
Dim bmSprite As New Bitmap(48, 42, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
Dim g As Graphics = Graphics.FromImage(bmSource) g.DrawImage(bmSprite, nXPos * 48, nYPos * 42)
and assign it to the picturebox control:
pbSprites.Image = bmSource
So far so good, I see the small bitmap in the large one when I start the app. The problem is the MouseClick() event is only ever triggered when I click outside
the smaller bitmap but still inside the other one. bmSprite is about a third of the size of bmSource.
Note that bmSource is also a drag and drop source, but that doesn't seem to be the problem as it still doesn't work when I remove the drag and drop code. Also, If I load a bitmap into pbSprite, rather than creating one in memory, it works OK. Why would creating the bitmap like this cause a problem?