using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
Bitmap bmp = new Bitmap(this.Width, this.Height, g);
Graphics imgGraphics = Graphics.FromImage(bmp);
IntPtr dc = imgGraphics.GetHdc();
bool success = PrintWindow(this.Handle, dc, 0);
imgGraphics.ReleaseHdc(dc);
bmp.Save("test.bmp");
bmp.Dispose();
}
'C#' 카테고리의 다른 글
[C#]HashTable을 이용한 폼 추가, ShowDialog 예제 (0) | 2018.05.24 |
---|---|
[C#]마우스 이벤트(mouse_event) 예제 (0) | 2018.05.21 |
[C#]win api를 이용한 키보드 이벤트(keybd_event) 예제 (0) | 2018.05.18 |
[C#]카운트다운 예제 (0) | 2018.05.16 |
[C#]TextBox Caret Hide 예제 (0) | 2018.04.20 |