CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2011
    Posts
    8

    Quick Screen Capture in MFC?

    I've got a screen capture method that captures the screen and saves to a BMP but it seems slow. That is to say, it works fine for the first 2 screen capture events but for the next 2 it doesn't capture the updates, but rather captures the same previous image.

    Does anybody have a handy-dandy real fast screen capture to BMP method?

    Thanks in advance!

  2. #2
    Join Date
    Aug 2011
    Posts
    8

    Re: Quick Screen Capture in MFC?

    I just wanted to follow up.

    This isn't my posting, but this is exactly the same problem that I'm having:
    http://stackoverflow.com/questions/4...235308#7235308

    It appears that the code isn't slow, it's a matter of 'thread synchronization'.

    Specifically, my code looks like this:

    Invalidate(true);
    CaptureScreen(ScreenCounter);

    And the screen capture is happening before the screen is 'rebuilt' from the Invalidate.

    How do I ensure that that CaptureScreen is called only after Invalidate(true) is finished?

    Thanks!

  3. #3
    Join Date
    Aug 2011
    Posts
    8

    How do you know when Invalidate(true) is done?

    How do you know when Invalidate(true) is done? (yeah, I know, the screen has been updated).

    The problem that I'm having is this code:

    Invalidate(true);
    CaptureScreen(ScreenCounter);

    Unfortunately, the screen capture is happening BEFORE the screen has been updated. Is there some way that I can force a 'wait' until Invalidate(true) is done?

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: How do you know when Invalidate(true) is done?

    Why are you starting duplicate threads?

    Invalidate(TRUE);
    UpdateWindow();
    CaptureScreen(ScreenCounter);

  5. #5
    Join Date
    Aug 2011
    Posts
    8

    Re: How do you know when Invalidate(true) is done?

    Thanks! That worked a charm!

    Sorry about the duplicate threads. My first thread was about a screen capture, and the second was more specific.

    Again, sorry about the duplicate threads.

    Really appreciate the help.

  6. #6
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Quick Screen Capture in MFC?

    Try to call UpdateWindow after your Invalidate.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Quick Screen Capture in MFC?

    [ merged threads ]
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  8. #8
    Join Date
    Sep 2012
    Posts
    2

    Re: Quick Screen Capture in MFC?

    Quote Originally Posted by zetar View Post
    I just wanted to follow up.

    This isn't my posting, but this is exactly the same problem that I'm having:
    http://stackoverflow.com/questions/4...235308#7235308

    It appears that the code isn't slow, it's a matter of 'thread synchronization'.

    Specifically, my code looks like this:

    Invalidate(true);
    CaptureScreen(ScreenCounter);

    And the screen capture is happening before the screen is 'rebuilt' from the Invalidate.

    How do I ensure that that CaptureScreen is called only after Invalidate(true) is finished?

    Thanks!
    but it seems don't work when the surface show in overlay.

Tags for this Thread

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