mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Small cleanups [skip ci]
This commit is contained in:
parent
02a06a12b0
commit
98e6be5eb6
171 changed files with 1607 additions and 1769 deletions
|
@ -63,7 +63,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
#region DllImports
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public extern static bool IsWindowVisible(IntPtr hWnd);
|
||||
public static extern bool IsWindowVisible(IntPtr hWnd);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
|
@ -75,9 +75,9 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern int ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int cch);
|
||||
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int cch);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public extern static int GetWindowTextLength(IntPtr hWnd);
|
||||
public static extern int GetWindowTextLength(IntPtr hWnd);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern uint GetSysColor(int nIndex);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
|
@ -98,13 +98,13 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
public static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WindowPlacement lpwndpl);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public extern static bool IsIconic(IntPtr hWnd);
|
||||
public static extern bool IsIconic(IntPtr hWnd);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public extern static bool IsZoomed(IntPtr hwnd);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public extern static int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
public static extern bool IsZoomed(IntPtr hwnd);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern uint GetClassLong(IntPtr hWnd, int nIndex);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "GetClassLongPtr")]
|
||||
public static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex);
|
||||
|
@ -112,13 +112,13 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
|
||||
[DllImport("user32", CharSet=CharSet.Unicode, SetLastError=true)]
|
||||
public extern static IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam);
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public extern static IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "GetWindowLong")]
|
||||
public extern static int GetWindowLong(IntPtr hwnd, int index);
|
||||
public static extern int GetWindowLong(IntPtr hwnd, int index);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "GetWindowLongPtr")]
|
||||
public extern static IntPtr GetWindowLongPtr(IntPtr hwnd, int nIndex);
|
||||
public static extern IntPtr GetWindowLongPtr(IntPtr hwnd, int nIndex);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern int SetWindowLong(IntPtr hWnd, int index, int styleFlags);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
|
||||
|
@ -131,9 +131,9 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetWindowInfo(IntPtr hwnd, ref WindowInfo pwi);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public extern static int EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
public static extern int EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public extern static int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
public static extern int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi);
|
||||
|
@ -187,7 +187,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern uint RegisterWindowMessage(string lpString);
|
||||
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult);
|
||||
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
private static extern bool GetPhysicalCursorPos(out POINT cursorLocation);
|
||||
[DllImport("user32", SetLastError=true)]
|
||||
|
@ -359,9 +359,6 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
/// A SafeHandle class implementation for the hIcon
|
||||
/// </summary>
|
||||
public class SafeIconHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
||||
private SafeIconHandle() : base(true) {
|
||||
}
|
||||
|
||||
public SafeIconHandle(IntPtr hIcon) : base(true) {
|
||||
SetHandle(hIcon);
|
||||
}
|
||||
|
@ -381,24 +378,21 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[DllImport("user32", SetLastError = true)]
|
||||
private static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
|
||||
private IntPtr hWnd;
|
||||
[SecurityCritical]
|
||||
private SafeWindowDCHandle() : base(true) {
|
||||
}
|
||||
private readonly IntPtr _hWnd;
|
||||
|
||||
[SecurityCritical]
|
||||
public SafeWindowDCHandle(IntPtr hWnd, IntPtr preexistingHandle) : base(true) {
|
||||
this.hWnd = hWnd;
|
||||
_hWnd = hWnd;
|
||||
SetHandle(preexistingHandle);
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
|
||||
protected override bool ReleaseHandle() {
|
||||
bool returnValue = ReleaseDC(hWnd, handle);
|
||||
bool returnValue = ReleaseDC(_hWnd, handle);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public static SafeWindowDCHandle fromDesktop() {
|
||||
public static SafeWindowDCHandle FromDesktop() {
|
||||
IntPtr hWndDesktop = User32.GetDesktopWindow();
|
||||
IntPtr hDCDesktop = GetWindowDC(hWndDesktop);
|
||||
return new SafeWindowDCHandle(hWndDesktop, hDCDesktop);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue