简体   繁体   中英

PeekMessage() Resetting the Mouse Cursor

Im currently messing around with changing the mouse cursor within a game like C++ application for Windows XP.

To change the cursor I am using SetCursor() and passing in the desired cursor, which is working. However during the while loop in which PeekMessage() is called the cursor keep getting reset back to the default arrow.

This is the offending loop:

MSG  msg;
while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
    TranslateMessage( &msg );
    DispatchMessage( &msg );
}

While debugging I found that the cursor changed during the call to PeekMessage() after which msg.message == 0x200, which should make the message one of these:

WM_MOUSEFIRST = 0x200
WM_MOUSEMOVE = 0x200

I haven't been able to find any information on why this is happening, and have no experience with windows messages.

Thanks.

According to here the system redraws the class cursor everytime the mouse moves, effectively setting it back to the default cursor. With this in mind i added this to the window message callback function:

case WM_SETCURSOR:
    return 0;

problem solved.

How did you debug that? Unless you use SoftIce or some other application which doesn't share the windows mouse pointer, it would be hard to isolate the debugger from the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM