Screen capture in virtual desktop - 1000 points

Posted on 2004-11-25
Last Modified: 2010-04-05

This question is worth 1000 points (after solution, will post another 500 question).

I'd like a working demo that can grab a bitmap of a given window in a virtual desktop.
Demo should function as follows:

1.  Create virtual desktop
2.  Start given application in a virtual desktop (for example, WinAmp) but don't switch to that virtual desktop
3.  Capture the bitmap of "equilizer" WinAmp window and save bitmap to a file while virtual desktop is *not* visible.

Please note that step 3. is core of the problem - I need a working example of how to capture a window
that is opened in a virtual desktop while the user is in another virtual desktop (i.e. not actually
seeing the window that is beeing captured).

Steps 1. and 2.  I can manage, but don't have time right now, thus 1000 points :)
Question by:Cynna
    LVL 30

    Expert Comment

    by:Wayne Barron

       It is against the rules of EE to give more then 500-Points "per" question.
    LVL 17

    Expert Comment

    by:Wim ten Brink
    I think this is just a 2-question question. One is "Hi, I am lazy, please write code for 1 and 2, okay?" and the other is "I don't know how to do 3. Who does?"
    It should have been split in two posts, though...

    And I'm wondering about what a "Virtual desktop" actually is.
    LVL 11

    Expert Comment

    About step 3 - it could be a problem, if window is minimized or really hidden. If you're using windows 95/98/Me, it still can be a problem. But if using Windows NT/2000/XP and the window is not minimized or actually hidden, you can use function PrintWindow, described in MSDN.

    declaring (if needed):
    function PrintWindow(SourceWindow: hwnd; Destination: hdc; nFlags: cardinal): bool; stdcall; external 'user32.dll' name 'PrintWindow';

    PrintWindow(FindWindow('Winamp EQ', nil), Image1.Canvas.Handle, 0);
    LVL 11

    Accepted Solution

      wnd : hwnd;
      bmp : TBitmap;
      rec : TRect;
    wnd := FindWindow('Winamp EQ', nil);
    GetWindowRect(wnd, rec);
    bmp := TBitmap.Create;
    bmp.Width := rec.Right - rec.Left;
    bmp.Height := rec.Bottom - rec.Top;
    PrintWindow(wnd, bmp.Canvas.Handle, 0);
    LVL 7

    Author Comment


    Sorry, but I did mention I'll give another 500 in another question, right?
    Since two questions are tightly related, it made sense to "connect" them like this.
    However,  I didn't read , so
    I'm sorry for breaking the rules, will mind my manners in the future :), OK?



    Nicely said :), only one slight correction: "don't have time right now" <> "Hi, I am lazy"

    > And I'm wondering about what a "Virtual desktop" actually is
    Look in Win32.hlp for "CreateDesktop()", "SwitchDesktop()",...etc. function family.
    For a demo of how this concept works: , download "Virtual Desktop" with sources.



    Thank you for your effort. But...

    >  ... if window is minimized or really hidden. If you're using windows 95/98/Me, it still can be a problem
    No problem there:
    I'm using only XP, and it isn't  - this is exactly the reason of using another desktop (user must NOT see the window,
    but capture has to be performed - so place window of another desktop).

    > can use function PrintWindow, described in MSDN
    This method of screen grabbing is unreliable - it won't work for any given window.
    I presume PrintWindow uses WM_PRINT message, because it exibits similar symptoms...

    For example, please visit and try
    capturing the picture of the game using PrintWindow() method - you'll end up with a gray block.
    On the other hand, if you try BitBlt() method, capture will be OK.

    I'll give it a few more days for this question. If nobody comes up with the solution,
    the 500 points are yours, OK?
    LVL 2

    Expert Comment

    >It is against the rules of EE to give more then 500-Points "per" question.

    carrzkiss, do u know what else it says in that link u posted.... let me just copy it into here.. "A question is worth whatever it's worth to you." so if the user wants to give more than 500points for a question, then so be it. there was once a time u could give 2000 points, why u think the high points users got so much in couple of years, cos people like this, who are willing to give extra points for the job getting done.

    no one wants to answer a question like in this
    LVL 2

    Expert Comment

    for a mear 50points if you catchg my drift. so giving extra points is a plus plus.
    LVL 30

    Expert Comment

    by:Wayne Barron

      The reason I posted the link, is because one of the Admins posted the link
    To a post that I was on (Not mine) and told the member that they cannot
    Give out no more then "500 Points" per questions.
    And they listed that link.
    So it is not me, it is EE admins. I am just trying to assist others so that they do not
    get into any trouble.
    LVL 7

    Author Comment

    Well, since nobody except ZhaawZ tried anything, the points are yours ZhaawZ, as promised.

    Will probably give it another go in a few days...
    LVL 2

    Expert Comment

    that's the spirit, don't give up.
    LVL 7

    Author Comment

    >... don't give up

    The only way to really learn ;)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now