[Gambas-user] How to make Mouse.Screen think that a form is 1024x768 or that the form is the screen?
Benoit Minisini
gambas at ...1...
Sat Aug 27 16:56:28 CEST 2005
On Thursday 25 August 2005 15:11, Steve Starr wrote:
> PUBLIC SUB Button1_MouseMove()
>
> Button1.Y = Mouse.ScreenY
> Button1.X = Mouse.ScreenX
>
> TextBox1.Text = Mouse.ScreenY
> TextBox2.Text = Mouse.ScreenX
>
> End
>
> When i drag Button1 all the way to the left TextBox2.Text will display
> 0 now if i drag Button1 all the way to the right wich goes beyond my
> form TextBox2.Text will display 1024 well this is the width of my
> screen how could i if possable
> make Mouse.ScreenX think that just my form is 1024 instead of my screen?
> Same deal with Mouse.ScreenY if i drag Button1 to the top of my form
> TextBox1.Text displays 0 but if i drag to the bottum button1 goes
> beyond my form and TextBox1.Text displays 768 now this woudnt be a
> problem if my form was full screened but that isnt practical.
>
>
> If you need my source to see what i mean just ask and ill email it.
> Thanks
>
I don't really understand all, but anyway try:
PUBLIC SUB Button1_MouseMove()
' ScreenX/Y is the absolute screen coordinate.
' X/Y is relative to the parent.
' ClientX/Y is the shift between the top of the container and its inner.
Button1.Y = Mouse.ScreenY - (Button1.Parent.ScreenX +
Button1.Parent.ClientX)
Button1.X = Mouse.ScreenX - (Button1.Parent.ScreenY +
Button1.Parent.ClientY)
END
When dealing with coordinates, things must be 'homogeneous'.
There are two kind of coordinates: relative coordinates (X, Y, ClientX,
ClientY) and screen coordinates (ScreenX, ScreenY). When you substract two
screen coordinates, or two relative coordinates, you get a relative
coordinate.
So your inital formula couldn't work: you assigned screen coordinates to
relative ones.
Mine may work, as I substract two screen coordinates, and substract a relative
one again.
I forgot to told you one recommandation if my last private email to you: use
indentation! Or you won't be able to read your code in two months!
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list