|
-
Oct 10th, 2012, 09:08 AM
#1
Thread Starter
Member
[RESOLVED] mouse problems
I have a form in my program with FormBorderStyle: None. Its Size is 1245 x 662.
On my form I have a PictureBox control called picGame. The picGame control's SizeMode
attribute is StretchImage; the actual image size is 1384 x 768.
In my code, I have the following Sub:
Code:
Public Sub DrawBoard()
_gameGraph.DrawImage(My.Resources.Screen_Player, New Rectangle(0, 0, 1384, 768))
_gameGraph.DrawImage(My.Resources.Button, New Rectangle(652, 408, 100, 26))
RaiseEvent boardUpdated(_gameField)
End Sub
Public Event boardUpdated(ByVal bmp1 As Bitmap)
Private Sub gameUpdate(ByVal bit As Bitmap) Handles Me.boardUpdated
Me.StartPosition = FormStartPosition.CenterScreen
picGame.Image = bit
picGame.Refresh()
End Sub
The program "adds together" all the bitmaps drawn in the DrawBoard sub and then displays it as
a single image at runtime using the gameupdate Sub. This has worked well for me in the past,
placing images with transparency perfectly, and very quickly, and with no flicker. I've
written an entire Chess program and Reversi program using this method, so I know it works.
My problem is this:
In my the MouseMove Sub associated with the picGame control, none of the e.X and e.Y coordinates
match with the screen coordinates of the bitmaps I've drawn.
In other words, I've put the button at coordinates 652, 408; this is where it looks good to me
on the screen. However, when I move the mouse, the actual location of 652, 408 -- according to
e.X and e.y is about 50 pixels off to the right and down. To add to the confusion, not every
control is off by the same amount. I mean, if they were ALL off by the same number of pixels,
then adjusting things would be easy; but, no, there's something weird going on here.
With Chess and Reversi, all the pieces are in very, very predictable positions. Yes, I
did have to adjust the clicking for each column and row, but it was no big deal... until now.
I'm not sure why this is, nor how to correct it, so that I don't have to do a 'special case'
scenario for each control I've drawn on the screen. Any ideas?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|