私はこれを使用して取得するウィンドウの高さと幅にしようとしています:の取得ウィンドウのリージョン
[DllImport("User32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr handle, out Rectangle rect);
private void timer1_Tick(object sender, EventArgs e)
{
Rectangle bonds = new Rectangle();
GetWindowRect(GetForegroundWindow(), out bonds);
Bitmap bmp = new Bitmap(bonds.Width, bonds.Height);
Graphics memoryGraphics = Graphics.FromImage(bmp);
IntPtr dc = memoryGraphics.GetHdc();
PrintWindow(GetForegroundWindow(), dc, 0x1);
memoryGraphics.ReleaseHdc(dc);
bmp.Save("C:\\Test.gif", ImageFormat.Gif);
}
が、bonds.widthと高さは、実際のウィンドウ以上です。
例:私のウィンドウは100x150、bond.heightは400のようなもので、bonds.widthは500と同じです。画像の角にあるウィンドウからなる400x500のサイズの画像を取得します。画像が(悪い)ウィンドウ
NOTEより道大きいので、残りは黒です:私は、ウィンドウが、それは私にとって良いaerolessだされていることを気にしません。
だから、どんな提案、または多分域を得るためのより良い方法はありますか?
画面は今理にかなって、画面の左上に相対 –