mirror of https://github.com/quasar/Quasar.git
Fixed #295
This commit is contained in:
parent
89d5fdbc1b
commit
5b396acfc3
|
@ -12,18 +12,17 @@ namespace xClient.Core.Helper
|
|||
public static Bitmap CaptureScreen(int screenNumber)
|
||||
{
|
||||
Rectangle bounds = GetBounds(screenNumber);
|
||||
IntPtr desktopHandle = NativeMethods.GetDesktopWindow();
|
||||
Bitmap screen = new Bitmap(bounds.Width, bounds.Height);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(screen))
|
||||
{
|
||||
IntPtr destDeviceContext = g.GetHdc();
|
||||
IntPtr srcDeviceContext = NativeMethods.GetWindowDC(desktopHandle);
|
||||
IntPtr srcDeviceContext = NativeMethods.CreateDC("DISPLAY", null, null, IntPtr.Zero);
|
||||
|
||||
NativeMethods.BitBlt(destDeviceContext, 0, 0, bounds.Width, bounds.Height, srcDeviceContext, bounds.X,
|
||||
bounds.Y, SRCCOPY);
|
||||
NativeMethods.ReleaseDC(desktopHandle, srcDeviceContext);
|
||||
|
||||
NativeMethods.DeleteDC(srcDeviceContext);
|
||||
g.ReleaseHdc(destDeviceContext);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
|||
namespace xClient.Core.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides some methods from the "user32.dll" and uxtheme libraries.
|
||||
/// Provides access to Win32 API and Microsoft C Runtime Library (msvcrt.dll).
|
||||
/// </summary>
|
||||
public static class NativeMethods
|
||||
{
|
||||
|
@ -18,15 +18,6 @@ namespace xClient.Core.Utilities
|
|||
[DllImport("user32.dll")]
|
||||
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = false)]
|
||||
public static extern IntPtr GetDesktopWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetWindowDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
|
||||
/// <summary>
|
||||
/// Performs a bit-block transfer of the color data corresponding to a
|
||||
/// rectangle of pixels from the specified source device context into
|
||||
|
@ -48,6 +39,12 @@ namespace xClient.Core.Utilities
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool BitBlt([In] IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, [In] IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern bool DeleteDC([In] IntPtr hdc);
|
||||
|
||||
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern unsafe int memcmp(byte* ptr1, byte* ptr2, uint count);
|
||||
|
||||
|
|
|
@ -7,9 +7,6 @@ namespace xServer.Controls
|
|||
{
|
||||
internal class AeroListView : ListView
|
||||
{
|
||||
private const int LVS_EX_DOUBLEBUFFER = 0x10000;
|
||||
private const int LVM_SETEXTENDEDLISTVIEWSTYLE = 4150;
|
||||
|
||||
private const uint WM_CHANGEUISTATE = 0x127;
|
||||
|
||||
private const int UIS_SET = 1;
|
||||
|
@ -34,12 +31,19 @@ namespace xServer.Controls
|
|||
{
|
||||
base.OnHandleCreated(e);
|
||||
|
||||
if (!PlatformHelper.RunningOnMono && PlatformHelper.VistaOrHigher)
|
||||
if (PlatformHelper.RunningOnMono) return;
|
||||
|
||||
if (PlatformHelper.VistaOrHigher)
|
||||
{
|
||||
// set window theme to explorer
|
||||
NativeMethods.SetWindowTheme(this.Handle, "explorer", null);
|
||||
NativeMethods.SendMessage(this.Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_DOUBLEBUFFER),
|
||||
new IntPtr(LVS_EX_DOUBLEBUFFER));
|
||||
NativeMethods.SendMessage(this.Handle, WM_CHANGEUISTATE, NativeMethodsHelper.MakeLong(UIS_SET, UISF_HIDEFOCUS), 0);
|
||||
}
|
||||
|
||||
if (PlatformHelper.XpOrHigher)
|
||||
{
|
||||
// removes the ugly dotted line around focused item
|
||||
NativeMethods.SendMessage(this.Handle, WM_CHANGEUISTATE,
|
||||
NativeMethodsHelper.MakeLong(UIS_SET, UISF_HIDEFOCUS), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,29 +4,14 @@ using System.Runtime.InteropServices;
|
|||
namespace xServer.Core.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides some methods from the "user32.dll" and uxtheme libraries.
|
||||
/// Provides access to Win32 API and Microsoft C Runtime Library (msvcrt.dll).
|
||||
/// </summary>
|
||||
public static class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, string lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr SetCursor(IntPtr hCursor);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad);
|
||||
|
||||
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
|
||||
public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
|
||||
|
||||
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
|
Loading…
Reference in New Issue