CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513

    Question Take screen shot including mouse

    Hi, I need to save a bmp or jpg with the user screen, just like pressing PrintScreen. I found how to do this, but the mouse pointer is not shown (pointer is null )

    Any solution?

    Thanks !!

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    the mouse pointer isnt actually part of the on screen graphics, but is implemented on the video card in a separate buffer, and is only combined with the image when it is sent to be drawn on the monitor.

    the workaround i guess, after initialising your printscreen, is to query the system and find out where the mouse is, and what the current cursor is (if possible) and draw it on the image yourself..
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  3. #3
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    Ok... it's not that vbSimple...

    Thank you for your answer !

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Nice idea. Here it is...

    Here, a working example.
    Sometimes at first click it was not able to get the picture..it seems to happen half the time...Must check a bit more

    Resize the form after a capture to see all what you got.

    '***********************************************
    Attached removed, modified and reloaded in next answers
    The previous version used kebd_event api to
    simulate a printScreen.
    It worked fine on Win2K, but gave matters on win98
    Thus I used a routine found in MSDN
    at topic "HowTo: capture screen, a form or any window"
    to capture screen if os is older than Win2k
    '***********************************************
    Last edited by Cimperiali; December 4th, 2003 at 11:23 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Ok, better working now

    Here, modified a bit.
    It is not a great job (only some error handling), it might be done better (ideas are welcome: I like to learn!), in any case, now it seems to work properly

    '********************

    Again, removed and attached a bit far down

    '*********************
    Last edited by Cimperiali; December 3rd, 2003 at 03:18 PM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  6. #6
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    Thank you !!!

    It draws the poiter with good accuracy, but I don't get the screen behind (sometimes only the taskbar, located at the top of the form...)

  7. #7
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    One question regarding the topic:

    Imagina that I use DrawIcon with a picturebox with a picture as background (.Picture): how can I save in a bmp both the .Picture and the Icon?

  8. #8
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    Thank you !!, but when I save the picture1.picture to a bmp file, the mouse cursor is not shown...

  9. #9
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Worked with win2k and now should work also with win9x

    ****************************************************
    REBUILD once more, to (hopefully) make it work even on win9X...
    ****************************************************

    a bit better, now....
    and it should also be able to capture the Mouse shape even if it
    is from another application...
    Attached Files Attached Files
    Last edited by Cimperiali; December 5th, 2003 at 05:00 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  10. #10
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    That's it, it was with Image property, not Picture.

    Thank you very much for your help Cimperiali !

  11. #11
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Then have a look now!

    Go up to the previous example and download it: I have reloaded and you should enjoy



    Cesare I.

    Ps: posted last recent example here:
    http://www.planet-source-code.com/vb...50310&lngWId=1
    Last edited by Cimperiali; December 8th, 2003 at 08:34 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured