Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_MOUSEHIDE / _MOUSESHOW
#5
That's what I've been finding from doing some experimenting and research. What I still haven't figured out is how Windows sticks that damn mouse pointer to one spot, regardless of how fast you move the window.

I put this little demo together with a loop event to exaggerate how the mouse cursor races the window.

Start the drag and then swirl the mouse around in a big circle and watch the window chase the mouse...

Code: (Select All)
DIM WinMse AS POINTAPI
TYPE POINTAPI
    X_Pos AS LONG
    Y_Pos AS LONG
END TYPE

DECLARE DYNAMIC LIBRARY "User32"
    FUNCTION GetWindowLongA& (BYVAL hwnd AS LONG, BYVAL nIndex AS LONG)
    FUNCTION SetWindowLongA& (BYVAL hwnd AS LONG, BYVAL nIndex AS LONG, BYVAL dwNewLong AS LONG)
    FUNCTION SetWindowPos& (BYVAL hwnd AS LONG, BYVAL hWndInsertAfter AS LONG, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL cx AS LONG, BYVAL cy AS LONG, BYVAL wFlags AS LONG)
    FUNCTION GetAsyncKeyState% (BYVAL vkey AS LONG)
    FUNCTION GetCursorPos (lpPoint AS POINTAPI)
    FUNCTION SetCursorPos& (BYVAL x AS INTEGER, BYVAL y AS INTEGER)
END DECLARE

DIM AS INTEGER setxy

WIDTH 50, 25
DO: LOOP UNTIL _SCREENEXISTS
GWL_STYLE = -16
ws_border = &H800000
WS_VISIBLE = &H10000000
_TITLE "No Border"
hwnd& = _WINDOWHANDLE
winstyle& = GetWindowLongA&(hwnd&, GWL_STYLE)
_DELAY .25
a& = SetWindowLongA&(hwnd&, GWL_STYLE, winstyle& AND WS_VISIBLE)
a& = SetWindowPos&(hwnd&, 0, 0, 200, 400, 0, 39)

LOCATE 1, 1
COLOR 0, 7
PRINT SPACE$(_WIDTH);
fw = _FONTWIDTH
fh = _FONTHEIGHT
x = _SCREENX: y = _SCREENY

DO
    _LIMIT 60

    IF GetAsyncKeyState(1) < 0 THEN
        IF lb = 0 THEN lb = 1
    ELSE
        IF lb THEN lb = 0: dragx = 0: dragy = 0
    END IF

    z = GetCursorPos(WinMse)

    IF lb THEN
        IF dragx THEN
            IF WinMse.X_Pos <> oldxpos OR WinMse.Y_Pos <> oldypos THEN
                j1 = (WinMse.X_Pos - oldxpos)
                j2 = (WinMse.Y_Pos - oldypos)
                x = x + j1: y = y + j2
                _SCREENMOVE x, y
                z1 = TIMER
                DO
                    setxy = SetCursorPos(x + dragx, y + dragy)
                LOOP UNTIL ABS(TIMER - z1) > .001
            END IF
            z = GetCursorPos(WinMse)
        ELSE
            IF WinMse.Y_Pos >= _SCREENY AND WinMse.Y_Pos <= _SCREENY + fh THEN
                x = _SCREENX: y = _SCREENY
                dragx = (WinMse.X_Pos - x)
                dragy = fw \ 2 ' Set to middle of the title bar vertical height.
            END IF
        END IF
    END IF
    IF LEN(INKEY$) THEN SYSTEM
    oldypos = WinMse.Y_Pos
    oldxpos = WinMse.X_Pos
LOOP

So what I was aiming to do before was hide the mouse during any off the drag point phase, but that is not possible since a button held negates the _MOUSEHIDE command. So still looking for the method that keeps the two married. I even tried the Win32 API MoveWindow approach, but it works the same as _SCREENMOVE. Obviously the mouse pointer has to move off the fixed point a bit to get the new position, but try a drag on a small resized QB64 IDE window and see how much better the pointer stays fixed to the drag point even during very rapid movement.

Oh well, in California, life's a beach. Good surf today, sunny and 75.

Pete
Reply


Messages In This Thread
_MOUSEHIDE / _MOUSESHOW - by Pete - 11-25-2022, 07:32 PM
RE: _MOUSEHIDE / _MOUSESHOW - by mnrvovrfc - 11-25-2022, 07:39 PM
RE: _MOUSEHIDE / _MOUSESHOW - by gaslouk - 11-26-2022, 08:22 AM
RE: _MOUSEHIDE / _MOUSESHOW - by SMcNeill - 11-26-2022, 08:36 AM
RE: _MOUSEHIDE / _MOUSESHOW - by Pete - 11-26-2022, 09:17 AM
RE: _MOUSEHIDE / _MOUSESHOW - by SMcNeill - 11-26-2022, 10:34 AM
RE: _MOUSEHIDE / _MOUSESHOW - by Pete - 11-26-2022, 04:55 PM
RE: _MOUSEHIDE / _MOUSESHOW - by mnrvovrfc - 11-26-2022, 08:07 PM



Users browsing this thread: 2 Guest(s)