|
Hello Everybody!
I'm trying to capture a screenshot of a window using a window handle without having to bring the window to the front. Does anybody know how to do this? I've searched and searched and either run into solutions for non-vb.net or ones that simply don't work. Any help?
|
|
|
|
|
Harrison Jones wrote: I'm trying to capture a screenshot of a window using a window handle without having to bring the window to the front.
Assuming that I understand your question correctly ... I'm not sure this is possible, since the covered portions of a window do not exist as bitmaps, but get repainted when the window is uncovered.
|
|
|
|
|
You could look into using the WM_PRINT message[^]....I'm not sure if it works for windows
that don't belong to your process, however.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi,
this is possible
..i made an application that makes screenshots of handles and other things..
and this is a code snip:
[DllImport("user32.dll")]
private static extern bool PrintWindow(IntPtr hwnd, IntPtr hdcBlt, uint nFlags);
[DllImport("user32.dll")]
private static extern int GetWindowRect(IntPtr hWnd, ref Rectangle rect);
[DllImport("user32.dll",EntryPoint="GetDC")]
public static extern IntPtr GetDC(IntPtr ptr);
[DllImport("gdi32.dll",EntryPoint="DeleteObject")]
public static extern IntPtr DeleteObject(IntPtr hDc);
private Bitmap Capture(IntPtr pHwnd)
{
Rectangle r = new Rectangle(0,0,0,0);
GetWindowRect(pHwnd,ref r);
r.Width = r.Width - r.X;
r.Height = r.Height - r.Y;
Bitmap bmp = new Bitmap(r.Width,r.Height);
Graphics e = Graphics.FromImage(bmp);
IntPtr ptr = e.GetHdc();
try
{
IntPtr hDC = GetDC(pHwnd);
PrintWindow(pHwnd,ptr,0);
DeleteObject(hDC);
}catch{}
e.ReleaseHdc(ptr);
e.Flush();
e.Dispose();
return bmp;
}
bless
|
|
|
|
|
Have you tried your program to see if it can capture a window that is not fully visible (for example, part of the window is behind another window)?
I would consider using the PrintWindow API if your test shows that it can capture a window that is not fully visible.
I am not good at Windows programming. I am relying on your test results. Thanks!
|
|
|
|
|
If you can offer a working sample program, I would greatly appreciate it. Thanks!
|
|
|
|
|
hi,
wrote code and it worked!
getting the handles by System.Diagnostics.Process.GetProcesses()
|
|
|
|
|
Thanks for your reply . Now I have some work to do. I will incorporate this into my screen capture program. Thanks a lot!
|
|
|
|
|
I've written a few very casual wrappers around REST and less structured web interfaces, but all just for fun, with very little attention to error detection and handling, timeouts, etc.
Can somebody please give me some pointers, either on practices, or to resources, for developing a solid, professional .NET (or other platform) wrapper for a REST API?
|
|
|
|
|
Hello,
I would like edit some values of machine.config configuration file inside my .net application. Is it possible ?
|
|
|
|
|
As the machine.config file contains global settings for all applications on a machine it is not wise to edit it. You can override most setting in your own app.config.
only two letters away from being an asset
|
|
|
|
|
Can I override <connectionManagement> element in <system.net> section ?
http://msdn.microsoft.com/en-us/library/fb6y0fyc.aspx
|
|
|
|
|
If you read the documentation in the link you provided you can see it supports add, remove and clear elements.
only two letters away from being an asset
|
|
|
|
|
Thank you, I coped with this problem, I wanted to increase the limit of connections that my application can make to a single host. I just added the following text to my app.config
<system.net>
<connectionManagement>
<clear/>
<add address="*" maxconnection="20" />
</connectionManagement>
</system.net>
|
|
|
|
|
I want the source code to calculate the real time bandwidth usage of your computer. I would prefer it in .Net framework. There are lot of bandwidth calculators but I was not able to find any source code.
If anyone has any idea, do tell me.
|
|
|
|
|
Hardik Upadhyay wrote: I want the source code to calculate the real time bandwidth usage of your computer.
I'm assuming you actually mean your own computer. However your question is invalid, as nobody here is just going to hand you the source code for this sort of tool. If there is no free version available on the web then you must write your own.
|
|
|
|
|
I've written a Windows Service (VS2008, .Net 3.5) and I'm trying to install it under Windows7. The service fails to install, and I keep getting this output:
Installing assembly 'd:\DevManaged\VS2008\AllInOneDemo\AIOWindowsService\bin\debug\AIOWindowsService.exe'.
Affected parameters are:
logtoconsole =
assemblypath = d:\DevManaged\VS2008\AllInOneDemo\AIOWindowsService\bin\debug\AIOWindowsService.exe
logfile = d:\DevManaged\VS2008\AllInOneDemo\AIOWindowsService\bin\debug\AIOWindowsService.InstallLog
Installing service AIOWindowsService...
Creating EventLog source AIOWindowsService in log Application...
Rolling back assembly 'd:\DevManaged\VS2008\AllInOneDemo\AIOWindowsService\bin\debug\AIOWindowsService.exe'.
Affected parameters are:
logtoconsole =
assemblypath = d:\DevManaged\VS2008\AllInOneDemo\AIOWindowsService\bin\debug\AIOWindowsService.exe
logfile = d:\DevManaged\VS2008\AllInOneDemo\AIOWindowsService\bin\debug\AIOWindowsService.InstallLog
Restoring event log to previous state for source AIOWindowsService.
An exception occurred during the Rollback phase of the System.Diagnostics.EventLogInstaller installer.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.
Inaccessible logs: Security.
An exception occurred during the Rollback phase of the installation. This exception will be ignored and
the rollback will continue. However, the machine might not fully revert to its initial state after the
rollback is complete.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I have the same issue, I tried to run the console as administrator but still does't work.
I also created my own log, like was post on this article and I still have the same result.
I have Windows7 64 Bits.
|
|
|
|
|
I found a template, and started with that. It appears to install/uninstall just fine. I'll be adding stuff to it and testing the install/uninstall as I go to see what's hosing me up.
Here's a link:
http://alibaabaa.co.uk/article/350[^]
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I have solved the problem.
Just disable UAC and run the "Visual Studio 2008 Command Prompt" as administrator, then type
installutil servicename.exe
and press enter.
The service is instaled!!!!
|
|
|
|
|
What does this mean?
Disconnected Context was detected<br />
Message: Context 0x1b9351e0' is disconnected. Releasing the interfaces from the current context (context 0x1b934f90). This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM components that live inside them.<br />
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Normally it means this[^]. Have you got any threading code in there? If so, it's possible that you've got a thread closing before cleanup has taken place.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Yeah - it was taking too long or something.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Thanks a lot for your helpful link.
I just happened to run into the same problem: I instantiated a COM object, and did that in a background thread during the startup of our application because the call to its "Initialize" method (which is required before other methods can be called) often took some 30 seconds. In order to keep things easy, I made the class containing that COM object a singleton (could do so because I do not need more than one object of it at a time). And when I then called a method of that COM object, it failed with exactly the error described by the OP: because the background thread in which it was created had already ended.
The bad thing here is that the supplier of the COM component is not capable of changing that low performance behavior...
|
|
|
|
|
Hi,
Any idea how to display animated image in datagridview columns?
|
|
|
|