mouse position

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by crown.

does someone know how to read the mouse position
when the mouse is on the desktop ?

maybe it is very simple , but i'm a biginner :wink:

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by crown

does someone know how to read the mouse position
when the mouse is on the desktop ?

maybe it is very simple , but i'm a biginner :wink:
I think that you have to use the WIN API at this time to get the position. Something like this:

GetCursorPos_(@Coordinate.POINT)
xpos = Coordinate\x ; x pos of mouse cursorypos = Coordinate\y ; y pos of mouse cursor
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> does someone know how to read the mouse position

If your app is just for Windows (and not Amiga/Linux), you can do this:

GetCursorPos_(mouse.POINT) : x=mouse\x : y=mouse\y

The variables x and y will then hold the current co-ordinates.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

Dammit Pupil -- you beat my post by 2 seconds!
At least the answers come thick and fast here!


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by crown.

thanks for the fast reply guys....

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by PB

Dammit Pupil -- you beat my post by 2 seconds!
At least the answers come thick and fast here!
I'll let you win next time :wink:
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

No API needed herer, guys...

x = WindowX() + WindowMouseX()
y = WindowY() + WindowMouseY()

Works fine...

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> x = WindowX() + WindowMouseX()
> y = WindowY() + WindowMouseY()
> Works fine...

Only works if your app actually has a window. :)


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

OpenWindow(0, 0, 0, 0, 0, #PB_Window_Invisible, "")

:)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> OpenWindow(0, 0, 0, 0, 0, #PB_Window_Invisible, "")

Yeah I know. :) And it's a good way to ensure your app works with the
Amiga/Linux versions of PureBasic too. But if you're just coding for
Windows, then using the API will save you both memory and exe size:

Code: Select all

; Creates exe size of 12,320 bytes.
OpenConsole()
OpenWindow(0,0,0,0,0,#PB_Window_Invisible,"")
x=WindowX()+WindowMouseX() : y=WindowY()+WindowMouseY()
PrintN(Str(x)) : PrintN(Str(y)) : Input() : End
;
; Creates exe size of 7,200 bytes.
OpenConsole()
GetCursorPos_(mouse.POINT) : x=mouse\x : y=mouse\y
PrintN(Str(x)) : PrintN(Str(y)) : Input() : End
PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

I will really split the window library to put a final word over API vs PB functions :)

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

You cant. We could use 5k Dialogs without your big
event-handler.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Danilo: you're challenging me :). Let's see If I can do a 5 ko app with a window and a gadget...

Fred - AlphaSND
Post Reply