Screen capture in virtual desktop - 1000 points

Posted on 2004-11-25
Medium Priority
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
  • 3
  • 3
  • 2
  • +2
LVL 31

Expert Comment

by:Wayne Barron
ID: 12678810

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

Expert Comment

by:Wim ten Brink
ID: 12683235
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

ID: 12683267
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);
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Accepted Solution

ZhaawZ earned 1500 total points
ID: 12683275
  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);

Author Comment

ID: 12684281

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 http://www.experts-exchange.com/help.jsp#hi4 , 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: www.free-soft.ro , 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).

>  ...you 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 http://members.tripod.com/webdesign123now/java1.htm 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?

Expert Comment

ID: 12686398
>It is against the rules of EE to give more then 500-Points "per" question. http://www.experts-exchange.com/help.jsp#hi4

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

Expert Comment

ID: 12686400
for a mear 50points if you catchg my drift. so giving extra points is a plus plus.
LVL 31

Expert Comment

by:Wayne Barron
ID: 12692083

  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.

Author Comment

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

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

Expert Comment

ID: 12753438
that's the spirit, don't give up.

Author Comment

ID: 12762194
>... don't give up

The only way to really learn ;)

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

850 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