LB Booster
General >> General Board >> Mouse event on redraw
http://lbb.conforums.com/index.cgi?board=general&action=display&num=1518190370

Mouse event on redraw
Post by Monkfish 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.
Re: Mouse event on redraw
Post by tsh73 on Feb 9th, 2018, 5:13pm

GetCursorPos function ?
Re: Mouse event on redraw
Post by Rod 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?
Re: Mouse event on redraw
Post by Richard Russell on Feb 9th, 2018, 7:44pm

on Feb 9th, 2018, 5:13pm, tsh73 wrote:
GetCursorPos function ?

Yes, GetCursorPos followed by ScreenToClient typically.

Richard.
Re: Mouse event on redraw
Post by Rod 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