Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

VB
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:
VB
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:
VB
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?

Thanks!
Posted
Updated 1-Nov-19 10:45am

Well, it beats me. I added another control, hooked it up and deleted the old control and it worked fine. You live and learn....
 
Share this answer
 
Same problem, same mysterious solution in VS 2019 - add a new control and it fires events OK
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900