Monitor window (Screen capture) - c#

I'm working on a c# wpf app in which I want a grid or rectangle to show the contents of a window in my application. It should be like a monitor which constantly shows what happens in the other window (video is being played in in it).
Is there a good way to capture the screen or some other option?
Thanks

You can take a look at the VisualBrush class - that might be able to handle what you want. I don't know if it can handle cloning video but this example shows it copying a static part of the screen.

Related

Get Image painted on Window

I have a windows form Window that is being painted on top of by another process. If I try to copy the window image using PrintWindow or device context copy, only my window below shows up:
Window before it's painted on by another process:
Window after it's painted:
Window I get when I do PrintWindow or BitBlt:
Is it possible to read the window draw from the window directly without sending it the paint argument? Can I read it from the graphics card directly?
DirectX breaks the rules, you cannot make PrintWindow() work. Using Graphics.CopyFromScreen() doesn't work either, it has a critical bug that prevents you from passing the correct CopyPixelOperation value. One that was addressed in Windows 8 by Windows itself, you can't rely on it yet.
You'll need to fallback to BitBlt(). The critical option is CopyPixelOperation.CaptureBlt so that video overlays are included in the copy. You'll find the required code in this answer.
If I am correct you want to copy window that is rendered by some DirectX proccess?
You can do that but you need to understand that you can't copy memory from window directly because winows form doesn't have your image, it only have a placeholder for rendered image.
It is only a ilusion that image is rendered inside form.
What you need to do is to copy memory from graphic card but unfortunately I don't know how to do that.
Most simple idea is to get window screenshot like alt+print screen, remove the border and copy that image to your window.
Maybe it will help http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp
Dmitry is right.
You can only make a CopyFromScreen as he suggested:
Capture the Screen into a Bitmap
You can modify the source code to create a bitmap large as your window and copy only that part of screen

App that is not showing on projector

Is there a way to create an app on .NET that will be used when connected with projector/external PC but will be shown only on main screen?
Thanks.
I don't think this is possible. Powerpoint has the functionality of showing notes just on the primary display. But this is only possible when the desktop gets extended and not mirrored to the beamer.
So you shold have to extend the desktop to the beamer and then place the App window on the main screen manually.
System.Windows.Forms.Screen.AllScreens gives you access to monitor information in C#. The PrimaryScreen Property tells you, which screen is the main Screen. You may move the window from one screen to another by respecting the screen widths.

Screen capture without main window

I will like to take a screen capture without a window. I currently hide my main window take a screen shot of the desktop and then make my main window visible again. Will it be possible to achive the same functionality without having to hide my window?
If you are curios on why I am trying to achieve that functionality then look at this question that I am trying to solve.
You can use the RenderTargetBitmap class to convert your Visual to a bitmap.
Tried something like Jing or SnagIt? SnagIt seems to be the most fully featured of the screen capture tools. So, if anything has this, it would be SnagIt.

How to get WPF window close button design?

I want to use the Close button as it shown in WPF windows application into my application.
Is it possible to get the design/image from the existing resources? Anyone points to me to get Pressed, Normal and Hover icons for close?. I could not get them all in one place to match each other..
I have attached close button image here..
That part of the window, termed the chrome, is not rendered by the WPF framework. You can create a chromeless window and render you own chrome. There are quite a few articles / blogposts that describe this. For example:
http://blogs.msdn.com/b/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
If you just want the images, try a screen capture tool.

How that overlay(?) form works in JING

OK, anyone can explain how Jing take screen shots with that overlay form? It appears that it take a full screen shot and records all visible window handles and let you select within the form a specific hwnd. could be true? if is, what are the big steps to achieve this? could be a simple picturebox or without a custom control i don't have a chance to freeze the screen while taking a screen shot?
Thank you!
I'm not familiar enough with Jing to know exactly what it uses. But there are two basic techniques. One is as you mention, capture the screen and display it in a topmost borderless form. The Vista/Win7 Snipping tool works that way. You'll find the code you need to get this started it in my answer in this thread.
The other, perhaps more likely to be used by Jing, is similar to what Spy++ does, allowing the user to move the mouse and draw a selection rectangle around the window. Its advantage is that it can deal with windows resizing or disappearing while you've got the tool running. You implement it by using a topmost form the size of the screen that has its TransparencyKey property set to the value of the BackColor. Fuchsia is a popular choice. You can draw on this form with the OnPaint() method, the drawing appears on top of all the windows. You'd need some P/Invoke (GetWindow) to iterate the underlying windows in their Z-order to know which window the user is pointing at. GetWindowRect() to get the window rectangle. Plus some hassle to deal with Aero lying about the border size.
You can find sample code to get you started on that technique in my answer in this thread.

Categories

Resources