。
私はこのソリューションには満足していませんが、少しハッキリです。しかし、隠されたウィンドウもスキャンします。
コード
[DllImport("User32.dll")]
public static extern bool PrintWindow(IntPtr hWnd, IntPtr hdcBlt, int nFlags
[StructLayout(LayoutKind.Sequential)]
struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
public static Bitmap GetWindow(IntPtr hWnd)
{
RECT rect;
GetWindowRect(hWnd, out rect);
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
if (width > 0 && height > 0)
{
// Build device context (dc)
Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics gfxBmp = Graphics.FromImage(bmp);
IntPtr hdcBitmap = gfxBmp.GetHdc();
// drawing options
int nFlags = 0;
// execute call
PrintWindow(hWnd, hdcBitmap, nFlags);
// some clean-up
gfxBmp.ReleaseHdc(hdcBitmap);
gfxBmp.Dispose();
return bmp;
}
else
{
return null;
}
} // end function getWindow
私はアイデアが好き。何とかして、W7のタスクバーにはこのような機能があります。 –
私のアプリケーションでは、データなどで定量化できない他のアプリケーションの「動作」や「外見」に従って、次に何をすべきかを判断する必要があり、視覚的に判断する必要があります。アプリケーション(またはタブ)を常に反転させるのは苦痛になります。 – KMC