I am having some troubles getting my mouse overs in the correct location when using scaletransform. I am using regions to check if the mouse is over a certain drawn image or text. It seems the way i have it now that the regions are scaling correctly, but they are to the left and right of where they should be at.
DesignWidth/Height is the width/height the screen/form is designed to be at, CurrentWidth/Height is the screen/forms current width/height
In Paint:
scaleX = CurrentWidth / DesignWidth
scaleY = CurrentHeight / DesignHeight
myGraphics.ScaleTransform(scaleX, scaleY)
Public Function HitTest(myObject as Object, x as point) as Boolean
Dim rect As New Rectangle(myObject.LocX * scaleX, myObject.LocY * scaleY, myObject.Width * scaleX, myObject.Height * scaleY)
If rect.Contains(x) Then return True
End Function
MouseMove calls HitTest()
I was reading about converting the Mouse Position to the Client Position, but only saw code for C, no VB code. I have tried compensating for the desktop location of the form, and that works until it is scaled to a different size, then the positioning is off again. Am I missing something that I should be compensating for?
Thanks,
liquid8
DesignWidth/Height is the width/height the screen/form is designed to be at, CurrentWidth/Height is the screen/forms current width/height
In Paint:
scaleX = CurrentWidth / DesignWidth
scaleY = CurrentHeight / DesignHeight
myGraphics.ScaleTransform(scaleX, scaleY)
Public Function HitTest(myObject as Object, x as point) as Boolean
Dim rect As New Rectangle(myObject.LocX * scaleX, myObject.LocY * scaleY, myObject.Width * scaleX, myObject.Height * scaleY)
If rect.Contains(x) Then return True
End Function
MouseMove calls HitTest()
I was reading about converting the Mouse Position to the Client Position, but only saw code for C, no VB code. I have tried compensating for the desktop location of the form, and that works until it is scaled to a different size, then the positioning is off again. Am I missing something that I should be compensating for?
Thanks,
liquid8