Author |
Topic: Mouse event on redraw (Read 116 times) |
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Mouse event on redraw
« Thread started on: Feb 9th, 2018, 2:32pm » |
|
One small anomaly between Windows XP and subsequent versions I have noticed is that under XP, if my program closes a graphics window and then reopens it, I get an automatic mouse move event occur. However, under subsequent versions of Windows this event does not occur.
This is actually beneficial to my program so I was wondering if I can get the mouse coordinates using a dll call after reopening the window without having to wait for an actual mouse event?
I should add that my program is closing and reopening the window on a keyboard event.
So the new window might be a different size or location to the first window and I need to know the position of the mouse pointer relative to the new window even though the mouse hasn't moved and triggered an event.
I could derive it automatically from the movement of the window if there is no direct way.
|
« Last Edit: Feb 9th, 2018, 2:47pm by Monkfish » |
Logged
|
|
|
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
Re: Mouse event on redraw
« Reply #1 on: Feb 9th, 2018, 5:13pm » |
|
GetCursorPos function ?
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Mouse event on redraw
« Reply #2 on: Feb 9th, 2018, 5:58pm » |
|
The mouse may not even be inside the window when it opens? Surely the user has to take some action first?
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Mouse event on redraw
« Reply #3 on: Feb 9th, 2018, 7:44pm » |
|
on Feb 9th, 2018, 5:13pm, tsh73 wrote: Yes, GetCursorPos followed by ScreenToClient typically.
Richard.
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Mouse event on redraw
« Reply #4 on: Feb 10th, 2018, 08:50am » |
|
Code:
'open a window and graphicbox
WindowHeight = 300
WindowWidth = 400
graphicbox #w.g, 0, 0, 400, 300
open "test" for window_nf as #w
print #w, "trapclose [quit]"
#w.g "setfocus"
hw = hWnd(#w.g)
struct MouseRect ,mx as long,my as long
calldll #user32, "GetCursorPos",MouseRect As struct,re As Long
calldll #user32, "ScreenToClient",hw As ulong,MouseRect As struct,re as long
print MouseRect.mx.struct
print MouseRect.my.struct
wait
[quit]
close #w
end
|
|
Logged
|
|
|
|
|