This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
CC-Functions/W32/DCDrawer/DCUnbuffered.cs

32 lines
715 B
C#

using CC_Functions.W32.Native;
namespace CC_Functions.W32.DCDrawer
{
public class DCUnbuffered : IDCDrawer
{
private readonly IntPtr hWnd;
private readonly IntPtr ptr;
public DCUnbuffered(IntPtr ptr, IntPtr hWnd)
{
this.ptr = ptr;
this.hWnd = hWnd;
Graphics = Graphics.FromHdc(ptr);
}
public DCUnbuffered(IntPtr ptr)
{
this.ptr = ptr;
hWnd = IntPtr.Zero;
Graphics = Graphics.FromHdc(ptr);
}
public Graphics Graphics { get; }
public void Dispose()
{
Graphics.Dispose();
user32.ReleaseDC(hWnd, ptr);
}
}
}