Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port ControlDesigner #681

Merged
merged 13 commits into from
Apr 12, 2019
12 changes: 12 additions & 0 deletions src/Common/src/CompModSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,17 @@ internal static class CompModSwitches {
}
}

private static BooleanSwitch commonDesignerServices;
public static BooleanSwitch CommonDesignerServices
{
get
{
if (commonDesignerServices == null)
{
commonDesignerServices = new BooleanSwitch("CommonDesignerServices", "Assert if any common designer service is not found.");
}
return commonDesignerServices;
}
}
}
}
86 changes: 84 additions & 2 deletions src/Common/src/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace System.Windows.Forms {
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.Versioning;

using static System.Windows.Forms.NativeMethods;

/// <include file='doc\NativeMethods.uex' path='docs/doc[@for="NativeMethods"]/*' />
internal static class NativeMethods {

Expand Down Expand Up @@ -975,6 +976,12 @@ public const int

public const int LOCALE_IMEASURE = 0x0000000D; // 0 = metric, 1 = US

public const int TVM_SETEXTENDEDSTYLE = TV_FIRST + 44;
public const int TVM_GETEXTENDEDSTYLE = TV_FIRST + 45;

public const int TVS_EX_FADEINOUTEXPANDOS = 0x0040;
public const int TVS_EX_DOUBLEBUFFER = 0x0004;

public static readonly int LOCALE_USER_DEFAULT = MAKELCID(LANG_USER_DEFAULT);
public static readonly int LANG_USER_DEFAULT = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);

Expand Down Expand Up @@ -1955,6 +1962,7 @@ public const int
WM_MBUTTONDOWN = 0x0207,
WM_MBUTTONUP = 0x0208,
WM_MBUTTONDBLCLK = 0x0209,
WM_NCMOUSEHOVER = 0x02A0,
WM_XBUTTONDOWN = 0x020B,
WM_XBUTTONUP = 0x020C,
WM_XBUTTONDBLCLK = 0x020D,
Expand Down Expand Up @@ -4793,7 +4801,8 @@ public class NMHEADER {
public int iButton = 0;
public IntPtr pItem = IntPtr.Zero; // HDITEM*
}


[SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
[StructLayout(LayoutKind.Sequential)]
public class MOUSEHOOKSTRUCT {
// pt was a by-value POINT structure
Expand Down Expand Up @@ -6009,6 +6018,79 @@ public struct UiaRect {
// This value requires KB2533623 to be installed.
// Windows Server 2003 and Windows XP: This value is not supported.
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] ref RECT rect, int cPoints);

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] POINT pt, int cPoints);


[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr WindowFromPoint(int x, int y);
[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
//[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
//[ResourceExposure(ResourceScope.None)]
//public extern static IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, [In, Out] HDHITTESTINFO lParam);
[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
JuditRose marked this conversation as resolved.
Show resolved Hide resolved
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public extern static IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, [In, Out] TV_HITTESTINFO lParam);

[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern short GetKeyState(int keyCode);
[DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "DeleteObject", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
private static extern bool IntDeleteObject(IntPtr hObject);
public static bool DeleteObject(IntPtr hObject)
{
System.Internal.HandleCollector.Remove(hObject, CommonHandles.GDI);
return IntDeleteObject(hObject);
}

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern bool GetUpdateRect(IntPtr hwnd, [In, Out] ref RECT rc, bool fErase);

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern bool GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase);

[DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "CreateRectRgn", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
private static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
[ResourceExposure(ResourceScope.Process)]
[ResourceConsumption(ResourceScope.Process)]
public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2)
{
return System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), CommonHandles.GDI);
}

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr GetCursor();

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern bool GetCursorPos([In, Out] POINT pt);

[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);
}
}

Expand Down
Loading