preet_gne
October 18th, 2004, 03:28 AM
Hi,
I am writing an application of capturing any window(messenger , notepad, destop or any other window ) in my application(winforms) to control them there only. So can anybody tell me how can this be possible, should it be done using API and if yes than which function or is there any built in C# library through which this can be made possible. Thanks in advance :-)
Regards.
Preet
kawasaki056
October 18th, 2004, 04:37 AM
There are perhaps many samples on the net which you can copy and paste so first , explains the flow.
after the signal like, button pushed or ...it's your favorite..
1 Create a "transparent" window by CreateWindowEx . to make it transparent , you specify "WS_EX_TRANSPARENT" to the funciton's dwExStyle member.
// there is additional work you do to call this function. and you do it BEFORE calling it. -1 you write window procedure of transparent window. and -2 Register the class , with RegisterClass() , RegisterClassEx() .
about this, at last , it is explained like this.
Actually, you must first call RegisterClass() (-1). but when calling function, it needs a parameter , to which you substitute the name of "wndproc" I mentioned so you must write "wndproc" (-2), and because the Class was Registered , you can at last call CreateWindowEx() function and make transparent window(1)....
there are three things you do here above......
and..if you could create transparent window(specify the window size to be the whole desktop area .very big window), you get the device context of the transparent window by GetDC() ; and what you got by GetDC() ;
HDC hdc = GetDC( ..) ;
is , this hdc is desktop windows context , contents, so, if you need , you cut the part of whole desktop , using CreateCompatibleDC and CreateCompatibleBitmap , cook it as you like. save to bitmap or, display it to another area or....
so
CreateWindowEx , WM_EX_TRANSPARENT , GetDC , CreateCompatibleDC , CreateCompatibleBitmap will be good keywords....
it's an orthodox way and , in my experience , there are some items,cases you can't capture. I could not capture video's screen shot..but almost all items inner screen is able to be captured..