programming:c_sharp
差異處
這裏顯示兩個版本的差異處。
| 兩邊的前次修訂版前次修改 下次修改 | 前次修改 | ||
| programming:c_sharp [2009/03/26 20:09] – wenpei | programming:c_sharp [2011/04/09 00:02] (目前版本) – 畫面截圖 wenpei | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== 在 C# 中抓取指定視窗的畫面截圖 ====== | ||
| + | Ref: http:// | ||
| + | |||
| + | < | ||
| + | /* 引入 Win32 API 中的 User32.DLL | ||
| + | * 需要加上 using System.Runtime.InteropServices; | ||
| + | */ | ||
| + | [DllImport(" | ||
| + | public static extern Boolean GetWindowRect(IntPtr hWnd, ref Rectangle bounds); | ||
| + | |||
| + | public void CaptureWindow () { | ||
| + | /* 取得目標視窗的 Handle | ||
| + | * 需要加上 using System.Diagnostics; | ||
| + | */ | ||
| + | Process[] process = Process.GetProcessesByName(" | ||
| + | |||
| + | /* 取得該視窗的大小與位置 */ | ||
| + | Rectangle bounds; | ||
| + | GetWindowRect(process[0].MainWindowHandle, | ||
| + | |||
| + | /* 抓取截圖 */ | ||
| + | Bitmap screenshot = new Bitmap(bounds.Width, | ||
| + | Graphics gfx = Graphics.FromImage(screenshot); | ||
| + | gfx.CopyFromScreen(bounds.X, | ||
| + | |||
| + | /* 利用 PictureBox 顯示出來 */ | ||
| + | imageView.Image = (Image) screenshot; | ||
| + | imageView.Update(); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | ====== Techotopia: C# Essentials ====== | ||
| + | http:// | ||
| + | |||
| ====== 在背景中下載檔案 ====== | ====== 在背景中下載檔案 ====== | ||
| http:// | http:// | ||
| 行 19: | 行 54: | ||
| ====== 以 C# 撰寫多執行緒 (Multi-threading) 相關學習資源整理 ====== | ====== 以 C# 撰寫多執行緒 (Multi-threading) 相關學習資源整理 ====== | ||
| http:// | http:// | ||
| + | |||
| + | ====== 在 C# 中抓取指定視窗的畫面截圖 ====== | ||
| + | http:// | ||
| + | |||
| + | < | ||
| + | /* 引入 Win32 API 中的 User32.DLL | ||
| + | * 需要加上 using System.Runtime.InteropServices; | ||
| + | */ | ||
| + | [DllImport(" | ||
| + | public static extern Boolean GetWindowRect(IntPtr hWnd, ref Rectangle bounds); | ||
| + | |||
| + | public void CaptureWindow () { | ||
| + | /* 取得目標視窗的 Handle | ||
| + | * 需要加上 using System.Diagnostics; | ||
| + | */ | ||
| + | Process[] process = Process.GetProcessesByName(" | ||
| + | |||
| + | /* 取得該視窗的大小與位置 */ | ||
| + | Rectangle bounds; | ||
| + | GetWindowRect(process[0].MainWindowHandle, | ||
| + | |||
| + | /* 抓取截圖 */ | ||
| + | Bitmap screenshot = new Bitmap(bounds.Width, | ||
| + | Graphics gfx = Graphics.FromImage(screenshot); | ||
| + | gfx.CopyFromScreen(bounds.X, | ||
| + | |||
| + | /* 利用 PictureBox 顯示出來 */ | ||
| + | imageView.Image = (Image) screenshot; | ||
| + | imageView.Update(); | ||
| + | } | ||
| + | </ | ||
| ====== .NET Reflector ====== | ====== .NET Reflector ====== | ||
programming/c_sharp.1238069349.txt.gz · 上一次變更: 由 wenpei
