public static SafeDC CreateCompatibleDC(SafeDC hdc) { SafeDC safeDC = null; try { IntPtr hdc2 = IntPtr.Zero; if (hdc != null) { hdc2 = hdc.handle; } safeDC = SafeDC.NativeMethods.CreateCompatibleDC(hdc2); if (safeDC == null) { HRESULT.ThrowLastError(); } } finally { if (safeDC != null) { safeDC._created = true; } } if (safeDC.IsInvalid) { safeDC.Dispose(); throw new SystemException("Unable to create a device context from the specified device information."); } return(safeDC); }
public static void SetProp(IntPtr hwnd, string lpString, IntPtr hData) { if (!Standard.NativeMethods.SetProp_1(hwnd, lpString, hData)) { HRESULT.ThrowLastError(); } }
public static void SystemParametersInfo(SPI uiAction, int uiParam, string pvParam, SPIF fWinIni) { if (!NativeMethods._SystemParametersInfo_String(uiAction, uiParam, pvParam, fWinIni)) { HRESULT.ThrowLastError(); } }
public static void AllowSetForegroundWindow(int dwProcessId) { if (!Standard.NativeMethods.AllowSetForegroundWindow_1(dwProcessId)) { HRESULT.ThrowLastError(); } }
public static void UnregisterClass(short atom, IntPtr hinstance) { if (!NativeMethods._UnregisterClassAtom(new IntPtr((int)atom), hinstance)) { HRESULT.ThrowLastError(); } }
public static void UnregisterClass(string lpClassName, IntPtr hInstance) { if (!NativeMethods._UnregisterClassName(lpClassName, hInstance)) { HRESULT.ThrowLastError(); } }
public static void UpdateLayeredWindow(IntPtr hwnd, SafeDC hdcDst, ref POINT pptDst, ref SIZE psize, SafeDC hdcSrc, ref POINT pptSrc, int crKey, ref BLENDFUNCTION pblend, ULW dwFlags) { if (!NativeMethods._UpdateLayeredWindow(hwnd, hdcDst, ref pptDst, ref psize, hdcSrc, ref pptSrc, crKey, ref pblend, dwFlags)) { HRESULT.ThrowLastError(); } }
public static void UnregisterClass(short atom, IntPtr hinstance) { if (!Standard.NativeMethods.UnregisterClass_1(new IntPtr(atom), hinstance)) { HRESULT.ThrowLastError(); } }
public static void UpdateLayeredWindow(IntPtr hwnd, int crKey, ref BLENDFUNCTION pblend, ULW dwFlags) { if (!NativeMethods._UpdateLayeredWindowIntPtr(hwnd, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, crKey, ref pblend, dwFlags)) { HRESULT.ThrowLastError(); } }
public static RECT AdjustWindowRectEx(RECT lpRect, WS dwStyle, bool bMenu, WS_EX dwExStyle) { if (!NativeMethods._AdjustWindowRectEx(ref lpRect, dwStyle, bMenu, dwExStyle)) { HRESULT.ThrowLastError(); } return(lpRect); }
public static IntPtr SelectObject(SafeDC hdc, IntPtr hgdiobj) { IntPtr intPtr = Standard.NativeMethods.SelectObject_1(hdc, hgdiobj); if (intPtr == IntPtr.Zero) { HRESULT.ThrowLastError(); } return(intPtr); }
public static WM RegisterWindowMessage(string lpString) { uint num = NativeMethods._RegisterWindowMessage(lpString); if (num == 0U) { HRESULT.ThrowLastError(); } return((WM)num); }
public static NONCLIENTMETRICS SystemParameterInfo_GetNONCLIENTMETRICS() { NONCLIENTMETRICS nONCLIENTMETRIC = (Utility.IsOSVistaOrNewer ? NONCLIENTMETRICS.VistaMetricsStruct : NONCLIENTMETRICS.XPMetricsStruct); if (!Standard.NativeMethods.SystemParametersInfoW_1(SPI.GETNONCLIENTMETRICS, nONCLIENTMETRIC.cbSize, ref nONCLIENTMETRIC, SPIF.None)) { HRESULT.ThrowLastError(); } return(nONCLIENTMETRIC); }
public static RECT GetWindowRect(IntPtr hwnd) { RECT rECT; if (!Standard.NativeMethods.GetWindowRect_1(hwnd, out rECT)) { HRESULT.ThrowLastError(); } return(rECT); }
public static NONCLIENTMETRICS SystemParameterInfo_GetNONCLIENTMETRICS() { NONCLIENTMETRICS nonclientmetrics = Utility.IsOSVistaOrNewer ? NONCLIENTMETRICS.VistaMetricsStruct : NONCLIENTMETRICS.XPMetricsStruct; if (!NativeMethods._SystemParametersInfo_NONCLIENTMETRICS(SPI.GETNONCLIENTMETRICS, nonclientmetrics.cbSize, ref nonclientmetrics, SPIF.None)) { HRESULT.ThrowLastError(); } return(nonclientmetrics); }
public static IntPtr GetModuleHandle(string lpModuleName) { IntPtr moduleHandleW = Standard.NativeMethods.GetModuleHandleW(lpModuleName); if (moduleHandleW == IntPtr.Zero) { HRESULT.ThrowLastError(); } return(moduleHandleW); }
public static IntPtr CreateWindowEx(WS_EX dwExStyle, string lpClassName, string lpWindowName, WS dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam) { IntPtr intPtr = NativeMethods._CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); if (IntPtr.Zero == intPtr) { HRESULT.ThrowLastError(); } return(intPtr); }
public static RECT GetWindowRect(IntPtr hwnd) { RECT result; if (!NativeMethods._GetWindowRect(hwnd, out result)) { HRESULT.ThrowLastError(); } return(result); }
public static short RegisterClassEx(ref WNDCLASSEX lpwcx) { short num = NativeMethods._RegisterClassEx(ref lpwcx); if (num == 0) { HRESULT.ThrowLastError(); } return(num); }
public static IntPtr GetModuleHandle(string lpModuleName) { IntPtr intPtr = NativeMethods._GetModuleHandle(lpModuleName); if (intPtr == IntPtr.Zero) { HRESULT.ThrowLastError(); } return(intPtr); }
public static POINT GetCursorPos() { POINT pOINT; if (!Standard.NativeMethods.GetCursorPos_1(out pOINT)) { HRESULT.ThrowLastError(); } return(pOINT); }
public static uint RegisterClipboardFormat(string formatName) { uint num = Standard.NativeMethods.RegisterClipboardFormatW(formatName); if (num == 0) { HRESULT.ThrowLastError(); } return(num); }
public static IntPtr SelectObject(SafeDC hdc, SafeHBITMAP hgdiobj) { IntPtr intPtr = NativeMethods._SelectObjectSafeHBITMAP(hdc, hgdiobj); if (intPtr == IntPtr.Zero) { HRESULT.ThrowLastError(); } return(intPtr); }
public static IntPtr SetActiveWindow(IntPtr hwnd) { Verify.IsNotDefault <IntPtr>(hwnd, "hwnd"); IntPtr intPtr = NativeMethods._SetActiveWindow(hwnd); if (intPtr == IntPtr.Zero) { HRESULT.ThrowLastError(); } return(intPtr); }
public static SafeHBITMAP CreateDIBSection(SafeDC hdc, ref BITMAPINFO bitmapInfo, out IntPtr ppvBits, IntPtr hSection, int dwOffset) { SafeHBITMAP safeHBITMAP = null; safeHBITMAP = (hdc != null ? Standard.NativeMethods.CreateDIBSection_1(hdc, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset) : Standard.NativeMethods.CreateDIBSection_2(IntPtr.Zero, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset)); if (safeHBITMAP.IsInvalid) { HRESULT.ThrowLastError(); } return(safeHBITMAP); }
public static HIGHCONTRAST SystemParameterInfo_GetHIGHCONTRAST() { HIGHCONTRAST highcontrast = new HIGHCONTRAST { cbSize = Marshal.SizeOf(typeof(HIGHCONTRAST)) }; if (!NativeMethods._SystemParametersInfo_HIGHCONTRAST(SPI.GETHIGHCONTRAST, highcontrast.cbSize, ref highcontrast, SPIF.None)) { HRESULT.ThrowLastError(); } return(highcontrast); }
public static HIGHCONTRAST SystemParameterInfo_GetHIGHCONTRAST() { HIGHCONTRAST hIGHCONTRAST = new HIGHCONTRAST() { cbSize = Marshal.SizeOf(typeof(HIGHCONTRAST)) }; HIGHCONTRAST hIGHCONTRAST1 = hIGHCONTRAST; if (!Standard.NativeMethods.SystemParametersInfoW_2(SPI.GETHIGHCONTRAST, hIGHCONTRAST1.cbSize, ref hIGHCONTRAST1, SPIF.None)) { HRESULT.ThrowLastError(); } return(hIGHCONTRAST1); }
public static WINDOWINFO GetWindowInfo(IntPtr hWnd) { WINDOWINFO wINDOWINFO = new WINDOWINFO() { cbSize = Marshal.SizeOf(typeof(WINDOWINFO)) }; WINDOWINFO wINDOWINFO1 = wINDOWINFO; if (!Standard.NativeMethods.GetWindowInfo_1(hWnd, ref wINDOWINFO1)) { HRESULT.ThrowLastError(); } return(wINDOWINFO1); }
public static SafeHBITMAP CreateDIBSection(SafeDC hdc, ref BITMAPINFO bitmapInfo, out IntPtr ppvBits, IntPtr hSection, int dwOffset) { SafeHBITMAP safeHBITMAP; if (hdc == null) { safeHBITMAP = NativeMethods._CreateDIBSectionIntPtr(IntPtr.Zero, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset); } else { safeHBITMAP = NativeMethods._CreateDIBSection(hdc, ref bitmapInfo, 0, out ppvBits, hSection, dwOffset); } if (safeHBITMAP.IsInvalid) { HRESULT.ThrowLastError(); } return(safeHBITMAP); }
public static string GetModuleFileName(IntPtr hModule) { StringBuilder stringBuilder = new StringBuilder(260); for (;;) { int num = NativeMethods._GetModuleFileName(hModule, stringBuilder, stringBuilder.Capacity); if (num == 0) { HRESULT.ThrowLastError(); } if (num != stringBuilder.Capacity) { break; } stringBuilder.EnsureCapacity(stringBuilder.Capacity * 2); } return(stringBuilder.ToString()); }