2
votes

I have created a small window by win api. This window is a child to the window of another thread.

I want allow user to move my window by moving mouse with presed right button. When I move my mouse in normal speed my window moves without problem. But when I move very quick some very strange messages recieved by window. For example,

P WM_MOUSEMOVE fwKeys:MK_BUTTON xPos:-32703 yPos:9

As you see the xPos drops down to a -32000. It happens almost instantly after I move my mouse quick. I have no idea how windows can send me such a message.

Why that message could be sended and how to fix it?

I am using a SetCaption function, so my window recievs messages even if mouse stays outside.

Upd. Solved. The problem was in my inherent maths. Getting hi and lowword from lParam wasn't proper.

1
xPos is 16-bit value, you probably have an overflow in your math while decoding xPos from lParam. - Roman R.
But that message I am watching in Spy++. - HelloWorld
So you're possibly doing something special to have window moved with right button? And it might be causing the wrong message sent. - Roman R.

1 Answers

0
votes

I had the same issue while implementing dragging support, making rapid small circles in the middle of the screen with the mouse while left button is pressed, generates some out of range positions (like -32000 or -64000, despite proper handling of the lParam coordinates conversion). This looked like a bug to me, so I worked around it by clipping x and y to current screen size in pixels for the max values and allowing negative values down to a negative screen size box.

This is a code extract for better comprehension (written in Red/System):

WM_MOUSEMOVE [
    lParam: msg/lParam
    x: GET_X_LPARAM(lParam)
    y: GET_Y_LPARAM(lParam)
    if any [
        x < (0 - screen-size-x)
        y < (0 - screen-size-y)
        x > screen-size-x
        y > screen-size-y
    ][
        return 0        ;-- ignore this event
    ]
    ...
]

That solved it for me.