Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions src/Common/src/CompModSwitches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@

namespace System.ComponentModel {
using System.Diagnostics;

/// <internalonly/>
// Shared between dlls

internal static class CompModSwitches {

#if WINDOWS_FORMS_SWITCHES

private static TraceSwitch activeX;
private static TraceSwitch flowLayout;
private static TraceSwitch dataCursor;
Expand Down Expand Up @@ -44,7 +39,10 @@ internal static class CompModSwitches {
private static TraceSwitch setBounds;

private static BooleanSwitch lifetimeTracing;


private static TraceSwitch s_handleLeak;
private static BooleanSwitch s_commonDesignerServices;

public static TraceSwitch ActiveX {
get {
if (activeX == null) {
Expand Down Expand Up @@ -286,8 +284,7 @@ public static TraceSwitch RichLayout {
}
return richLayout;
}
}

}

public static TraceSwitch SetBounds {
get {
Expand All @@ -296,20 +293,15 @@ public static TraceSwitch SetBounds {
}
return setBounds;
}
}

}
#endif



private static TraceSwitch handleLeak;

public static TraceSwitch HandleLeak {
get {
if (handleLeak == null) {
handleLeak = new TraceSwitch("HANDLELEAK", "HandleCollector: Track Win32 Handle Leaks");
if (s_handleLeak == null) {
s_handleLeak = new TraceSwitch("HANDLELEAK", "HandleCollector: Track Win32 Handle Leaks");
}
return handleLeak;
return s_handleLeak;
}
}

Expand All @@ -322,6 +314,16 @@ public static BooleanSwitch TraceCollect {
return traceCollect;
}
}

internal static BooleanSwitch CommonDesignerServices
{
get
{
if (s_commonDesignerServices == null)
{
s_commonDesignerServices = new BooleanSwitch("CommonDesignerServices", "Assert if any common designer service is not found.");
}
return s_commonDesignerServices;
}
}
}
}
79 changes: 77 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 @@ -4793,7 +4800,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 +6017,73 @@ public UiaRect(System.Drawing.Rectangle r) {
// 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 = 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 = 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 = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr WindowFromPoint(int x, int y);
[DllImport(ExternDll.User32, CharSet = 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 = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public extern static IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, [In, Out] TV_HITTESTINFO lParam);
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern short GetKeyState(int keyCode);
[DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "DeleteObject", CharSet = 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 = 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 = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern bool GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase);

[DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "CreateRectRgn", CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
private static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
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 = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern IntPtr GetCursor();

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

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

Expand Down
Loading