1
votes

Im having some weird problems with Graphics and Bitmap.

I have a Graphics Object that is displayed on a PictureBox and im capturing the MouseMove and MouseClick Events that give X and Y Position of the Mouse on the Image but if the Y Position goes Bigger then 32775 it then goes into Negatives which means everything breaks. And if the Image is Bigger then 65535 it then stops displaying the Image.

Any Ideas how these problems can be fixed?

Thanks

Example Code:

http://pastebin.com/YEX0XD1q

Just Click Make 10,000 Bigger about 4 times then scroll down and on the right it will show the mouse X and Y position and as you move down through the image and hover over the Red Area if you go down enough it will go into Negative Y.

1
Are you PInvoking an API call to get the mouse position? In .Net, the MouseEventArgs parameter in the MouseMove event specifies X and Y as int, so you shouldn't be getting this short wraparound problem (I've never tried using a PictureBox this big myself). - MusiGenesis
@MusiGenesis Assuming that the full range is guaranteed through and through... - user166390
I just tried this myself, and the designer won't let me make a PictureBox's height or width larger than 32767. How are you doing this? - MusiGenesis
I have a PictureBox inside a Panel which AutoScrolls and i am changing the PictureBox.Image to a larger picture which makes the PictureBox Become larger inside the Panel. If you can understand that. - Dean
I can understand it, I'm just not able to duplicate it. When I put a PictureBox inside an AutoScroll Panel, I still can't make the PictureBox larger than 32767 (for height or width). I can create a larger Bitmap and assign it to the PictureBox's Image property, but that still won't make the control any larger than 32767. It would be helpful if you could post a code sample that illustrates your problem. - MusiGenesis

1 Answers

1
votes

By Researching i've managed to solve my problem

  1. Dont Use PictureBox inside Panel, Instead use ScrollableControl. This will fix the Problem where i couldn't make something bigger then 65K Height.
  2. Use GetVirtualMouseLocation to get Virtual Mouse Positions

I Just used what was posted here

The Above Works Perfectly.