liquid8 Posted March 12, 2003 Posted March 12, 2003 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 Quote
*Gurus* divil Posted March 12, 2003 *Gurus* Posted March 12, 2003 You can get a Point structure of the mouse pointer's position relative to the upper-left corner of any control using this method: myPoint = myControl.PointToClient(Cursor.Position) That might help you get further, but you'll still have to adjust for your scaletransform I guess. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
liquid8 Posted March 13, 2003 Author Posted March 13, 2003 Worked perfectly... thanks divil! :) I knew that function had to be in there somewhere.. liquid8 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.