I want to take a screenshot of the user's currently active window (and run OCR on top of it at a later stage). This (e.g. described here) works fine as long as the developer works on standard monitors with the same resolution.
The problem is, that WPF uses device-independent units and the native API functions require pixels. I found many resources how to fix this for my own WPF application, most prominantly here and here. However, I found no way to do this dependent on what monitor the window is currently shown. For example, if the developer has a laptop with a QHD dipslay and uses a secondary monitor with a normal HD resolution. I found a C++ solution on MSDN, but not in C#.
Does anyone have experience with this or any suggestions?
Thanks.
Related
I'm using Avalonia UI to create an application that is available for both Windows as well as macOS, and have come across the issue that, when using a macOS device that has a Retina display, the entire application is scaled up quite massively, estimated about two times. This means that my application, which, in its smallest form is about the size of the Windows Explorer default, actually falls outside of the screen on these Retina displays, which, of course, is not ideal.
Is there a solution?
i am working on visual studio 2010.
i created my master form windows state is Maximized
my system resolution is 1366X768 ,,in one button click i am calling 5 forms together into my master form.. but in my system everything getting correct..
but i installed the same application in my client system,,that system resolution is 1024X768
but here my alignment is not getting proper..now my image is getting like this:
so how i can fit my windows form application in all resolution,,if any one know please help me to find out
You basically have two options:
1) Follow Microsoft's instruction on implementing auotscaling for Windows forms applications. (See http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx)
2) Write your own code to scale the form based on resolution.
============================
Other factors to keep in mind.
If you app is translatable that can affect scaling
A user changing the Windows default font size can have the same affect.
Hope this helps.
I've written a WPF application (in Visual C# 2010 Express) that has 2 windows. The 1st has a various buttons, the other displays video using the MediaElement control. When a button is pressed, a video associated with it is played or stopped if it's already playing.
On my development machine (Windows 7, good graphics card, lots of memory etc), this runs fine. The only problem I've encountered is that when attached to the debugger it is very unstable but when run normally these issues go away.
Unfortunately when run on a much less powerful XP machine the videos run at 1-2fps. This is despite the fact that the videos run fine in Windows Media Player.
There seem to quite a lot of reports of poor performance for the MediaElement control (not to mention inconsistencies in what it can play) so I decided to look at some alternatives.
I tried a free library call WPF MediaKit (http://wpfmediakit.codeplex.com) that I thought might have some effect, however while I've got it to work on an XP machine, it resolutely refuses to display videos on my development machine despite using exactly the same code. I'm still hoping I can this to work but I'm not confident it will help given it's still using the MediaElement control behind the scenes.
I then tried using wmp.dll COM control (Windows forms rather than WPF) and even with the simplest app (new Windows Form project, WMP control added to form, and 1 line of code to set the URL on load) I get odd behaviour. With the debugger attached, it works across multiple monitors, but sometimes when it starts playing, it just repeatedly stutters over the 1st few frames and the only way to break it out of this seems to be to move it to the other monitor. If I'm not using the debugger, I don't seem to get the stutter issue but the video is only displayed on the main monitor, as soon as I move the window to the secondary monitor, it goes black.
So my question is has anyone experienced anything like the above and/or have a decent solution to it? It would be especially nice to find something that works consistently with and without the debugger attached!
Have you tried this library?
http://directshownet.sourceforge.net/about.html
There's also this .NET interface to VideoLAN media player, but that introduces a dependency to VLC:
http://wiki.videolan.org/.Net_Interface_to_VLC
WPF MediaKit does not use MediaElement behind the scenes, but instead uses the D3DImage interop class to provide high performance video to WPF.
WPF in XP has always been a hit-or-miss in terms of performance. You might want to take a look at the rendering tier to ensure WPF is fully hardware accelerating. Also make sure you have the newest video drivers available and that the GPU is capable.
-Jer
how to give size of a control in window mobile app dynamically,because i have developed one application,when i used to run that application on different emulator's ,the size of that control's in that application differ's for different emulator.so could u plz help me that how we can handle such issue in windows mobile application in which iam using visual studio 2008 and windows mobile6 classical emulator
Your question is a bit ambiguous, but I'll take a stab at it.
Apparent control size (how big it looks to your eye) if affected byt a few things. The obvious are things like Dock and Achor properties, which are well documented online and are the same as for the desktop. What is less obvious is scaling. Some PDAs have a 240x320 display, while others may have 480x640 yet with the same physical dimension screen.
The platform can attempt to have your single Form code work for both by doing "pixel doubling" which essentially just doubles all of your size values. This tends to end up with graininess and I think it was turned off by default starting with WinMo 6.
To adjust this behavior, you can adjust your Form's AutoScaleMode property.
We have a C# (WPF) application in which we want to take a screenshot of an arbitrary application launched by us (i.e. so we have a reference to the Process we started).
The application may be minimized or behind other windows but we still only want the image of the individual application, not overlapping pixels.
I know the typical P/Invoke solutions using BitBlt or PrintWindow work most of the time, but those fail (I only get black/transparent pixels) when dealing with an DirectX or OpenGL application that draws directly to the graphics device. I have found this article on taking a screenshot of a Direct3D app from C#, so I think I have that case covered.
So my question is this:
How would I do this for an OpenGL application?
What is the easiest way to determine the appropriate method to use (PW/DX/GL)?
Is there a single universal way of doing this?
For #2, am I relegated to inspecting the modules loaded by the executable and seeing if an DirectX or OpenGL DLL/Assembly is loaded?
This only has to run on Windows XP (not cross-platform and not going to Vista/7 anytime soon if ever for this application).
Answer to 1: In OpenGL, you can call glReadBuffer and glReadPixels to get the screen bitmap. However, this is slow (so you don't call it repeatedly every frame) and you might also have problems when th GL window is overlapped by another application / window. The correct way to do this is to "render to texture" (google it) by using a pbuffer.
Idea for 2: If you have the handle to window, you might be able to get the pixelformatdescriptor structure it has and check it. Never tried it though.
For 3: By the way, I don't think there is a single universal way of doing this without any problems..