Skip to content

Commit 28fc930

Browse files
authored
Port System.Windows.Forms.Design components (#632)
* port WindowsFormsDesignerOptionService * port ComponentTray * port DesignerOptions * removed duplicated translation key * PR comments * Fix release build * removed ResourceConsumptionAttribute and ResourceExposureAttribute * PR comments * removed unused code, removed references to wshidbey bugs, added nameof to exception descriptions * added InheritedGlyph.bmp, fixed PR comments in DesignerActionUI * rebuild resources
1 parent fcfbc18 commit 28fc930

File tree

89 files changed

+24957
-541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+24957
-541
lines changed

src/Common/src/CompModSwitches.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77

88
namespace System.ComponentModel {
99
using System.Diagnostics;
10-
11-
/// <internalonly/>
12-
// Shared between dlls
1310

1411
internal static class CompModSwitches {
15-
1612
#if WINDOWS_FORMS_SWITCHES
17-
1813
private static TraceSwitch activeX;
1914
private static TraceSwitch flowLayout;
2015
private static TraceSwitch dataCursor;
@@ -44,7 +39,10 @@ internal static class CompModSwitches {
4439
private static TraceSwitch setBounds;
4540

4641
private static BooleanSwitch lifetimeTracing;
47-
42+
43+
private static TraceSwitch s_handleLeak;
44+
private static BooleanSwitch s_commonDesignerServices;
45+
4846
public static TraceSwitch ActiveX {
4947
get {
5048
if (activeX == null) {
@@ -286,8 +284,7 @@ public static TraceSwitch RichLayout {
286284
}
287285
return richLayout;
288286
}
289-
}
290-
287+
}
291288

292289
public static TraceSwitch SetBounds {
293290
get {
@@ -296,20 +293,15 @@ public static TraceSwitch SetBounds {
296293
}
297294
return setBounds;
298295
}
299-
}
300-
296+
}
301297
#endif
302298

303-
304-
305-
private static TraceSwitch handleLeak;
306-
307299
public static TraceSwitch HandleLeak {
308300
get {
309-
if (handleLeak == null) {
310-
handleLeak = new TraceSwitch("HANDLELEAK", "HandleCollector: Track Win32 Handle Leaks");
301+
if (s_handleLeak == null) {
302+
s_handleLeak = new TraceSwitch("HANDLELEAK", "HandleCollector: Track Win32 Handle Leaks");
311303
}
312-
return handleLeak;
304+
return s_handleLeak;
313305
}
314306
}
315307

@@ -322,6 +314,16 @@ public static BooleanSwitch TraceCollect {
322314
return traceCollect;
323315
}
324316
}
325-
317+
internal static BooleanSwitch CommonDesignerServices
318+
{
319+
get
320+
{
321+
if (s_commonDesignerServices == null)
322+
{
323+
s_commonDesignerServices = new BooleanSwitch("CommonDesignerServices", "Assert if any common designer service is not found.");
324+
}
325+
return s_commonDesignerServices;
326+
}
327+
}
326328
}
327329
}

src/Common/src/NativeMethods.cs

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ namespace System.Windows.Forms {
5555
using System.Diagnostics.CodeAnalysis;
5656
using System.Globalization;
5757
using System.Runtime.Versioning;
58-
58+
using static System.Windows.Forms.NativeMethods;
59+
5960
/// <include file='doc\NativeMethods.uex' path='docs/doc[@for="NativeMethods"]/*' />
6061
internal static class NativeMethods {
6162

@@ -975,6 +976,12 @@ public const int
975976

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

979+
public const int TVM_SETEXTENDEDSTYLE = TV_FIRST + 44;
980+
public const int TVM_GETEXTENDEDSTYLE = TV_FIRST + 45;
981+
982+
public const int TVS_EX_FADEINOUTEXPANDOS = 0x0040;
983+
public const int TVS_EX_DOUBLEBUFFER = 0x0004;
984+
978985
public static readonly int LOCALE_USER_DEFAULT = MAKELCID(LANG_USER_DEFAULT);
979986
public static readonly int LANG_USER_DEFAULT = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
980987

@@ -4793,7 +4800,8 @@ public class NMHEADER {
47934800
public int iButton = 0;
47944801
public IntPtr pItem = IntPtr.Zero; // HDITEM*
47954802
}
4796-
4803+
4804+
[SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
47974805
[StructLayout(LayoutKind.Sequential)]
47984806
public class MOUSEHOOKSTRUCT {
47994807
// pt was a by-value POINT structure
@@ -6009,6 +6017,70 @@ public UiaRect(System.Drawing.Rectangle r) {
60096017
// This value requires KB2533623 to be installed.
60106018
// Windows Server 2003 and Windows XP: This value is not supported.
60116019
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
6020+
6021+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6022+
[ResourceExposure(ResourceScope.None)]
6023+
public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] ref RECT rect, int cPoints);
6024+
6025+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6026+
[ResourceExposure(ResourceScope.None)]
6027+
public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] POINT pt, int cPoints);
6028+
6029+
6030+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6031+
[ResourceExposure(ResourceScope.None)]
6032+
public static extern IntPtr WindowFromPoint(int x, int y);
6033+
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
6034+
[ResourceExposure(ResourceScope.None)]
6035+
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
6036+
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
6037+
[ResourceExposure(ResourceScope.None)]
6038+
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
6039+
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
6040+
[ResourceExposure(ResourceScope.None)]
6041+
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
6042+
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
6043+
[ResourceExposure(ResourceScope.None)]
6044+
public extern static IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, [In, Out] TV_HITTESTINFO lParam);
6045+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6046+
[ResourceExposure(ResourceScope.None)]
6047+
public static extern short GetKeyState(int keyCode);
6048+
[DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "DeleteObject", CharSet = CharSet.Auto)]
6049+
[ResourceExposure(ResourceScope.None)]
6050+
private static extern bool IntDeleteObject(IntPtr hObject);
6051+
public static bool DeleteObject(IntPtr hObject)
6052+
{
6053+
System.Internal.HandleCollector.Remove(hObject, CommonHandles.GDI);
6054+
return IntDeleteObject(hObject);
6055+
}
6056+
6057+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6058+
[ResourceExposure(ResourceScope.None)]
6059+
public static extern bool GetUpdateRect(IntPtr hwnd, [In, Out] ref RECT rc, bool fErase);
6060+
6061+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6062+
[ResourceExposure(ResourceScope.None)]
6063+
public static extern bool GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase);
6064+
6065+
[DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "CreateRectRgn", CharSet = CharSet.Auto)]
6066+
[ResourceExposure(ResourceScope.Process)]
6067+
private static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
6068+
public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2)
6069+
{
6070+
return System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), CommonHandles.GDI);
6071+
}
6072+
6073+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6074+
[ResourceExposure(ResourceScope.None)]
6075+
public static extern IntPtr GetCursor();
6076+
6077+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6078+
[ResourceExposure(ResourceScope.None)]
6079+
public static extern bool GetCursorPos([In, Out] POINT pt);
6080+
6081+
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
6082+
[ResourceExposure(ResourceScope.None)]
6083+
public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);
60126084
}
60136085
}
60146086

0 commit comments

Comments
 (0)