Jump to content

Screen Snapshot with cursor display


Recommended Posts

Hi all,

I hope this forum entertains problems with regards to programming in VC++ for windows.

Anyway, I am listing my problem here and hope somebody can guide me.

I have written a code that takes a snapshot of the Screen and the mouse pointer and generates a .bmp file. I have managed to succesfully capture the cursor location but the problem is that the snapshot generated shows the mouse cursor as a Hourglass icon (or any relative icon that shows a busy state).

I have used a combination of GetIconInfo and DrawIconEx to do this.

There could be 2 possible reasons (acc. to me)

1) WHen the code takes a snapshot of the screen/captures the mouse pointer it temporarily (not visible to the eye) goes into a busy state and that is why the captured image shows that way

2) I may not have specified everything required to aquire the correct icon of the cursor and so it takes some default icon (which may be the busy state icon).

Hope I have explained myself clearly...

Thanks

Link to comment
Share on other sites

ok...I just happened to strike on something.

Here is the code snipet to 'paste' the mouse cursor on the screen snapshot.

hdcScreen	= GetDC(hwndScreen);
hdcCapt = CreateCompatibleDC(hdcScreen);
hcursor = GetCursor();

DrawIconEx(
 hdcCapt,    
 CursorPos.x, CursorPos.y,
 hcursor,  
 0,0,  
 0,  
 NULL,  
 DI_NORMAL | DI_COMPAT
 );

Basically, if hcursor gives the correct handle to DrawIconEx, when we get the required cursor. But the problem is that the GetCursor(); call allways returns the handle for a 'Busy cursor' (I verified with the value that it returns)

Now, my concern is how can I get the handle of the 'active cursor'. Will i need to call the windows procedure that is handling the cursor image/shape?

Link to comment
Share on other sites

Maybe if you used this:

hcursor = SetCursor(IDC_ARROW);

This will set it to the standard arrow (active) cursor, before taking the snapshot... so you needn't worry about grabbing it. This will only take effect also until the mouse moves, so there shouldn't be a lot of overhead from it...

Link to comment
Share on other sites

scuzzman,

Your method will allow me to get the handle of an ARROW cursor. But what happens when the mouse moves around,from one window to another,resizing etc.? In all above cases the mouse cursor changes its shape and I would like to capture the cursor as it is while taking the snapshots.

Link to comment
Share on other sites

Well, the problem you're running into is that when the system takes the snapshot, it goes to the "Busy" cursor. Hence, when the snapshot is taken, the "Busy" cursor is the active cursor... I don't know of a method to grab the "Previous" cursor...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy