views:

284

answers:

1

I'm writing a screen recording app for Windows in Delphi 7 and wish to know when the mouse pointer changes in my app (like from a normal pointer to a resize pointer, etc).

Currently what I'm doing is painting the mouse pointer onto an in-memory bitmap everytime the mouse moves (and on a timer) and doing a pixel by pixel comparison of it with the last bitmap I painted.

Though the comparision is fairly quick (about 2-5ms) because it's happening so often (every mouse move) it adds up. I figure there has to be a faster and less complicated way!

+1  A: 

You have a handle to the cursor, right? If it's the same handle value you had before, then I think it's reasonable to assume it looks the same, too. If the cursor looks different, it will have a different handle value.

That should certainly be true for the standard system cursors. If the application you're recording is creating new cursors while it's running, then maybe it would be able to update the appearance of the current cursor without actually making a new cursor object in the OS (and thus keeping the same handle value), but I don't think that's likely, especially since SetCursor exits immediately when the cursor hasn't changed, and I expect the API function doesn't do the graphical comparison you're trying to avoid, either. It just compares the HCursor value.

Rob Kennedy
Indeed you seem to be right, cheers! :)
Ben Daniel
I was wrong. I've started to notice simply checking the handle isn't enough as the handle only seems to change when hovering over my application. If I print the current cursor handle to screen every few ms while I hover over other apps it doesn't actually change when the cursor changes. :(
Ben Daniel
How are you getting the cursor handle when it's over another application? MSDN says to call GetCursorInfo instead of GetCursor.
Rob Kennedy
Ahh right you are. I was comparing the results of GetCursor. Thanks again!
Ben Daniel