mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Few NativeMethods changes
This commit is contained in:
parent
c5687ce3dd
commit
06c29e2d33
4 changed files with 22 additions and 32 deletions
|
@ -30,8 +30,6 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
namespace ShareX.HelpersLib
|
||||
{
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
#region Delegates
|
||||
|
||||
public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
@ -40,9 +38,11 @@ public static partial class NativeMethods
|
|||
|
||||
#endregion Delegates
|
||||
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
#region user32.dll
|
||||
|
||||
[DllImport("user32")]
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AnimateWindow(IntPtr hwnd, int time, AnimateWindowFlags flags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
|
@ -98,6 +98,12 @@ public static partial class NativeMethods
|
|||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetActiveWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern uint GetClassLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
|
||||
|
||||
|
@ -117,9 +123,6 @@ public static partial class NativeMethods
|
|||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetIconInfo(IntPtr hIcon, out IconInfo piconinfo);
|
||||
|
||||
|
@ -190,7 +193,7 @@ public static partial class NativeMethods
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool IsZoomed(IntPtr hWnd);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
|
||||
|
||||
|
@ -299,12 +302,6 @@ public static partial class NativeMethods
|
|||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern ushort GlobalDeleteAtom(ushort nAtom);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern uint GetClassLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
|
||||
|
@ -346,6 +343,9 @@ public static partial class NativeMethods
|
|||
[DllImport("gdi32.dll")]
|
||||
public static extern IntPtr CreateDIBSection(IntPtr hdc, [In] ref BITMAPINFOHEADER pbmi, uint pila, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
|
||||
|
||||
#endregion gdi32.dll
|
||||
|
||||
#region gdiplus.dll
|
||||
|
@ -372,7 +372,6 @@ public static partial class NativeMethods
|
|||
[DllImport("shell32.dll")]
|
||||
public static extern IntPtr SHAppBarMessage(uint dwMessage, [In] ref APPBARDATA pData);
|
||||
|
||||
// http://stackoverflow.com/questions/14600987/code-to-open-windows-explorer-or-focus-if-exists-with-file-selected
|
||||
[DllImport("shell32.dll")]
|
||||
public static extern int SHOpenFolderAndSelectItems(IntPtr pidlFolder, int cild, IntPtr apidl, int dwFlags);
|
||||
|
||||
|
|
|
@ -361,15 +361,6 @@ public static bool IsWindowCloaked(IntPtr handle)
|
|||
return false;
|
||||
}
|
||||
|
||||
public static IntPtr SetHook(int hookType, HookProc hookProc)
|
||||
{
|
||||
using (Process currentProcess = Process.GetCurrentProcess())
|
||||
using (ProcessModule currentModule = currentProcess.MainModule)
|
||||
{
|
||||
return SetWindowsHookEx(hookType, hookProc, GetModuleHandle(currentModule.ModuleName), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RestoreWindow(IntPtr handle)
|
||||
{
|
||||
WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
|
||||
|
|
|
@ -50,7 +50,7 @@ public WindowsList(IntPtr ignoreWindow) : this()
|
|||
public List<WindowInfo> GetWindowsList()
|
||||
{
|
||||
windows = new List<WindowInfo>();
|
||||
NativeMethods.EnumWindowsProc ewp = EvalWindows;
|
||||
EnumWindowsProc ewp = EvalWindows;
|
||||
NativeMethods.EnumWindows(ewp, IntPtr.Zero);
|
||||
return windows;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public List<SimpleWindowInfo> GetWindowInfoList()
|
|||
windows = new List<SimpleWindowInfo>();
|
||||
parentHandles = new HashSet<IntPtr>();
|
||||
|
||||
NativeMethods.EnumWindowsProc ewp = EvalWindow;
|
||||
EnumWindowsProc ewp = EvalWindow;
|
||||
NativeMethods.EnumWindows(ewp, IntPtr.Zero);
|
||||
|
||||
List<SimpleWindowInfo> result = new List<SimpleWindowInfo>();
|
||||
|
@ -137,7 +137,7 @@ private bool CheckHandle(IntPtr handle, bool isWindow)
|
|||
{
|
||||
parentHandles.Add(handle);
|
||||
|
||||
NativeMethods.EnumWindowsProc ewp = EvalControl;
|
||||
EnumWindowsProc ewp = EvalControl;
|
||||
NativeMethods.EnumChildWindows(handle, ewp, IntPtr.Zero);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue