public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2) { IntPtr hRgn = System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), CommonHandles.GDI); DbgUtil.AssertWin32(hRgn != IntPtr.Zero, "IntCreateRectRgn([x1={0}, y1={1}, x2={2}, y2={3}]) failed.", x1, y1, x2, y2); return(hRgn); }
public static IntPtr ExtCreatePen(int fnStyle, int dwWidth, IntNativeMethods.LOGBRUSH lplb, int dwStyleCount, int[] lpStyle) { IntPtr hPen = System.Internal.HandleCollector.Add(IntExtCreatePen(fnStyle, dwWidth, lplb, dwStyleCount, lpStyle), IntSafeNativeMethods.CommonHandles.GDI); DbgUtil.AssertWin32(hPen != IntPtr.Zero, "IntExtCreatePen(style={0}, width={1}, brush={2}, styleCount={3}, styles={4}) failed.", fnStyle, dwWidth, lplb, dwStyleCount, lpStyle); return(hPen); }
public static IntPtr CreatePen(int fnStyle, int nWidth, int crColor) { IntPtr hPen = System.Internal.HandleCollector.Add(IntCreatePen(fnStyle, nWidth, crColor), IntSafeNativeMethods.CommonHandles.GDI); DbgUtil.AssertWin32(hPen != IntPtr.Zero, "IntCreatePen(style={0}, width={1}, color=[{2}]) failed.", fnStyle, nWidth, crColor); return(hPen); }
public static IntPtr CreateSolidBrush(int crColor) { IntPtr hBrush = System.Internal.HandleCollector.Add(IntCreateSolidBrush(crColor), IntSafeNativeMethods.CommonHandles.GDI); DbgUtil.AssertWin32(hBrush != IntPtr.Zero, "IntCreateSolidBrush(color={0}) failed.", crColor); return(hBrush); }
public static bool DeleteHDC(HandleRef hDC) { System.Internal.HandleCollector.Remove((IntPtr)hDC, IntSafeNativeMethods.CommonHandles.HDC); bool retVal = IntDeleteDC(hDC); DbgUtil.AssertWin32(retVal, "DeleteHDC([hdc=0x{0:X8}]) failed.", hDC.Handle); return(retVal); }
public static int GetTextExtentPoint32(HandleRef hDC, string text, [In, Out] IntNativeMethods.SIZE size) { int byteCount = text.Length; int retVal = GetTextExtentPoint32W(hDC, text, text.Length, size); DbgUtil.AssertWin32(retVal != 0, "GetTextExtentPoint32(hdc=[0x{0:X8}], text=[{1}], size=[{2}] failed.", hDC.Handle, text, size); return(retVal); }
public static IntPtr GetCurrentObject(HandleRef hDC, int uObjectType) { IntPtr hGdiObj = IntGetCurrentObject(hDC, uObjectType); // If the selected object is a region the return value is HGI_ERROR on failure. DbgUtil.AssertWin32(hGdiObj != IntPtr.Zero, "GetObject(hdc=[0x{0:X8}], type=[{1}]) failed.", hDC, uObjectType); return(hGdiObj); }
public static bool DeleteObject(HandleRef hObject) { System.Internal.HandleCollector.Remove((IntPtr)hObject, IntSafeNativeMethods.CommonHandles.GDI); bool retVal = IntDeleteObject(hObject); DbgUtil.AssertWin32(retVal, "DeleteObject(hObj=[0x{0:X8}]) failed.", hObject.Handle); return(retVal); }
public static bool Arc( HandleRef hDC, int nLeftRect, // x-coord of rectangle's upper-left corner int nTopRect, // y-coord of rectangle's upper-left corner int nRightRect, // x-coord of rectangle's lower-right corner int nBottomRect, // y-coord of rectangle's lower-right corner int nXStartArc, // x-coord of first radial ending point int nYStartArc, // y-coord of first radial ending point int nXEndArc, // x-coord of second radial ending point int nYEndArc // y-coord of second radial ending point ) { bool retVal = IntArc(hDC, nLeftRect, nTopRect, nRightRect, nBottomRect, nXStartArc, nYStartArc, nXEndArc, nYEndArc); DbgUtil.AssertWin32(retVal, "Arc(hdc=[0x{0:X8}], ...) failed.", hDC.Handle); return(retVal); }
public static int GetTextMetrics(HandleRef hDC, ref IntNativeMethods.TEXTMETRIC lptm) { int retVal; if (Marshal.SystemDefaultCharSize == 1) { // ANSI IntNativeMethods.TEXTMETRICA lptmA = new IntNativeMethods.TEXTMETRICA(); retVal = IntUnsafeNativeMethods.GetTextMetricsA(hDC, ref lptmA); lptm.tmHeight = lptmA.tmHeight; lptm.tmAscent = lptmA.tmAscent; lptm.tmDescent = lptmA.tmDescent; lptm.tmInternalLeading = lptmA.tmInternalLeading; lptm.tmExternalLeading = lptmA.tmExternalLeading; lptm.tmAveCharWidth = lptmA.tmAveCharWidth; lptm.tmMaxCharWidth = lptmA.tmMaxCharWidth; lptm.tmWeight = lptmA.tmWeight; lptm.tmOverhang = lptmA.tmOverhang; lptm.tmDigitizedAspectX = lptmA.tmDigitizedAspectX; lptm.tmDigitizedAspectY = lptmA.tmDigitizedAspectY; lptm.tmFirstChar = (char)lptmA.tmFirstChar; lptm.tmLastChar = (char)lptmA.tmLastChar; lptm.tmDefaultChar = (char)lptmA.tmDefaultChar; lptm.tmBreakChar = (char)lptmA.tmBreakChar; lptm.tmItalic = lptmA.tmItalic; lptm.tmUnderlined = lptmA.tmUnderlined; lptm.tmStruckOut = lptmA.tmStruckOut; lptm.tmPitchAndFamily = lptmA.tmPitchAndFamily; lptm.tmCharSet = lptmA.tmCharSet; } else { // Unicode retVal = IntUnsafeNativeMethods.GetTextMetricsW(hDC, ref lptm); } DbgUtil.AssertWin32(retVal != 0, "GetTextMetrics(hdc=[0x{0:X8}], [out TEXTMETRIC] failed.", hDC.Handle); return(retVal); }
public static int GetTextExtentPoint32(HandleRef hDC, string text, [In, Out] IntNativeMethods.SIZE size) { int retVal; int byteCount = text.Length; if (Marshal.SystemDefaultCharSize == 1) { // Convert Unicode string to ANSI. byteCount = IntUnsafeNativeMethods.WideCharToMultiByte(IntNativeMethods.CP_ACP, 0, text, text.Length, null, 0, IntPtr.Zero, IntPtr.Zero); byte[] textBytes = new byte[byteCount]; IntUnsafeNativeMethods.WideCharToMultiByte(IntNativeMethods.CP_ACP, 0, text, text.Length, textBytes, textBytes.Length, IntPtr.Zero, IntPtr.Zero); // Security: Windows 95/98/Me: This value may not exceed 8192. byteCount = Math.Min(text.Length, IntNativeMethods.MaxTextLengthInWin9x); retVal = GetTextExtentPoint32A(hDC, textBytes, byteCount, size); } else { retVal = GetTextExtentPoint32W(hDC, text, text.Length, size); } DbgUtil.AssertWin32(retVal != 0, "GetTextExtentPoint32(hdc=[0x{0:X8}], text=[{1}], size=[{2}] failed.", hDC.Handle, text, size); return(retVal); }
public static IntNativeMethods.RegionFlags GetRgnBox(HandleRef hRgn, [In, Out] ref IntNativeMethods.RECT clipRect) { IntNativeMethods.RegionFlags result = IntGetRgnBox(hRgn, ref clipRect); DbgUtil.AssertWin32(result != IntNativeMethods.RegionFlags.ERROR, "GetRgnBox([hRegion=0x{0:X8}], [out rect]) failed.", hRgn.Handle); return(result); }
public static IntNativeMethods.RegionFlags SelectClipRgn(HandleRef hDC, HandleRef hRgn) { IntNativeMethods.RegionFlags result = IntSelectClipRgn(hDC, hRgn); DbgUtil.AssertWin32(result != IntNativeMethods.RegionFlags.ERROR, "SelectClipRgn([hdc=0x{0:X8}], [hRegion=0x{1:X8}]) failed.", hDC.Handle, hRgn.Handle); return(result); }
public static int SetGraphicsMode(HandleRef hDC, int iMode) { iMode = IntSetGraphicsMode(hDC, iMode); DbgUtil.AssertWin32(iMode != 0, "SetGraphicsMode([hdc=0x{0:X8}], [GM_ADVANCED]) failed.", hDC.Handle); return(iMode); }