From 79ae146c82c53d419842d19bc022b9d5f3479337 Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Thu, 14 Nov 2024 12:16:42 -0800 Subject: [PATCH] This updates `SplashScreen` to use direct interop built on CsWin32. It also uses the shared `System.Private.Windows.Core` library built in Windows Forms. This makes `SplashScreen` trim-friendly and improves the performance as it will no longer need to generate the rather extensive interop it used to at startup. This also introduces a bottom level assembly for WPF: `System.Windows.Primitives` where there are no other dependencies other than the WinForms/WPF base assembly: `System.Private.Windows.Core`. `PInvokeCore` is the static class that comes from `System.Private.Windows.Core`. `PInvoke` is the static class from `System.Windows.Primitives`. When C# adds something akin to extension types (currently in the design phase) we'll be able to unify to a single `PInvoke`. Generated types (such as `HWND`) are in the namespaces as specified by the Windows metdata and don't have the same problem with conflicts as CsWin32 won't generate types that already exist. CsWin32 uses `System.Drawing` types where they match Win32 types. `Point` is an example of this. These interchange `System.Drawing` types are in-box with .NET. `System.Private.Windows.Core` provides a lot of useful support functionality, particularly when it comes to interop. The various scope types in this PR are an example. OLE code will come from this assembly after the new APIs are merged in WinForms. I've also deleted a large swath of unused interop. It builds on #10023, which leverages #9914. This is an update of #7929. --- Microsoft.Dotnet.Wpf.sln | 35 + eng/Versions.props | 1 + eng/WpfArcadeSdk/tools/SdkReferences.targets | 13 +- eng/WpfArcadeSdk/tools/ShippingProjects.props | 10 +- .../tools/WpfProjectReference.targets | 1 + .../src/Shared/MS/Win32/NativeMethodsCLR.cs | 4277 +---------------- .../Shared/MS/Win32/UnsafeNativeMethodsCLR.cs | 3 - .../System.Windows.Primitives/AssemblyInfo.cs | 24 + .../NativeMethods.json | 10 + .../NativeMethods.txt | 22 + .../System.Windows.Primitives.csproj | 34 + .../ref/System.Windows.Primitives-ref.csproj | 13 + .../UIAutomationClientSideProviders.csproj | 2 + .../MS/Internal/SplashScreenNativeMethods.cs | 147 - .../src/WindowsBase/MS/Internal/Utilities.cs | 9 +- .../System/Windows/SplashScreen.cs | 483 +- .../src/WindowsBase/WindowsBase.csproj | 3 +- .../WindowsBase.Tests/Resources.Designer.cs | 71 + .../WindowsBase.Tests.csproj | 5 + 19 files changed, 540 insertions(+), 4623 deletions(-) create mode 100644 src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs create mode 100644 src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.json create mode 100644 src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.txt create mode 100644 src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj create mode 100644 src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/ref/System.Windows.Primitives-ref.csproj delete mode 100644 src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/SplashScreenNativeMethods.cs create mode 100644 src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/Resources.Designer.cs diff --git a/Microsoft.Dotnet.Wpf.sln b/Microsoft.Dotnet.Wpf.sln index 0a97cba9484..570e744835b 100644 --- a/Microsoft.Dotnet.Wpf.sln +++ b/Microsoft.Dotnet.Wpf.sln @@ -6,6 +6,10 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xaml", "src\Microsoft.DotNet.Wpf\src\System.Xaml\System.Xaml.csproj", "{9AC36357-34B7-40A1-95CA-FE9F46D089A7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "packaging", "packaging", "{0159B0F1-0626-4BED-8D1B-CBFF4F12C369}" + ProjectSection(SolutionItems) = preProject + packaging\Directory.Build.props = packaging\Directory.Build.props + packaging\Directory.Build.targets = packaging\Directory.Build.targets + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.DotNet.Wpf.GitHub", "Microsoft.DotNet.Wpf.GitHub", "{BF20132A-191F-4D34-9A1B-831772A6DFCF}" EndProject @@ -257,6 +261,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{92968783-200 .editorconfig = .editorconfig build.cmd = build.cmd eng\common\build.ps1 = eng\common\build.ps1 + eng\scripts\CIBuild.cmd = eng\scripts\CIBuild.cmd Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets global.json = global.json @@ -370,6 +375,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{C70269FA eng\WpfArcadeSdk\tools\WPF_Generated_Files.txt = eng\WpfArcadeSdk\tools\WPF_Generated_Files.txt EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives", "src\Microsoft.DotNet.Wpf\src\System.Windows.Primitives\System.Windows.Primitives.csproj", "{5306FA93-178C-4535-ADEE-86B1DE1B68CB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives-ref", "src\Microsoft.DotNet.Wpf\src\System.Windows.Primitives\ref\System.Windows.Primitives-ref.csproj", "{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|arm64 = Debug|arm64 @@ -1606,6 +1615,30 @@ Global {D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x64.Build.0 = Release|x64 {D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x86.ActiveCfg = Release|x86 {D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x86.Build.0 = Release|x86 + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|arm64.ActiveCfg = Debug|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|arm64.Build.0 = Debug|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x64.ActiveCfg = Debug|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x64.Build.0 = Debug|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x86.ActiveCfg = Debug|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x86.Build.0 = Debug|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|arm64.ActiveCfg = Release|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|arm64.Build.0 = Release|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x64.ActiveCfg = Release|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x64.Build.0 = Release|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x86.ActiveCfg = Release|Any CPU + {5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x86.Build.0 = Release|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|arm64.ActiveCfg = Debug|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|arm64.Build.0 = Debug|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x64.ActiveCfg = Debug|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x64.Build.0 = Debug|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x86.ActiveCfg = Debug|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x86.Build.0 = Debug|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|arm64.ActiveCfg = Release|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|arm64.Build.0 = Release|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x64.ActiveCfg = Release|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x64.Build.0 = Release|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x86.ActiveCfg = Release|Any CPU + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1730,6 +1763,8 @@ Global {D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1} = {A48B585E-6AB0-4F8D-8484-77F37CB44437} {8F62A3BF-C618-49B1-8B09-82C32C3427BB} = {92968783-2008-4A16-A823-6737224FEB9E} {C70269FA-2569-48B7-B246-A263BBC5698F} = {8F62A3BF-C618-49B1-8B09-82C32C3427BB} + {5306FA93-178C-4535-ADEE-86B1DE1B68CB} = {2EE4A2DA-70B3-4767-9D18-618DA0FE3105} + {0EFFC7C4-B486-4852-8CED-EDEB46E02C42} = {D0AED517-9972-41CB-8751-983E4EB8F511} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567} diff --git a/eng/Versions.props b/eng/Versions.props index 46626d1099d..a1485294f8e 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -81,6 +81,7 @@ 5.38.0.1 0.0.0.1 + 0.3.106 diff --git a/eng/WpfArcadeSdk/tools/SdkReferences.targets b/eng/WpfArcadeSdk/tools/SdkReferences.targets index a096217ec92..6bbded2bc68 100644 --- a/eng/WpfArcadeSdk/tools/SdkReferences.targets +++ b/eng/WpfArcadeSdk/tools/SdkReferences.targets @@ -97,6 +97,16 @@ + + + + <_targetFrameworkIdentifier>$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework))) + <_targetFrameworkIdentifier Condition="'$(_targetFrameworkIdentifier)' == '.NETCoreApp'">net + <_targetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework))) + <_targetFrameworkRoot>$(_targetFrameworkIdentifier)$(_targetFrameworkVersion) + + + - <_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(TargetFramework) + <_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(_targetFrameworkRoot) - + $(InternalShippingLibProjects); PresentationNative; - + $(ExternalShippingProjects); $(InternalShippingProjects) @@ -79,7 +80,7 @@ Reference assembly projects are categorized by what repo they are shipping in. If this changes, say due to open sourcing, they must move accordingly or they will not be including in the ref pack. - + See: ReferenceAssembly.targets/CopyHandCraftedReferenceProjectsToRefDir --> @@ -104,6 +105,7 @@ System.Printing-ref; System.Windows.Controls.Ribbon-ref; System.Windows.Presentation-ref; + System.Windows.Primitives-ref; WindowsFormsIntegration-ref; @@ -145,6 +147,8 @@ ReachFramework-ref; System.Printing; System.Printing-ref; + System.Windows.Primitives; + System.Windows.Primitives-ref; UIAutomationClient; UIAutomationClient-ref; UIAutomationClientsideProviders; diff --git a/eng/WpfArcadeSdk/tools/WpfProjectReference.targets b/eng/WpfArcadeSdk/tools/WpfProjectReference.targets index 1dbe29181f5..13c42d21c2c 100644 --- a/eng/WpfArcadeSdk/tools/WpfProjectReference.targets +++ b/eng/WpfArcadeSdk/tools/WpfProjectReference.targets @@ -21,6 +21,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs index 2e0a430c69c..5dbb847a9bd 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs @@ -108,77 +108,10 @@ public override int GetHashCode() public const int ERROR = 0; public const int BITMAPINFO_MAX_COLORSIZE = 256; -#if never - public const int BI_BITFIELDS = 3; - - public enum RegionFlags { - ERROR = 0, - NULLREGION = 1, - SIMPLEREGION = 2, - COMPLEXREGION = 3, - } - - public const int - /* FONT WEIGHT (BOLD) VALUES */ - FW_DONTCARE = 0, - FW_NORMAL = 400, - FW_BOLD = 700, - // some others... - - /* FONT CHARACTER SET */ - ANSI_CHARSET = 0, - DEFAULT_CHARSET = 1, - // plus others .... - - /* Font OutPrecision */ - OUT_DEFAULT_PRECIS = 0, - OUT_TT_PRECIS = 4, - OUT_TT_ONLY_PRECIS = 7, - - /* polygon fill mode */ - ALTERNATE = 1, - WINDING = 2, - - // text align - TA_DEFAULT = 0, - - // brush - BS_SOLID = 0, - HOLLOW_BRUSH = 5, - - // Binary raster operations. - R2_BLACK = 1, /* 0 */ - R2_NOTMERGEPEN = 2, /* DPon */ - R2_MASKNOTPEN = 3, /* DPna */ - R2_NOTCOPYPEN = 4, /* PN */ - R2_MASKPENNOT = 5, /* PDna */ - R2_NOT = 6, /* Dn */ - R2_XORPEN = 7, /* DPx */ - R2_NOTMASKPEN = 8, /* DPan */ - R2_MASKPEN = 9, /* DPa */ - R2_NOTXORPEN = 10, /* DPxn */ - R2_NOP = 11, /* D */ - R2_MERGENOTPEN = 12, /* DPno */ - R2_COPYPEN = 13, /* P */ - R2_MERGEPENNOT = 14, /* PDno */ - R2_MERGEPEN = 15, /* DPo */ - R2_WHITE = 16 /* 1 */; - public const int - /* SetGraphicsMode(hdc, iMode ) */ - GM_COMPATIBLE = 1, - GM_ADVANCED = 2, - MWT_IDENTITY = 1; - -#endif - public const int -// PAGE_READONLY = 0x02, - PAGE_READWRITE = 0x04, -// PAGE_WRITECOPY = 0x08, -// FILE_MAP_COPY = 0x0001, -// FILE_MAP_WRITE = 0x0002, - FILE_MAP_READ = 0x0004; + PAGE_READWRITE = 0x04, + FILE_MAP_READ = 0x0004; public const int APPCOMMAND_BROWSER_BACKWARD = 1; public const int APPCOMMAND_BROWSER_FORWARD = 2; @@ -237,137 +170,9 @@ public const int public const int FAPPCOMMAND_OEM = 0x1000; public const int FAPPCOMMAND_MASK = 0xF000; -#if never - - public const int SHGFI_ICON = 0x000000100 , // get icon - SHGFI_DISPLAYNAME = 0x000000200, // get display name - SHGFI_TYPENAME = 0x000000400, // get type name - SHGFI_ATTRIBUTES = 0x000000800, // get attributes - SHGFI_ICONLOCATION = 0x000001000, // get icon location - SHGFI_EXETYPE = 0x000002000, // return exe type - SHGFI_SYSICONINDEX = 0x000004000, // get system icon index - SHGFI_LINKOVERLAY = 0x000008000, // put a link overlay on icon - SHGFI_SELECTED = 0x000010000, // show icon in selected state - SHGFI_ATTR_SPECIFIED = 0x000020000, // get only specified attributes - SHGFI_LARGEICON = 0x000000000, // get large icon - SHGFI_SMALLICON = 0x000000001, // get small icon - SHGFI_OPENICON = 0x000000002, // get open icon - SHGFI_SHELLICONSIZE = 0x000000004, // get shell size icon - SHGFI_PIDL = 0x000000008, // pszPath is a pidl - SHGFI_USEFILEATTRIBUTES = 0x000000010, // use passed dwFileAttribute - SHGFI_ADDOVERLAYS = 0x000000020, // apply the appropriate overlays - SHGFI_OVERLAYINDEX = 0x000000040; // Get the index of the overlay - - public const int DM_DISPLAYORIENTATION = 0x00000080; - - public const int AUTOSUGGEST = 0x10000000, - AUTOSUGGEST_OFF = 0x20000000, - AUTOAPPEND = 0x40000000, - AUTOAPPEND_OFF = (unchecked((int)0x80000000)); - - public const int ARW_BOTTOMLEFT = 0x0000, - ARW_BOTTOMRIGHT = 0x0001, - ARW_TOPLEFT = 0x0002, - ARW_TOPRIGHT = 0x0003, - ARW_LEFT = 0x0000, - ARW_RIGHT = 0x0000, - ARW_UP = 0x0004, - ARW_DOWN = 0x0004, - ARW_HIDE = 0x0008, - ACM_OPENA = (0x0400+100), - ACM_OPENW = (0x0400+103), - ADVF_NODATA = 1, - ADVF_ONLYONCE = 4, - ADVF_PRIMEFIRST = 2; - // Note: ADVF_ONLYONCE and ADVF_PRIMEFIRST values now conform with objidl.dll but are backwards from - // Platform SDK documentation as of 07/21/2003. - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/oen_a2z_8jxi.asp. - // See VSWhidbey bug#96162. - - public const int BCM_GETIDEALSIZE = 0x1601; -#endif public const int BI_RGB = 0; -#if never - BS_PATTERN = 3, -#endif public const int BITSPIXEL = 12; -#if never - BDR_RAISEDOUTER = 0x0001, - BDR_SUNKENOUTER = 0x0002, - BDR_RAISEDINNER = 0x0004, - BDR_SUNKENINNER = 0x0008, - BDR_RAISED = 0x0005, - BDR_SUNKEN = 0x000a, - BF_LEFT = 0x0001, - BF_TOP = 0x0002, - BF_RIGHT = 0x0004, - BF_BOTTOM = 0x0008, - BF_ADJUST = 0x2000, - BF_FLAT = 0x4000, - BF_MIDDLE = 0x0800, - BFFM_INITIALIZED = 1, - BFFM_SELCHANGED = 2, - BFFM_SETSELECTION = 0x400+103, - BFFM_ENABLEOK = 0x400+101, - BS_PUSHBUTTON = 0x00000000, - BS_DEFPUSHBUTTON = 0x00000001, - BS_MULTILINE = 0x00002000, - BS_PUSHLIKE = 0x00001000, - BS_OWNERDRAW = 0x0000000B, - BS_RADIOBUTTON = 0x00000004, - BS_3STATE = 0x00000005, - BS_GROUPBOX = 0x00000007, - BS_LEFT = 0x00000100, - BS_RIGHT = 0x00000200, - BS_CENTER = 0x00000300, - BS_TOP = 0x00000400, - BS_BOTTOM = 0x00000800, - BS_VCENTER = 0x00000C00, - BS_RIGHTBUTTON = 0x00000020, - BN_CLICKED = 0, - BM_SETCHECK = 0x00F1, - BM_SETSTATE = 0x00F3, - BM_CLICK = 0x00F5; - - public const int CDERR_DIALOGFAILURE = 0xFFFF, - CDERR_STRUCTSIZE = 0x0001, - CDERR_INITIALIZATION = 0x0002, - CDERR_NOTEMPLATE = 0x0003, - CDERR_NOHINSTANCE = 0x0004, - CDERR_LOADSTRFAILURE = 0x0005, - CDERR_FINDRESFAILURE = 0x0006, - CDERR_LOADRESFAILURE = 0x0007, - CDERR_LOCKRESFAILURE = 0x0008, - CDERR_MEMALLOCFAILURE = 0x0009, - CDERR_MEMLOCKFAILURE = 0x000A, - CDERR_NOHOOK = 0x000B, - CDERR_REGISTERMSGFAIL = 0x000C, - CFERR_NOFONTS = 0x2001, - CFERR_MAXLESSTHANMIN = 0x2002, - CC_RGBINIT = 0x00000001, - CC_FULLOPEN = 0x00000002, - CC_PREVENTFULLOPEN = 0x00000004, - CC_SHOWHELP = 0x00000008, - CC_ENABLEHOOK = 0x00000010, - CC_SOLIDCOLOR = 0x00000080, - CC_ANYCOLOR = 0x00000100, - CF_SCREENFONTS = 0x00000001, - CF_SHOWHELP = 0x00000004, - CF_ENABLEHOOK = 0x00000008, - CF_INITTOLOGFONTSTRUCT = 0x00000040, - CF_EFFECTS = 0x00000100, - CF_APPLY = 0x00000200, - CF_SCRIPTSONLY = 0x00000400, - CF_NOVECTORFONTS = 0x00000800, - CF_NOSIMULATIONS = 0x00001000, - CF_LIMITSIZE = 0x00002000, - CF_FIXEDPITCHONLY = 0x00004000, - CF_FORCEFONTEXIST = 0x00010000, - CF_TTONLY = 0x00040000, - CF_SELECTSCRIPT = 0x00400000, - CF_NOVERTFONTS = 0x01000000, - CP_WINANSI = 1004; -#endif + public const int cmb4 = 0x0473, CS_DBLCLKS = 0x0008, @@ -634,29 +439,11 @@ public const int EM_CHARFROMPOS = 0x00D7, EM_LINEFROMCHAR = 0x00C9, EM_LINEINDEX = 0x00BB; -#if never - - - public const int ERROR_CLASS_ALREADY_EXISTS = 1410; -#endif public const int FNERR_SUBCLASSFAILURE = 0x3001, FNERR_INVALIDFILENAME = 0x3002, FNERR_BUFFERTOOSMALL = 0x3003; -#if never - public const int FRERR_BUFFERLENGTHZERO = 0x4001, - FADF_BSTR = (0x100), - FADF_UNKNOWN = (0x200), - FADF_DISPATCH = (0x400), - FADF_VARIANT = (unchecked((int)0x800)), - FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000, - FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200, - FVIRTKEY = 0x01, - FSHIFT = 0x04, - FALT = 0x10; -#endif - public const int GMEM_MOVEABLE = 0x0002, GMEM_ZEROINIT = 0x0040, GMEM_DDESHARE = 0x2000, @@ -881,23 +668,6 @@ public const int HDN_GETDISPINFOA = ((0-300)-9), HDN_GETDISPINFOW = ((0-300)-29); // HOVER_DEFAULT = Do not use this value ever! It crashes entire servers. -#if never - - public const int HDS_FULLDRAG = 0x0080; - - // Corresponds to bitmaps in MENUITEMINFO - public const int HBMMENU_CALLBACK = -1, - HBMMENU_SYSTEM = 1, - HBMMENU_MBAR_RESTORE = 2, - HBMMENU_MBAR_MINIMIZE = 3, - HBMMENU_MBAR_CLOSE = 5, - HBMMENU_MBAR_CLOSE_D = 6, - HBMMENU_MBAR_MINIMIZE_D = 7, - HBMMENU_POPUP_CLOSE = 8, - HBMMENU_POPUP_RESTORE = 9, - HBMMENU_POPUP_MAXIMIZE = 10, - HBMMENU_POPUP_MINIMIZE = 11; -#endif public static HandleRef HWND_TOP = new HandleRef(null, (IntPtr)0); public static HandleRef HWND_BOTTOM = new HandleRef(null, (IntPtr)1); @@ -906,7 +676,6 @@ public const int // NOTE: NativeMethodsOther.cs defines the following //public static IntPtr HWND_MESSAGE = new IntPtr(-3); - public const int INPLACE_E_NOTOOLSPACE = unchecked((int)0x800401A1), ICON_SMALL = 0, ICON_BIG = 1, @@ -957,37 +726,7 @@ public const int public const int CSC_NAVIGATEFORWARD = 0x00000001, CSC_NAVIGATEBACK = 0x00000002; -#if never - - public const int IDM_PRINT = 27, - IDM_PAGESETUP = 2004, - IDM_PRINTPREVIEW = 2003, - IDM_PROPERTIES = 28, - IDM_SAVEAS = 71; - - - - public const int STG_E_INVALIDFUNCTION = unchecked((int)0x80030001); - public const int STG_E_FILENOTFOUND = unchecked((int)0x80030002); - public const int STG_E_PATHNOTFOUND = unchecked((int)0x80030003); - public const int STG_E_TOOMANYOPENFILES = unchecked((int)0x80030004); - public const int STG_E_ACCESSDENIED = unchecked((int)0x80030005); - public const int STG_E_INVALIDHANDLE = unchecked((int)0x80030006); - public const int STG_E_INSUFFICIENTMEMORY = unchecked((int)0x80030008); - public const int STG_E_INVALIDPOINTER = unchecked((int)0x80030009); - public const int STG_E_NOMOREFILES = unchecked((int)0x80030012); - public const int STG_E_DISKISWRITEPROTECTED = unchecked((int)0x80030013); - public const int STG_E_SEEKERROR = unchecked((int)0x80030019); - public const int STG_E_WRITEFAULT = unchecked((int)0x8003001D); - public const int STG_E_READFAULT = unchecked((int)0x8003001E); - public const int STG_E_SHAREVIOLATION = unchecked((int)0x80030020); - public const int STG_E_LOCKVIOLATION = unchecked((int)0x80030021); -#endif public const int STG_E_CANTSAVE = unchecked((int)0x80030103); -#if never - - public const int KEYEVENTF_KEYUP = 0x0002; -#endif public const int LOGPIXELSX = 88, LOGPIXELSY = 90, @@ -1020,259 +759,8 @@ public const int LB_FINDSTRINGEXACT = 0x01A2, LB_ITEMFROMPOINT = 0x01A9, LB_SETLOCALE = 0x01A5; -#if never - - public const int LBS_NOTIFY = 0x0001, - LBS_MULTIPLESEL = 0x0008, - LBS_OWNERDRAWFIXED = 0x0010, - LBS_OWNERDRAWVARIABLE = 0x0020, - LBS_HASSTRINGS = 0x0040, - LBS_USETABSTOPS = 0x0080, - LBS_NOINTEGRALHEIGHT = 0x0100, - LBS_MULTICOLUMN = 0x0200, - LBS_WANTKEYBOARDINPUT = 0x0400, - LBS_EXTENDEDSEL = 0x0800, - LBS_DISABLENOSCROLL = 0x1000, - LBS_NOSEL = 0x4000, - LOCK_WRITE = 0x1, - LOCK_EXCLUSIVE = 0x2, - LOCK_ONLYONCE = 0x4, - LV_VIEW_TILE = 0x0004, - LVBKIF_SOURCE_NONE = 0x0000, - LVBKIF_SOURCE_URL = 0x0002, - LVBKIF_STYLE_NORMAL = 0x0000, - LVBKIF_STYLE_TILE = 0x0010, - LVS_ICON = 0x0000, - LVS_REPORT = 0x0001, - LVS_SMALLICON = 0x0002, - LVS_LIST = 0x0003, - LVS_SINGLESEL = 0x0004, - LVS_SHOWSELALWAYS = 0x0008, - LVS_SORTASCENDING = 0x0010, - LVS_SORTDESCENDING = 0x0020, - LVS_SHAREIMAGELISTS = 0x0040, - LVS_NOLABELWRAP = 0x0080, - LVS_AUTOARRANGE = 0x0100, - LVS_EDITLABELS = 0x0200, - LVS_NOSCROLL = 0x2000, - LVS_ALIGNTOP = 0x0000, - LVS_ALIGNLEFT = 0x0800, - LVS_NOCOLUMNHEADER = 0x4000, - LVS_NOSORTHEADER = unchecked((int)0x8000), - LVS_OWNERDATA = 0x1000, - LVSCW_AUTOSIZE = -1, - LVSCW_AUTOSIZE_USEHEADER = -2, - LVM_REDRAWITEMS = (0x1000+21), - LVM_SCROLL=(0x1000+20), - LVM_SETBKCOLOR = (0x1000+1), - LVM_SETBKIMAGEA = (0x1000+68), - LVM_SETBKIMAGEW = (0x1000+138), - LVM_SETCALLBACKMASK = (0x1000+11), - LVM_GETCALLBACKMASK = (0x1000+10), - LVM_SETINFOTIP = (0x1000+173), - LVSIL_NORMAL = 0, - LVSIL_SMALL = 1, - LVSIL_STATE = 2, - LVM_SETIMAGELIST = (0x1000+3), - LVM_SETTOOLTIPS = (0x1000+74), - LVIF_TEXT = 0x0001, - LVIF_IMAGE = 0x0002, - LVIF_INDENT = 0x0010, - LVIF_PARAM = 0x0004, - LVIF_STATE = 0x0008, - LVIF_GROUPID = 0x0100, - LVIF_COLUMNS = 0x0200, - LVIS_FOCUSED = 0x0001, - LVIS_SELECTED = 0x0002, - LVIS_CUT = 0x0004, - LVIS_DROPHILITED = 0x0008, - LVIS_OVERLAYMASK = 0x0F00, - LVIS_STATEIMAGEMASK = 0xF000, - LVM_GETITEMA = (0x1000+5), - LVM_GETITEMW = (0x1000+75), - LVM_SETITEMA = (0x1000+6), - LVM_SETITEMW = (0x1000+76), - LVM_SETITEMPOSITION32 = (0x01000 + 49), - LVM_INSERTITEMA = (0x1000+7), - LVM_INSERTITEMW = (0x1000+77), - LVM_DELETEITEM = (0x1000+8), - LVM_DELETECOLUMN = (0x1000+28), - LVM_DELETEALLITEMS = (0x1000+9), - LVM_UPDATE = (0x1000+42), - LVNI_FOCUSED = 0x0001, - LVNI_SELECTED = 0x0002, - LVM_GETNEXTITEM = (0x1000+12), - LVFI_PARAM = 0x0001, - LVFI_NEARESTXY = 0x0040, - LVFI_PARTIAL = 0x0008, - LVFI_STRING = 0x0002, - LVM_FINDITEMA = (0x1000+13), - LVM_FINDITEMW = (0x1000+83), - LVIR_BOUNDS = 0, - LVIR_ICON = 1, - LVIR_LABEL = 2, - LVIR_SELECTBOUNDS = 3, - LVM_GETITEMPOSITION = (0x1000+16), - LVM_GETITEMRECT = (0x1000+14), - LVM_GETSUBITEMRECT = (0x1000+56), - LVM_GETSTRINGWIDTHA = (0x1000+17), - LVM_GETSTRINGWIDTHW = (0x1000+87), - LVHT_NOWHERE = 0x0001, - LVHT_ONITEMICON = 0x0002, - LVHT_ONITEMLABEL = 0x0004, - LVHT_ABOVE = 0x0008, - LVHT_BELOW = 0x0010, - LVHT_RIGHT = 0x0020, - LVHT_LEFT = 0x0040, - LVHT_ONITEM = (0x0002|0x0004|0x0008), - LVHT_ONITEMSTATEICON = 0x0008, - LVM_SUBITEMHITTEST = (0x1000 + 57), - LVM_HITTEST = (0x1000+18), - LVM_ENSUREVISIBLE = (0x1000+19), - LVA_DEFAULT = 0x0000, - LVA_ALIGNLEFT = 0x0001, - LVA_ALIGNTOP = 0x0002, - LVA_SNAPTOGRID = 0x0005, - LVM_ARRANGE = (0x1000+22), - LVM_EDITLABELA = (0x1000+23), - LVM_EDITLABELW = (0x1000+118), - LVCDI_ITEM = 0x0000, - LVCF_FMT = 0x0001, - LVCF_WIDTH = 0x0002, - LVCF_TEXT = 0x0004, - LVCF_SUBITEM = 0x0008, - LVCF_IMAGE = 0x0010, - LVCF_ORDER = 0x0020, - LVCFMT_IMAGE = 0x0800, - LVGA_HEADER_LEFT = 0x00000001, - LVGA_HEADER_CENTER = 0x00000002, - LVGA_HEADER_RIGHT = 0x00000004, - LVGA_FOOTER_LEFT = 0x00000008, - LVGA_FOOTER_CENTER = 0x00000010, - LVGA_FOOTER_RIGHT = 0x00000020, - LVGF_NONE = 0x00000000, - LVGF_HEADER = 0x00000001, - LVGF_FOOTER = 0x00000002, - LVGF_STATE = 0x00000004, - LVGF_ALIGN = 0x00000008, - LVGF_GROUPID = 0x00000010, - LVGS_NORMAL = 0x00000000, - LVGS_COLLAPSED = 0x00000001, - LVGS_HIDDEN = 0x00000002, - LVIM_AFTER = 0x00000001, - LVTVIF_FIXEDSIZE = 0x00000003, - LVTVIM_TILESIZE = 0x00000001, - LVTVIM_COLUMNS = 0x00000002, - LVM_ENABLEGROUPVIEW = (0x1000 + 157), - LVM_MOVEITEMTOGROUP = (0x1000 + 154), - LVM_GETCOLUMNA = (0x1000+25), - LVM_GETCOLUMNW = (0x1000+95), - LVM_SETCOLUMNA = (0x1000+26), - LVM_SETCOLUMNW = (0x1000+96), - LVM_INSERTCOLUMNA = (0x1000+27), - LVM_INSERTCOLUMNW = (0x1000+97), - LVM_INSERTGROUP = (0x1000 + 145), - LVM_REMOVEGROUP = (0x1000 + 150), - LVM_INSERTMARKHITTEST = (0x1000 + 168), - LVM_REMOVEALLGROUPS = (0x1000 + 160), - LVM_GETCOLUMNWIDTH = (0x1000+29), - LVM_SETCOLUMNWIDTH = (0x1000+30), - LVM_SETINSERTMARK = (0x1000 + 166), - LVM_GETHEADER = (0x1000+31), - LVM_SETTEXTCOLOR = (0x1000+36), - LVM_SETTEXTBKCOLOR = (0x1000+38), - LVM_GETTOPINDEX = (0x1000+39), - LVM_SETITEMPOSITION = (0x1000+15), - LVM_SETITEMSTATE = (0x1000+43), - LVM_GETITEMSTATE = (0x1000+44), - LVM_GETITEMTEXTA = (0x1000+45), - LVM_GETITEMTEXTW = (0x1000+115), - LVM_GETHOTITEM = (0x1000+61), - LVM_SETITEMTEXTA = (0x1000+46), - LVM_SETITEMTEXTW = (0x1000+116), - LVM_SETITEMCOUNT = (0x1000+47), - LVM_SORTITEMS = (0x1000+48), - LVM_GETSELECTEDCOUNT = (0x1000+50), - LVM_GETISEARCHSTRINGA = (0x1000+52), - LVM_GETISEARCHSTRINGW = (0x1000+117), - LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000+54), - LVM_SETVIEW = (0x1000 + 142), - LVM_GETGROUPINFO = (0x1000 + 149), - LVM_SETGROUPINFO = (0x1000 + 147), - LVM_HASGROUP = (0x1000 + 161), - LVM_SETTILEVIEWINFO = (0x1000 + 162), - LVM_GETTILEVIEWINFO = (0x1000 + 163), - LVM_GETINSERTMARK = (0x1000 + 167), - LVM_GETINSERTMARKRECT = (0x1000 + 169), - LVM_SETINSERTMARKCOLOR = (0x1000 + 170), - LVM_GETINSERTMARKCOLOR = (0x1000 + 171), - LVM_ISGROUPVIEWENABLED = (0x1000 + 175), - LVS_EX_GRIDLINES = 0x00000001, - LVS_EX_CHECKBOXES = 0x00000004, - LVS_EX_TRACKSELECT = 0x00000008, - LVS_EX_HEADERDRAGDROP = 0x00000010, - LVS_EX_FULLROWSELECT = 0x00000020, - LVS_EX_ONECLICKACTIVATE = 0x00000040, - LVS_EX_TWOCLICKACTIVATE = 0x00000080, - LVS_EX_INFOTIP = 0x00000400, - LVS_EX_UNDERLINEHOT = 0x00000800, - LVS_EX_DOUBLEBUFFER = 0x00010000, - LVN_ITEMCHANGING = ((0-100)-0), - LVN_ITEMCHANGED = ((0-100)-1), - LVN_BEGINLABELEDITA = ((0-100)-5), - LVN_BEGINLABELEDITW = ((0-100)-75), - LVN_ENDLABELEDITA = ((0-100)-6), - LVN_ENDLABELEDITW = ((0-100)-76), - LVN_COLUMNCLICK = ((0-100)-8), - LVN_BEGINDRAG = ((0-100)-9), - LVN_BEGINRDRAG = ((0-100)-11), - LVN_ODFINDITEMA = ((0-100)-52), - LVN_ODFINDITEMW = ((0-100)-79), - LVN_ITEMACTIVATE = ((0-100)-14), - LVN_GETDISPINFOA = ((0-100)-50), - LVN_GETDISPINFOW = ((0-100)-77), - LVN_ODCACHEHINT = ((0-100) - 13), - LVN_ODSTATECHANGED = ((0-100) - 15), - LVN_SETDISPINFOA = ((0-100)-51), - LVN_SETDISPINFOW = ((0-100)-78), - LVN_GETINFOTIPA = ((0-100)-57), - LVN_GETINFOTIPW = ((0-100)- 58), - LVN_KEYDOWN = ((0-100)-55), - - LWA_COLORKEY = 0x00000001, -#endif - public const int LWA_ALPHA = 0x00000002; -#if never - - public const int LANG_NEUTRAL = 0x00, - LOCALE_IFIRSTDAYOFWEEK = 0x0000100C; /* first day of week specifier */ - - public const int LOCALE_IMEASURE = 0x0000000D; // 0 = metric, 1 = US - - public static readonly int LOCALE_USER_DEFAULT = MAKELCID(LANG_USER_DEFAULT); - public static readonly int LANG_USER_DEFAULT = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); - - public static int MAKELANGID(int primary, int sub) { - return ((((ushort)(sub)) << 10) | (ushort)(primary)); - } - - /// - /// - /// Creates an LCID from a LangId - /// - public static int MAKELCID(int lgid) { - return MAKELCID(lgid, SORT_DEFAULT); - } - - /// - /// - /// Creates an LCID from a LangId - /// - public static int MAKELCID(int lgid, int sort) { - return ((0xFFFF & lgid) | (((0x000f) & sort) << 16)); - } -#endif + public const int LWA_ALPHA = 0x00000002; public const int MEMBERID_NIL = (-1), MAX_PATH = 260, @@ -1378,25 +866,6 @@ public const int XFORMCOORDS_HIMETRICTOCONTAINER = 0x4, XFORMCOORDS_CONTAINERTOHIMETRIC = 0x8; -#if never - - public const int NIM_ADD = 0x00000000, - NIM_MODIFY = 0x00000001, - NIM_DELETE = 0x00000002, - NIF_MESSAGE = 0x00000001, - NIF_ICON = 0x00000002, - NIF_TIP = 0x00000004, - NFR_ANSI = 1, - NFR_UNICODE = 2, - NM_CLICK = ((0-0)-2), - NM_DBLCLK = ((0-0)-3), - NM_RCLICK = ((0-0)-5), - NM_RDBLCLK = ((0-0)-6), - NM_CUSTOMDRAW = ((0-0)-12), - NM_RELEASEDCAPTURE = ((0-0)-16), - NONANTIALIASED_QUALITY = 3; -#endif - public const int OFN_READONLY = 0x00000001, OFN_OVERWRITEPROMPT = 0x00000002, OFN_HIDEREADONLY = 0x00000004, @@ -1413,48 +882,6 @@ public const int OFN_ENABLESIZING = 0x00800000, OFN_USESHELLITEM = 0x01000000; -#if never - public const int OLEIVERB_PRIMARY = 0, - OLEIVERB_SHOW = -1, - OLEIVERB_HIDE = -3, - OLEIVERB_UIACTIVATE = -4, - OLEIVERB_INPLACEACTIVATE = -5, - OLEIVERB_DISCARDUNDOSTATE= -6, - OLEIVERB_PROPERTIES = -7, - OLE_E_NOCONNECTION = unchecked((int)0x80040004), - OLE_E_PROMPTSAVECANCELLED = unchecked((int)0x8004000C), - OLEMISC_RECOMPOSEONRESIZE = 0x00000001, - OLEMISC_INSIDEOUT = 0x00000080, - OLEMISC_ACTIVATEWHENVISIBLE = 0x0000100, - OLEMISC_ACTSLIKEBUTTON = 0x00001000, - OLEMISC_SETCLIENTSITEFIRST = 0x00020000, - OBJ_PEN = 1, - OBJ_BRUSH = 2, - OBJ_DC = 3, - OBJ_METADC = 4, - OBJ_PAL = 5, - OBJ_FONT = 6, - OBJ_BITMAP = 7, - OBJ_REGION = 8, - OBJ_METAFILE = 9, - OBJ_MEMDC = 10, - OBJ_EXTPEN = 11, - OBJ_ENHMETADC = 12, - ODS_CHECKED = 0x0008, - ODS_COMBOBOXEDIT = 0x1000, - ODS_DEFAULT = 0x0020, - ODS_DISABLED = 0x0004, - ODS_FOCUS = 0x0010, - ODS_GRAYED = 0x0002, - ODS_HOTLIGHT = 0x0040, - ODS_INACTIVE = 0x0080, - ODS_NOACCEL = 0x0100, - ODS_NOFOCUSRECT = 0x0200, - ODS_SELECTED = 0x0001, - OLECLOSE_SAVEIFDIRTY = 0, - OLECLOSE_PROMPTSAVE = 2; -#endif - public const int PDERR_SETUPFAILURE = 0x1001, PDERR_PARSEFAILURE = 0x1002, PDERR_RETDEFFAILURE = 0x1003, @@ -1528,10 +955,6 @@ public const int PSM_SETFINISHTEXTW = (0x0400+121), PATCOPY = 0x00F00021, PATINVERT = 0x005A0049; -#if never - - public const int PBS_SMOOTH = 0x01; -#endif public const int QS_KEY = 0x0001, QS_MOUSEMOVE = 0x0002, @@ -1546,27 +969,9 @@ public const int QS_INPUT = QS_MOUSE | QS_KEY, QS_ALLEVENTS = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY, QS_ALLINPUT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE; -#if never - - //public const int RECO_PASTE = 0x00000000; // paste from clipboard - public const int RECO_DROP = 0x00000001; // drop - //public const int RECO_COPY = 0x00000002; // copy to the clipboard - //public const int RECO_CUT = 0x00000003; // cut to the clipboard - //public const int RECO_DRAG = 0x00000004; // drag - - public const int RPC_E_CHANGED_MODE = unchecked((int)0x80010106), - RGN_AND = 1, - RPC_E_CANTCALLOUT_ININPUTSYNCCALL = unchecked((int)0x8001010D), - RGN_DIFF = 4, -#endif + public const int RDW_INVALIDATE = 0x0001; public const int RDW_ALLCHILDREN = 0x0080; -#if never - RDW_ERASE = 0x0004, - RDW_FRAME = 0x0400, - RB_INSERTBANDA = (0x0400+1), - RB_INSERTBANDW = (0x0400+10); -#endif public const int stc4 = 0x0443, SHGFP_TYPE_CURRENT = 0, @@ -1627,37 +1032,11 @@ public const int SWP_SHOWWINDOW = 0x0040, SWP_HIDEWINDOW = 0x0080, SWP_DRAWFRAME = 0x0020; -#if never - - public const int SND_SYNC = 0000, - SND_ASYNC = 0x0001, - SND_NODEFAULT = 0x0002, - SND_MEMORY = 0x0004, - SND_LOOP = 0x0008, - SND_PURGE = 0x0040, - SND_FILENAME = 0x00020000, - SND_NOSTOP = 0x0010; -#endif - - public const int MB_ICONHAND = 0x000010, - MB_ICONQUESTION = 0x000020, - MB_ICONEXCLAMATION = 0x000030, - MB_ICONASTERISK = 0x000040; -#if never - - public const int FLASHW_STOP = 0, - FLASHW_CAPTION = 0x00000001, - FLASHW_TRAY = 0x00000002, - FLASHW_ALL = FLASHW_CAPTION | FLASHW_TRAY, - FLASHW_TIMER = 0x00000004, - FLASHW_TIMERNOFG = 0x0000000C; - - public const int HLP_FILE = 1, - HLP_KEYWORD = 2, - HLP_NAVIGATOR = 3, - HLP_OBJECT = 4; -#endif + public const int MB_ICONHAND = 0x000010, + MB_ICONQUESTION = 0x000020, + MB_ICONEXCLAMATION = 0x000030, + MB_ICONASTERISK = 0x000040; public const int SW_SCROLLCHILDREN = 0x0001, SW_INVALIDATE = 0x0002, @@ -2063,51 +1442,10 @@ public const int UISF_HIDEACCEL = 0x2, UISF_ACTIVE = 0x4; -#if never - - public const int TVHT_NOWHERE = 0x0001, - TVHT_ONITEMICON = 0x0002, - TVHT_ONITEMLABEL = 0x0004, - TVHT_ONITEM = (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON), - TVHT_ONITEMINDENT = 0x0008, - TVHT_ONITEMBUTTON = 0x0010, - TVHT_ONITEMRIGHT = 0x0020, - TVHT_ONITEMSTATEICON = 0x0040, - TVHT_ABOVE = 0x0100, - TVHT_BELOW = 0x0200, - TVHT_TORIGHT = 0x0400, - TVHT_TOLEFT = 0x0800; - - public const int - USERCLASSTYPE_FULL = 1, - USERCLASSTYPE_SHORT = 2, - USERCLASSTYPE_APPNAME = 3, - UOI_FLAGS = 1; - - - public const int VIEW_E_DRAW = unchecked((int)0x80040140), - VK_LEFT = 0x25, - VK_UP = 0x26, - VK_RIGHT = 0x27, - VK_DOWN = 0x28, -#endif - public const int VK_TAB = 0x09; public const int VK_SHIFT = 0x10; public const int VK_CONTROL = 0x11; public const int VK_MENU = 0x12; -#if never - VK_ESCAPE = 0x1B, - VK_INSERT = 0x002D; - - public const int WAVE_FORMAT_PCM = 0x0001, - WAVE_FORMAT_ADPCM = 0x0002, - WAVE_FORMAT_IEEE_FLOAT = 0x0003; - - public const int MMIO_READ = 0x00000000, - MMIO_ALLOCBUF = 0x00010000, - MMIO_FINDRIFF = 0x00000020; -#endif public const int WH_JOURNALPLAYBACK = 1, WH_GETMESSAGE = 3, @@ -2166,373 +1504,9 @@ public const int public const int WHITE_BRUSH = 0x00000000; public const int NULL_BRUSH = 5; -#if never - - public static int START_PAGE_GENERAL = unchecked((int)0xffffffff); - - // Result action ids for PrintDlgEx. - public const int PD_RESULT_CANCEL = 0; - public const int PD_RESULT_PRINT = 1; - public const int PD_RESULT_APPLY = 2; - -#endif - public const int XBUTTON1 = 0x0001; public const int XBUTTON2 = 0x0002; -#if never - - - // These are initialized in a static constructor for speed. That way we don't have to - // evaluate the char size each time. - // - public static readonly int CBEM_GETITEM; - public static readonly int CBEM_SETITEM; - public static readonly int CBEN_ENDEDIT; - public static readonly int CBEM_INSERTITEM; - public static readonly int LVM_GETITEMTEXT; - public static readonly int LVM_SETITEMTEXT; - public static readonly int ACM_OPEN; - public static readonly int DTM_SETFORMAT; - public static readonly int DTN_USERSTRING; - public static readonly int DTN_WMKEYDOWN; - public static readonly int DTN_FORMAT; - public static readonly int DTN_FORMATQUERY; - public static readonly int EMR_POLYTEXTOUT; - public static readonly int HDM_INSERTITEM; - public static readonly int HDM_GETITEM; - public static readonly int HDM_SETITEM; - public static readonly int HDN_ITEMCHANGING; - public static readonly int HDN_ITEMCHANGED; - public static readonly int HDN_ITEMCLICK; - public static readonly int HDN_ITEMDBLCLICK; - public static readonly int HDN_DIVIDERDBLCLICK; - public static readonly int HDN_BEGINTRACK; - public static readonly int HDN_ENDTRACK; - public static readonly int HDN_TRACK; - public static readonly int HDN_GETDISPINFO; - public static readonly int LVM_GETITEM; - public static readonly int LVM_SETBKIMAGE; - public static readonly int LVM_SETITEM; - public static readonly int LVM_INSERTITEM; - public static readonly int LVM_FINDITEM; - public static readonly int LVM_GETSTRINGWIDTH; - public static readonly int LVM_EDITLABEL; - public static readonly int LVM_GETCOLUMN; - public static readonly int LVM_SETCOLUMN; - public static readonly int LVM_GETISEARCHSTRING; - public static readonly int LVM_INSERTCOLUMN; - public static readonly int LVN_BEGINLABELEDIT; - public static readonly int LVN_ENDLABELEDIT; - public static readonly int LVN_ODFINDITEM; - public static readonly int LVN_GETDISPINFO; - public static readonly int LVN_GETINFOTIP; - public static readonly int LVN_SETDISPINFO; - public static readonly int PSM_SETTITLE; - public static readonly int PSM_SETFINISHTEXT; - public static readonly int RB_INSERTBAND; - public static readonly int SB_SETTEXT; - public static readonly int SB_GETTEXT; - public static readonly int SB_GETTEXTLENGTH; - public static readonly int SB_SETTIPTEXT; - public static readonly int SB_GETTIPTEXT; - public static readonly int TB_SAVERESTORE; - public static readonly int TB_ADDSTRING; - public static readonly int TB_GETBUTTONTEXT; - public static readonly int TB_MAPACCELERATOR; - public static readonly int TB_GETBUTTONINFO; - public static readonly int TB_SETBUTTONINFO; - public static readonly int TB_INSERTBUTTON; - public static readonly int TB_ADDBUTTONS; - public static readonly int TBN_GETBUTTONINFO; - public static readonly int TBN_GETINFOTIP; - public static readonly int TBN_GETDISPINFO; - public static readonly int TTM_ADDTOOL; - public static readonly int TTM_SETTITLE; - public static readonly int TTM_DELTOOL; - public static readonly int TTM_NEWTOOLRECT; - public static readonly int TTM_GETTOOLINFO; - public static readonly int TTM_SETTOOLINFO; - public static readonly int TTM_HITTEST; - public static readonly int TTM_GETTEXT; - public static readonly int TTM_UPDATETIPTEXT; - public static readonly int TTM_ENUMTOOLS; - public static readonly int TTM_GETCURRENTTOOL; - public static readonly int TTN_GETDISPINFO; - public static readonly int TTN_NEEDTEXT; - public static readonly int TVM_INSERTITEM; - public static readonly int TVM_GETITEM; - public static readonly int TVM_SETITEM; - public static readonly int TVM_EDITLABEL; - public static readonly int TVM_GETISEARCHSTRING; - public static readonly int TVN_SELCHANGING; - public static readonly int TVN_SELCHANGED; - public static readonly int TVN_GETDISPINFO; - public static readonly int TVN_SETDISPINFO; - public static readonly int TVN_ITEMEXPANDING; - public static readonly int TVN_ITEMEXPANDED; - public static readonly int TVN_BEGINDRAG; - public static readonly int TVN_BEGINRDRAG; - public static readonly int TVN_BEGINLABELEDIT; - public static readonly int TVN_ENDLABELEDIT; - public static readonly int TCM_GETITEM; - public static readonly int TCM_SETITEM; - public static readonly int TCM_INSERTITEM; - - public const string TOOLTIPS_CLASS = "tooltips_class32"; - - public const string WC_DATETIMEPICK = "SysDateTimePick32", - WC_LISTVIEW = "SysListView32", - WC_MONTHCAL = "SysMonthCal32", - WC_PROGRESS = "msctls_progress32", - WC_STATUSBAR = "msctls_statusbar32", - WC_TOOLBAR = "ToolbarWindow32", - WC_TRACKBAR = "msctls_trackbar32", - WC_TREEVIEW = "SysTreeView32", - WC_TABCONTROL = "SysTabControl32", - MSH_MOUSEWHEEL = "MSWHEEL_ROLLMSG", - MSH_SCROLL_LINES = "MSH_SCROLL_LINES_MSG", - MOUSEZ_CLASSNAME = "MouseZ", - MOUSEZ_TITLE = "Magellan MSWHEEL"; - - public const int CHILDID_SELF = 0; - - public const int OBJID_QUERYCLASSNAMEIDX = unchecked(unchecked((int)0xFFFFFFF4)); - public const int OBJID_WINDOW = unchecked(unchecked((int)0x00000000)); - - public const string uuid_IAccessible = "{618736E0-3C3D-11CF-810C-00AA00389B71}"; - public const string uuid_IEnumVariant = "{00020404-0000-0000-C000-000000000046}"; - - static NativeMethods() { - if (Marshal.SystemDefaultCharSize == 1) { - CBEM_GETITEM = NativeMethods.CBEM_GETITEMA; - CBEM_SETITEM = NativeMethods.CBEM_SETITEMA; - CBEN_ENDEDIT = NativeMethods.CBEN_ENDEDITA; - CBEM_INSERTITEM = NativeMethods.CBEM_INSERTITEMA; - LVM_GETITEMTEXT = NativeMethods.LVM_GETITEMTEXTA; - LVM_SETITEMTEXT = NativeMethods.LVM_SETITEMTEXTA; - ACM_OPEN = NativeMethods.ACM_OPENA; - DTM_SETFORMAT = NativeMethods.DTM_SETFORMATA; - DTN_USERSTRING = NativeMethods.DTN_USERSTRINGA; - DTN_WMKEYDOWN = NativeMethods.DTN_WMKEYDOWNA; - DTN_FORMAT = NativeMethods.DTN_FORMATA; - DTN_FORMATQUERY = NativeMethods.DTN_FORMATQUERYA; - EMR_POLYTEXTOUT = NativeMethods.EMR_POLYTEXTOUTA; - HDM_INSERTITEM = NativeMethods.HDM_INSERTITEMA; - HDM_GETITEM = NativeMethods.HDM_GETITEMA; - HDM_SETITEM = NativeMethods.HDM_SETITEMA; - HDN_ITEMCHANGING = NativeMethods.HDN_ITEMCHANGINGA; - HDN_ITEMCHANGED = NativeMethods.HDN_ITEMCHANGEDA; - HDN_ITEMCLICK = NativeMethods.HDN_ITEMCLICKA; - HDN_ITEMDBLCLICK = NativeMethods.HDN_ITEMDBLCLICKA; - HDN_DIVIDERDBLCLICK = NativeMethods.HDN_DIVIDERDBLCLICKA; - HDN_BEGINTRACK = NativeMethods.HDN_BEGINTRACKA; - HDN_ENDTRACK = NativeMethods.HDN_ENDTRACKA; - HDN_TRACK = NativeMethods.HDN_TRACKA; - HDN_GETDISPINFO = NativeMethods.HDN_GETDISPINFOA; - LVM_SETBKIMAGE = NativeMethods.LVM_SETBKIMAGEA; - LVM_GETITEM = NativeMethods.LVM_GETITEMA; - LVM_SETITEM = NativeMethods.LVM_SETITEMA; - LVM_INSERTITEM = NativeMethods.LVM_INSERTITEMA; - LVM_FINDITEM = NativeMethods.LVM_FINDITEMA; - LVM_GETSTRINGWIDTH = NativeMethods.LVM_GETSTRINGWIDTHA; - LVM_EDITLABEL = NativeMethods.LVM_EDITLABELA; - LVM_GETCOLUMN = NativeMethods.LVM_GETCOLUMNA; - LVM_SETCOLUMN = NativeMethods.LVM_SETCOLUMNA; - LVM_GETISEARCHSTRING = NativeMethods.LVM_GETISEARCHSTRINGA; - LVM_INSERTCOLUMN = NativeMethods.LVM_INSERTCOLUMNA; - LVN_BEGINLABELEDIT = NativeMethods.LVN_BEGINLABELEDITA; - LVN_ENDLABELEDIT = NativeMethods.LVN_ENDLABELEDITA; - LVN_ODFINDITEM = NativeMethods.LVN_ODFINDITEMA; - LVN_GETDISPINFO = NativeMethods.LVN_GETDISPINFOA; - LVN_GETINFOTIP = NativeMethods.LVN_GETINFOTIPA; - LVN_SETDISPINFO = NativeMethods.LVN_SETDISPINFOA; - PSM_SETTITLE = NativeMethods.PSM_SETTITLEA; - PSM_SETFINISHTEXT = NativeMethods.PSM_SETFINISHTEXTA; - RB_INSERTBAND = NativeMethods.RB_INSERTBANDA; - SB_SETTEXT = NativeMethods.SB_SETTEXTA; - SB_GETTEXT = NativeMethods.SB_GETTEXTA; - SB_GETTEXTLENGTH = NativeMethods.SB_GETTEXTLENGTHA; - SB_SETTIPTEXT = NativeMethods.SB_SETTIPTEXTA; - SB_GETTIPTEXT = NativeMethods.SB_GETTIPTEXTA; - TB_SAVERESTORE = NativeMethods.TB_SAVERESTOREA; - TB_ADDSTRING = NativeMethods.TB_ADDSTRINGA; - TB_GETBUTTONTEXT = NativeMethods.TB_GETBUTTONTEXTA; - TB_MAPACCELERATOR = NativeMethods.TB_MAPACCELERATORA; - TB_GETBUTTONINFO = NativeMethods.TB_GETBUTTONINFOA; - TB_SETBUTTONINFO = NativeMethods.TB_SETBUTTONINFOA; - TB_INSERTBUTTON = NativeMethods.TB_INSERTBUTTONA; - TB_ADDBUTTONS = NativeMethods.TB_ADDBUTTONSA; - TBN_GETBUTTONINFO = NativeMethods.TBN_GETBUTTONINFOA; - TBN_GETINFOTIP = NativeMethods.TBN_GETINFOTIPA; - TBN_GETDISPINFO = NativeMethods.TBN_GETDISPINFOA; - TTM_ADDTOOL = NativeMethods.TTM_ADDTOOLA; - TTM_SETTITLE = NativeMethods.TTM_SETTITLEA; - TTM_DELTOOL = NativeMethods.TTM_DELTOOLA; - TTM_NEWTOOLRECT = NativeMethods.TTM_NEWTOOLRECTA; - TTM_GETTOOLINFO = NativeMethods.TTM_GETTOOLINFOA; - TTM_SETTOOLINFO = NativeMethods.TTM_SETTOOLINFOA; - TTM_HITTEST = NativeMethods.TTM_HITTESTA; - TTM_GETTEXT = NativeMethods.TTM_GETTEXTA; - TTM_UPDATETIPTEXT = NativeMethods.TTM_UPDATETIPTEXTA; - TTM_ENUMTOOLS = NativeMethods.TTM_ENUMTOOLSA; - TTM_GETCURRENTTOOL = NativeMethods.TTM_GETCURRENTTOOLA; - TTN_GETDISPINFO = NativeMethods.TTN_GETDISPINFOA; - TTN_NEEDTEXT = NativeMethods.TTN_NEEDTEXTA; - TVM_INSERTITEM = NativeMethods.TVM_INSERTITEMA; - TVM_GETITEM = NativeMethods.TVM_GETITEMA; - TVM_SETITEM = NativeMethods.TVM_SETITEMA; - TVM_EDITLABEL = NativeMethods.TVM_EDITLABELA; - TVM_GETISEARCHSTRING = NativeMethods.TVM_GETISEARCHSTRINGA; - TVN_SELCHANGING = NativeMethods.TVN_SELCHANGINGA; - TVN_SELCHANGED = NativeMethods.TVN_SELCHANGEDA; - TVN_GETDISPINFO = NativeMethods.TVN_GETDISPINFOA; - TVN_SETDISPINFO = NativeMethods.TVN_SETDISPINFOA; - TVN_ITEMEXPANDING = NativeMethods.TVN_ITEMEXPANDINGA; - TVN_ITEMEXPANDED = NativeMethods.TVN_ITEMEXPANDEDA; - TVN_BEGINDRAG = NativeMethods.TVN_BEGINDRAGA; - TVN_BEGINRDRAG = NativeMethods.TVN_BEGINRDRAGA; - TVN_BEGINLABELEDIT = NativeMethods.TVN_BEGINLABELEDITA; - TVN_ENDLABELEDIT = NativeMethods.TVN_ENDLABELEDITA; - TCM_GETITEM = NativeMethods.TCM_GETITEMA; - TCM_SETITEM = NativeMethods.TCM_SETITEMA; - TCM_INSERTITEM = NativeMethods.TCM_INSERTITEMA; - } - else { - CBEM_GETITEM = NativeMethods.CBEM_GETITEMW; - CBEM_SETITEM = NativeMethods.CBEM_SETITEMW; - CBEN_ENDEDIT = NativeMethods.CBEN_ENDEDITW; - CBEM_INSERTITEM = NativeMethods.CBEM_INSERTITEMW; - LVM_GETITEMTEXT = NativeMethods.LVM_GETITEMTEXTW; - LVM_SETITEMTEXT = NativeMethods.LVM_SETITEMTEXTW; - ACM_OPEN = NativeMethods.ACM_OPENW; - DTM_SETFORMAT = NativeMethods.DTM_SETFORMATW; - DTN_USERSTRING = NativeMethods.DTN_USERSTRINGW; - DTN_WMKEYDOWN = NativeMethods.DTN_WMKEYDOWNW; - DTN_FORMAT = NativeMethods.DTN_FORMATW; - DTN_FORMATQUERY = NativeMethods.DTN_FORMATQUERYW; - EMR_POLYTEXTOUT = NativeMethods.EMR_POLYTEXTOUTW; - HDM_INSERTITEM = NativeMethods.HDM_INSERTITEMW; - HDM_GETITEM = NativeMethods.HDM_GETITEMW; - HDM_SETITEM = NativeMethods.HDM_SETITEMW; - HDN_ITEMCHANGING = NativeMethods.HDN_ITEMCHANGINGW; - HDN_ITEMCHANGED = NativeMethods.HDN_ITEMCHANGEDW; - HDN_ITEMCLICK = NativeMethods.HDN_ITEMCLICKW; - HDN_ITEMDBLCLICK = NativeMethods.HDN_ITEMDBLCLICKW; - HDN_DIVIDERDBLCLICK = NativeMethods.HDN_DIVIDERDBLCLICKW; - HDN_BEGINTRACK = NativeMethods.HDN_BEGINTRACKW; - HDN_ENDTRACK = NativeMethods.HDN_ENDTRACKW; - HDN_TRACK = NativeMethods.HDN_TRACKW; - HDN_GETDISPINFO = NativeMethods.HDN_GETDISPINFOW; - LVM_SETBKIMAGE = NativeMethods.LVM_SETBKIMAGEW; - LVM_GETITEM = NativeMethods.LVM_GETITEMW; - LVM_SETITEM = NativeMethods.LVM_SETITEMW; - LVM_INSERTITEM = NativeMethods.LVM_INSERTITEMW; - LVM_FINDITEM = NativeMethods.LVM_FINDITEMW; - LVM_GETSTRINGWIDTH = NativeMethods.LVM_GETSTRINGWIDTHW; - LVM_EDITLABEL = NativeMethods.LVM_EDITLABELW; - LVM_GETCOLUMN = NativeMethods.LVM_GETCOLUMNW; - LVM_SETCOLUMN = NativeMethods.LVM_SETCOLUMNW; - LVM_GETISEARCHSTRING = NativeMethods.LVM_GETISEARCHSTRINGW; - LVM_INSERTCOLUMN = NativeMethods.LVM_INSERTCOLUMNW; - LVN_BEGINLABELEDIT = NativeMethods.LVN_BEGINLABELEDITW; - LVN_ENDLABELEDIT = NativeMethods.LVN_ENDLABELEDITW; - LVN_ODFINDITEM = NativeMethods.LVN_ODFINDITEMW; - LVN_GETDISPINFO = NativeMethods.LVN_GETDISPINFOW; - LVN_GETINFOTIP = NativeMethods.LVN_GETINFOTIPW; - LVN_SETDISPINFO = NativeMethods.LVN_SETDISPINFOW; - PSM_SETTITLE = NativeMethods.PSM_SETTITLEW; - PSM_SETFINISHTEXT = NativeMethods.PSM_SETFINISHTEXTW; - RB_INSERTBAND = NativeMethods.RB_INSERTBANDW; - SB_SETTEXT = NativeMethods.SB_SETTEXTW; - SB_GETTEXT = NativeMethods.SB_GETTEXTW; - SB_GETTEXTLENGTH = NativeMethods.SB_GETTEXTLENGTHW; - SB_SETTIPTEXT = NativeMethods.SB_SETTIPTEXTW; - SB_GETTIPTEXT = NativeMethods.SB_GETTIPTEXTW; - TB_SAVERESTORE = NativeMethods.TB_SAVERESTOREW; - TB_ADDSTRING = NativeMethods.TB_ADDSTRINGW; - TB_GETBUTTONTEXT = NativeMethods.TB_GETBUTTONTEXTW; - TB_MAPACCELERATOR = NativeMethods.TB_MAPACCELERATORW; - TB_GETBUTTONINFO = NativeMethods.TB_GETBUTTONINFOW; - TB_SETBUTTONINFO = NativeMethods.TB_SETBUTTONINFOW; - TB_INSERTBUTTON = NativeMethods.TB_INSERTBUTTONW; - TB_ADDBUTTONS = NativeMethods.TB_ADDBUTTONSW; - TBN_GETBUTTONINFO = NativeMethods.TBN_GETBUTTONINFOW; - TBN_GETINFOTIP = NativeMethods.TBN_GETINFOTIPW; - TBN_GETDISPINFO = NativeMethods.TBN_GETDISPINFOW; - TTM_ADDTOOL = NativeMethods.TTM_ADDTOOLW; - TTM_SETTITLE = NativeMethods.TTM_SETTITLEW; - TTM_DELTOOL = NativeMethods.TTM_DELTOOLW; - TTM_NEWTOOLRECT = NativeMethods.TTM_NEWTOOLRECTW; - TTM_GETTOOLINFO = NativeMethods.TTM_GETTOOLINFOW; - TTM_SETTOOLINFO = NativeMethods.TTM_SETTOOLINFOW; - TTM_HITTEST = NativeMethods.TTM_HITTESTW; - TTM_GETTEXT = NativeMethods.TTM_GETTEXTW; - TTM_UPDATETIPTEXT = NativeMethods.TTM_UPDATETIPTEXTW; - TTM_ENUMTOOLS = NativeMethods.TTM_ENUMTOOLSW; - TTM_GETCURRENTTOOL = NativeMethods.TTM_GETCURRENTTOOLW; - TTN_GETDISPINFO = NativeMethods.TTN_GETDISPINFOW; - TTN_NEEDTEXT = NativeMethods.TTN_NEEDTEXTW; - TVM_INSERTITEM = NativeMethods.TVM_INSERTITEMW; - TVM_GETITEM = NativeMethods.TVM_GETITEMW; - TVM_SETITEM = NativeMethods.TVM_SETITEMW; - TVM_EDITLABEL = NativeMethods.TVM_EDITLABELW; - TVM_GETISEARCHSTRING = NativeMethods.TVM_GETISEARCHSTRINGW; - TVN_SELCHANGING = NativeMethods.TVN_SELCHANGINGW; - TVN_SELCHANGED = NativeMethods.TVN_SELCHANGEDW; - TVN_GETDISPINFO = NativeMethods.TVN_GETDISPINFOW; - TVN_SETDISPINFO = NativeMethods.TVN_SETDISPINFOW; - TVN_ITEMEXPANDING = NativeMethods.TVN_ITEMEXPANDINGW; - TVN_ITEMEXPANDED = NativeMethods.TVN_ITEMEXPANDEDW; - TVN_BEGINDRAG = NativeMethods.TVN_BEGINDRAGW; - TVN_BEGINRDRAG = NativeMethods.TVN_BEGINRDRAGW; - TVN_BEGINLABELEDIT = NativeMethods.TVN_BEGINLABELEDITW; - TVN_ENDLABELEDIT = NativeMethods.TVN_ENDLABELEDITW; - TCM_GETITEM = NativeMethods.TCM_GETITEMW; - TCM_SETITEM = NativeMethods.TCM_SETITEMW; - TCM_INSERTITEM = NativeMethods.TCM_INSERTITEMW; - } - } - - /* - * MISCELLANEOUS - */ - - [StructLayout(LayoutKind.Sequential), CLSCompliant(false)] - public class OLECMD { - [MarshalAs(UnmanagedType.U4)] - public uint cmdID; - [MarshalAs(UnmanagedType.U4)] - public uint cmdf; - } - - [ComVisible(true), ComImport(), Guid("B722BCCB-4E68-101B-A2BC-00AA00404770"), - InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown), CLSCompliantAttribute(false)] - public interface IOleCommandTarget - { - - [return: MarshalAs(UnmanagedType.I4)] - [PreserveSig] - int QueryStatus( - ref Guid pguidCmdGroup, - int cCmds, - [In, Out] - OLECMD prgCmds, - [In, Out] - IntPtr pCmdText); - - [return: MarshalAs(UnmanagedType.I4)] - [PreserveSig] - int Exec( - ref Guid pguidCmdGroup, - int nCmdID, - int nCmdexecopt, - // we need to have this an array because callers need to be able to specify NULL or VT_NULL - [In, MarshalAs(UnmanagedType.LPArray)] - Object[] pvaIn, - int pvaOut); - } -#endif public static int SignedHIWORD(int n) { int i = (int)(short)((n >> 16) & 0xffff); @@ -2546,210 +1520,6 @@ public static int SignedLOWORD(int n) return i; } -#if never - - /// - /// - /// This is a new class used in Imagelist to get the system Imagelist List for Small and Large Icons. - /// - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class SHFILEINFO { - public IntPtr hIcon; - public int iIcon; - public int cbWndExtra; - public int dwAttributes; - public string szDisplayName; - public string szTyoeName; - } - - - /// - /// - /// - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - public class FONTDESC { - public int cbSizeOfStruct = SizeOf(); - public string lpstrName; - public long cySize; - public short sWeight; - public short sCharset; - public bool fItalic; - public bool fUnderline; - public bool fStrikethrough; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(FONTDESC)); - } - } - - - /// - /// - /// - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - public class FLASHWINFO { - public int cbSize = SizeOf(); - public IntPtr hWnd; - public int dwFlags; - public int uCount; - public int dwTimeOut; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(FLASHWINFO)); - } - } - - /// - /// - /// - [StructLayout(LayoutKind.Sequential)] - public class PICTDESCbmp { - internal int cbSizeOfStruct = SizeOf(); - internal int picType = Ole.PICTYPE_BITMAP; - internal IntPtr hbitmap = IntPtr.Zero; - internal IntPtr hpalette = IntPtr.Zero; - internal int unused = 0; - - public PICTDESCbmp(System.Drawing.Bitmap bitmap) { - hbitmap = bitmap.GetHbitmap(); - // gpr: What about palettes? - } - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(PICTDESCbmp)); - } - } - - /// - /// - /// - [StructLayout(LayoutKind.Sequential)] - public class PICTDESCicon { - internal int cbSizeOfStruct = SizeOf(); - internal int picType = Ole.PICTYPE_ICON; - internal IntPtr hicon = IntPtr.Zero; - internal int unused1 = 0; - internal int unused2 = 0; - - public PICTDESCicon(System.Drawing.Icon icon) { - hicon = SafeNativeMethods.CopyImage(new HandleRef(icon, icon.Handle), NativeMethods.IMAGE_ICON, icon.Size.Width, icon.Size.Height, 0); - } - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(PICTDESCicon)); - } - } - - /// - /// - /// - [StructLayout(LayoutKind.Sequential)] - public class PICTDESCemf { - internal int cbSizeOfStruct = SizeOf(); - internal int picType = Ole.PICTYPE_ENHMETAFILE; - internal IntPtr hemf = IntPtr.Zero; - internal int unused1 = 0; - internal int unused2 = 0; - - public PICTDESCemf(System.Drawing.Imaging.Metafile metafile) { - //gpr hemf = metafile.CopyHandle(); - } - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(PICTDESCemf)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class USEROBJECTFLAGS { - public int fInherit = 0; - public int fReserved = 0; - public int dwFlags = 0; - } - - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)] - internal class SYSTEMTIMEARRAY { - public short wYear1; - public short wMonth1; - public short wDayOfWeek1; - public short wDay1; - public short wHour1; - public short wMinute1; - public short wSecond1; - public short wMilliseconds1; - public short wYear2; - public short wMonth2; - public short wDayOfWeek2; - public short wDay2; - public short wHour2; - public short wMinute2; - public short wSecond2; - public short wMilliseconds2; - } - - public delegate bool EnumChildrenCallback(IntPtr hwnd, IntPtr lParam); - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class HH_AKLINK { - internal int cbStruct=SizeOf(); - internal bool fReserved; - internal string pszKeywords; - internal string pszUrl; - internal string pszMsgText; - internal string pszMsgTitle; - internal string pszWindow; - internal bool fIndexOnFail; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(HH_AKLINK)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class HH_POPUP { - internal int cbStruct=SizeOf(); - internal IntPtr hinst = IntPtr.Zero; - internal int idString = 0; - internal IntPtr pszText; - internal POINT pt; - internal int clrForeground = -1; - internal int clrBackground = -1; - internal RECT rcMargins = RECT.FromXYWH(-1, -1, -1, -1); // amount of space between edges of window and text, -1 for each member to ignore - internal string pszFont = null; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(HH_POPUP)); - } - } - - public static readonly int HH_FTS_DEFAULT_PROXIMITY = -1; - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class HH_FTS_QUERY { - internal int cbStruct = SizeOf(); - internal bool fUniCodeStrings; - [MarshalAs(UnmanagedType.LPStr)] - internal string pszSearchQuery; - internal int iProximity = NativeMethods.HH_FTS_DEFAULT_PROXIMITY; - internal bool fStemmedSearch; - internal bool fTitleOnly; - internal bool fExecute = true; - [MarshalAs(UnmanagedType.LPStr)] - internal string pszWindow; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(HH_FTS_QUERY)); - } - } -#endif [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto, Pack=4)] public class MONITORINFOEX { @@ -2765,222 +1535,6 @@ private static int SizeOf() return Marshal.SizeOf(typeof(MONITORINFOEX)); } } -#if never - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto, Pack=4)] - public class MONITORINFO { - internal int cbSize = SizeOf(); - internal RECT rcMonitor = new RECT(); - internal RECT rcWork = new RECT(); - internal int dwFlags = 0; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(MONITORINFO)); - } - } - - public delegate bool EnumChildrenProc(IntPtr hwnd, IntPtr lParam); - public delegate int EditStreamCallback(IntPtr dwCookie, IntPtr buf, int cb, out int transferred); - - [StructLayout(LayoutKind.Sequential)] - public class EDITSTREAM { - public IntPtr dwCookie = IntPtr.Zero; - public int dwError = 0; - public EditStreamCallback pfnCallback = null; - } - - [StructLayout(LayoutKind.Sequential)] - public class EDITSTREAM64 { - [MarshalAs(UnmanagedType.ByValArray, SizeConst=20)] - public byte[] contents = new byte[20]; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct DEVMODE - { - private const int CCHDEVICENAME = 32; - private const int CCHFORMNAME = 32; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHDEVICENAME)] - public string dmDeviceName; - public short dmSpecVersion; - public short dmDriverVersion; - public short dmSize; - public short dmDriverExtra; - public int dmFields; - public int dmPositionX; - public int dmPositionY; - public ScreenOrientation dmDisplayOrientation; - public int dmDisplayFixedOutput; - public short dmColor; - public short dmDuplex; - public short dmYResolution; - public short dmTTOption; - public short dmCollate; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHFORMNAME)] - public string dmFormName; - public short dmLogPixels; - public int dmBitsPerPel; - public int dmPelsWidth; - public int dmPelsHeight; - public int dmDisplayFlags; - public int dmDisplayFrequency; - public int dmICMMethod; - public int dmICMIntent; - public int dmMediaType; - public int dmDitherType; - public int dmReserved1; - public int dmReserved2; - public int dmPanningWidth; - public int dmPanningHeight; - } - - [ComImport(), Guid("0FF510A3-5FA5-49F1-8CCC-190D71083F3E"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IVsPerPropertyBrowsing { - // hides the property at the given dispid from the properties window - // implmentors should can return E_NOTIMPL to show all properties that - // are otherwise browsable. - - [PreserveSig] - int HideProperty(int dispid,ref bool pfHide); - - // will have the "+" expandable glyph next to them and can be expanded or collapsed by the user - // Returning a non-S_OK return code or false for pfDisplay will suppress this feature - - [PreserveSig] - int DisplayChildProperties(int dispid, - ref bool pfDisplay); - - // retrieves the localized name and description for a property. - // returning a non-S_OK return code will display the default values - - [PreserveSig] - int GetLocalizedPropertyInfo(int dispid, int localeID, - [Out, MarshalAs(UnmanagedType.LPArray)] - string[] pbstrLocalizedName, - [Out, MarshalAs(UnmanagedType.LPArray)] - string[] pbstrLocalizeDescription); - - // determines if the given (usually current) value for a property is the default. If it is not default, - // the property will be shown as bold in the browser to indcate that it has been modified from the default. - - [PreserveSig] - int HasDefaultValue(int dispid, - ref bool fDefault); - - // determines if a property should be made read only. This only applies to properties that are writeable, - [PreserveSig] - int IsPropertyReadOnly(int dispid, - ref bool fReadOnly); - - - // returns the classname for this object. The class name is the non-bolded text that appears in the - // properties window selection combo. If this method returns a non-S_OK return code, the default - // will be used. The default is the name string from a call to ITypeInfo::GetDocumentation(MEMID_NIL, ...); - [PreserveSig] - int GetClassName([In, Out]ref string pbstrClassName); - - // checks whether the given property can be reset to some default value. If return value is non-S_OK or *pfCanReset is - // - [PreserveSig] - int CanResetPropertyValue(int dispid, [In, Out]ref bool pfCanReset); - - // given property. If the return value is S_OK, the property's value will then be refreshed to the new default - // values. - [PreserveSig] - int ResetPropertyValue(int dispid); - } - - [ComImport(), Guid("7494683C-37A0-11d2-A273-00C04F8EF4FF"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IManagedPerPropertyBrowsing { - - - [PreserveSig] - int GetPropertyAttributes(int dispid, - ref int pcAttributes, - ref IntPtr pbstrAttrNames, - ref IntPtr pvariantInitValues); - } - - [ComImport(), Guid("33C0C1D8-33CF-11d3-BFF2-00C04F990235"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IProvidePropertyBuilder { - - [PreserveSig] - int MapPropertyToBuilder( - int dispid, - [In, Out, MarshalAs(UnmanagedType.LPArray)] - int[] pdwCtlBldType, - [In, Out, MarshalAs(UnmanagedType.LPArray)] - string[] pbstrGuidBldr, - - [In, Out, MarshalAs(UnmanagedType.Bool)] - ref bool builderAvailable); - - [PreserveSig] - int ExecuteBuilder( - int dispid, - [In, MarshalAs(UnmanagedType.BStr)] - string bstrGuidBldr, - [In, MarshalAs(UnmanagedType.Interface)] - object pdispApp, - - HandleRef hwndBldrOwner, - [Out, In, MarshalAs(UnmanagedType.Struct)] - ref object pvarValue, - [In, Out, MarshalAs(UnmanagedType.Bool)] - ref bool actionCommitted); - } - - [StructLayout(LayoutKind.Sequential)] - public class INITCOMMONCONTROLSEX { - public int dwSize = SizeOf(); - public int dwICC; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(MONITORINFO)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class IMAGELISTDRAWPARAMS { - public int cbSize = SizeOf(); - public IntPtr himl; - public int i; - public IntPtr hdcDst; - public int x; - public int y; - public int cx; - public int cy; - public int xBitmap; - public int yBitmap; - public int rgbBk; - public int rgbFg; - public int fStyle; - public int dwRop; - public int fState; - public int Frame; - public int crEffect; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(IMAGELISTDRAWPARAMS)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class IMAGEINFO { - public IntPtr hbmImage; - public IntPtr hbmMask; - public int Unused1; - public int Unused2; - // rcImage was a by-value RECT structure - public int rcImage_left; - public int rcImage_top; - public int rcImage_right; - public int rcImage_bottom; - } -#endif [StructLayout(LayoutKind.Sequential)] public class TRACKMOUSEEVENT { @@ -3013,40 +1567,6 @@ public override string ToString() { public delegate IntPtr WndProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam); - -#if never - [StructLayout(LayoutKind.Sequential)] - public struct RECT { - public int left; - public int top; - public int right; - public int bottom; - - public RECT(int left, int top, int right, int bottom) { - this.left = left; - this.top = top; - this.right = right; - this.bottom = bottom; - } - - public RECT(System.Drawing.Rectangle r) { - this.left = r.Left; - this.top = r.Top; - this.right = r.Right; - this.bottom = r.Bottom; - } - - public static RECT FromXYWH(int x, int y, int width, int height) { - return new RECT(x, y, x + width, y + height); - } - - public System.Drawing.Size Size { - get { - return new System.Drawing.Size(this.right - this.left, this.bottom - this.top); - } - } - } -#endif [StructLayout(LayoutKind.Sequential)] public struct MARGINS { public int cxLeftWidth; @@ -3054,40 +1574,6 @@ public struct MARGINS { public int cyTopHeight; public int cyBottomHeight; } -#if never - - public delegate int ListViewCompareCallback(IntPtr lParam1, IntPtr lParam2, IntPtr lParamSort); - - public delegate int TreeViewCompareCallback(IntPtr lParam1, IntPtr lParam2, IntPtr lParamSort); - - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class WNDCLASS { - public int style = 0; - public IntPtr lpfnWndProc = IntPtr.Zero; - public int cbClsExtra = 0; - public int cbWndExtra = 0; - public IntPtr hInstance = IntPtr.Zero; - public IntPtr hIcon = IntPtr.Zero; - public IntPtr hCursor = IntPtr.Zero; - public IntPtr hbrBackground = IntPtr.Zero; - public string lpszMenuName = null; - public string lpszClassName = null; - } - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class WNDCLASS_I { - public int style = 0; - public IntPtr lpfnWndProc = IntPtr.Zero; - public int cbClsExtra = 0; - public int cbWndExtra = 0; - public IntPtr hInstance = IntPtr.Zero; - public IntPtr hIcon = IntPtr.Zero; - public IntPtr hCursor = IntPtr.Zero; - public IntPtr hbrBackground = IntPtr.Zero; - public IntPtr lpszMenuName = IntPtr.Zero; - public IntPtr lpszClassName = IntPtr.Zero; - } -#endif [StructLayout(LayoutKind.Sequential)] public class NONCLIENTMETRICS { @@ -3153,57 +1639,13 @@ public struct PAINTSTRUCT { public int reserved7; public int reserved8; } -#if never + +#if FRAMEWORK_NATIVEMETHODS || CORE_NATIVEMETHODS || BASE_NATIVEMETHODS || DRT_SEE_NATIVEMETHODS || UIAUTOMATIONTYPES [StructLayout(LayoutKind.Sequential)] - public class SCROLLINFO { - public int cbSize = SizeOf(); - public int fMask; - public int nMin; - public int nMax; - public int nPage; - public int nPos; - public int nTrackPos; - - public SCROLLINFO() { - } - - public SCROLLINFO(int mask, int min, int max, int page, int pos) { - fMask = mask; - nMin = min; - nMax = max; - nPage = page; - nPos = pos; - } - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(SCROLLINFO)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class TPMPARAMS { - public int cbSize = SizeOf(); - // rcExclude was a by-value RECT structure - public int rcExclude_left; - public int rcExclude_top; - public int rcExclude_right; - public int rcExclude_bottom; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(TPMPARAMS)); - } - } -#endif - -#if FRAMEWORK_NATIVEMETHODS || CORE_NATIVEMETHODS || BASE_NATIVEMETHODS || DRT_SEE_NATIVEMETHODS || UIAUTOMATIONTYPES - - [StructLayout(LayoutKind.Sequential)] - public class SIZE { - public int cx; - public int cy; + public class SIZE { + public int cx; + public int cy; public SIZE() { @@ -3234,292 +1676,6 @@ public struct WINDOWPLACEMENT { public int rcNormalPosition_right; public int rcNormalPosition_bottom; } -#if never - - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)] - public class STARTUPINFO { - public int cb; - public string lpReserved; - public string lpDesktop; - public string lpTitle; - public int dwX; - public int dwY; - public int dwXSize; - public int dwYSize; - public int dwXCountChars; - public int dwYCountChars; - public int dwFillAttribute; - public int dwFlags; - public short wShowWindow; - public short cbReserved2; - public IntPtr lpReserved2; - public IntPtr hStdInput; - public IntPtr hStdOutput; - public IntPtr hStdError; - } - - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)] - public class STARTUPINFO_I { - public int cb; - public IntPtr lpReserved; - public IntPtr lpDesktop; - public IntPtr lpTitle; - public int dwX; - public int dwY; - public int dwXSize; - public int dwYSize; - public int dwXCountChars; - public int dwYCountChars; - public int dwFillAttribute; - public int dwFlags; - public short wShowWindow; - public short cbReserved2; - public IntPtr lpReserved2; - public IntPtr hStdInput; - public IntPtr hStdOutput; - public IntPtr hStdError; - } - - [StructLayout(LayoutKind.Sequential)] - public class PAGESETUPDLG { - public int lStructSize; - public IntPtr hwndOwner; - public IntPtr hDevMode; - public IntPtr hDevNames; - public int Flags; - - //POINT ptPaperSize; - public int paperSizeX; - public int paperSizeY; - - // RECT rtMinMargin; - public int minMarginLeft; - public int minMarginTop; - public int minMarginRight; - public int minMarginBottom; - - // RECT rtMargin; - public int marginLeft; - public int marginTop; - public int marginRight; - public int marginBottom; - - public IntPtr hInstance; - public IntPtr lCustData; - public WndProc lpfnPageSetupHook; - public WndProc lpfnPagePaintHook; - public string lpPageSetupTemplateName; - public IntPtr hPageSetupTemplate; - } - - - - // x86 requires EXPLICIT packing of 1. - [StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Auto)] - public class PRINTDLG { - public int lStructSize; - - public IntPtr hwndOwner; - public IntPtr hDevMode; - public IntPtr hDevNames; - public IntPtr hDC; - - public int Flags; - - public short nFromPage; - public short nToPage; - public short nMinPage; - public short nMaxPage; - public short nCopies; - - public IntPtr hInstance; - public IntPtr lCustData; - - public WndProc lpfnPrintHook; - public WndProc lpfnSetupHook; - - public string lpPrintTemplateName; - public string lpSetupTemplateName; - - public IntPtr hPrintTemplate; - public IntPtr hSetupTemplate; - } - - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class PRINTDLGEX { - public int lStructSize; - - public IntPtr hwndOwner; - public IntPtr hDevMode; - public IntPtr hDevNames; - public IntPtr hDC; - - public int Flags; - public int Flags2; - - public int ExclusionFlags; - - public int nPageRanges; - public int nMaxPageRanges; - - public IntPtr pageRanges; - - public int nMinPage; - public int nMaxPage; - public int nCopies; - - public IntPtr hInstance; - public string lpPrintTemplateName; - - public WndProc lpCallback; - - public int nPropertyPages; - - public IntPtr lphPropertyPages; - - public int nStartPage; - public int dwResultAction; - - } - - // x86 requires EXPLICIT packing of 1. - [StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Auto)] - public class PRINTPAGERANGE { - public int nFromPage; - public int nToPage; - } - - - - [StructLayout(LayoutKind.Sequential)] - public class PICTDESC - { - internal int cbSizeOfStruct; - public int picType; - internal IntPtr union1; - internal int union2; - internal int union3; - - public static PICTDESC CreateBitmapPICTDESC(IntPtr hbitmap, IntPtr hpal) { - PICTDESC pictdesc = new PICTDESC(); - pictdesc.cbSizeOfStruct = 16; - pictdesc.picType = Ole.PICTYPE_BITMAP; - pictdesc.union1 = hbitmap; - pictdesc.union2 = (int)(((long)hpal) & 0xffffffff); - pictdesc.union3 = (int)(((long)hpal) >> 32); - return pictdesc; - } - - public static PICTDESC CreateIconPICTDESC(IntPtr hicon) { - PICTDESC pictdesc = new PICTDESC(); - pictdesc.cbSizeOfStruct = 12; - pictdesc.picType = Ole.PICTYPE_ICON; - pictdesc.union1 = hicon; - return pictdesc; - } - - public static PICTDESC CreateEnhMetafilePICTDESC(IntPtr hEMF) { - PICTDESC pictdesc = new PICTDESC(); - pictdesc.cbSizeOfStruct = 12; - pictdesc.picType = Ole.PICTYPE_ENHMETAFILE; - pictdesc.union1 = hEMF; - return pictdesc; - } - - public static PICTDESC CreateWinMetafilePICTDESC(IntPtr hmetafile, int x, int y) { - PICTDESC pictdesc = new PICTDESC(); - pictdesc.cbSizeOfStruct = 20; - pictdesc.picType = Ole.PICTYPE_METAFILE; - pictdesc.union1 = hmetafile; - pictdesc.union2 = x; - pictdesc.union3 = y; - return pictdesc; - } - - public virtual IntPtr GetHandle() { - return union1; - } - - public virtual IntPtr GetHPal() { - if (picType == Ole.PICTYPE_BITMAP) - return (IntPtr)((uint)union2 | (((long)union3) << 32)); - else - return IntPtr.Zero; - } - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagFONTDESC { - public uint cbSizeofstruct = SizeOf(); - - [MarshalAs(UnmanagedType.LPWStr)] - public string lpstrName; - - [MarshalAs(UnmanagedType.I8)] - public long cySize; - - [MarshalAs(UnmanagedType.I2)] - public short sWeight; - - [MarshalAs(UnmanagedType.I2)] - public short sCharset; - - [MarshalAs(UnmanagedType.Bool)] - public bool fItalic; - - [MarshalAs(UnmanagedType.Bool)] - public bool fUnderline; - - [MarshalAs(UnmanagedType.Bool)] - public bool fStrikethrough; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(tagFONTDESC)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class MMCKINFO { - public int ckID; - public int cksize; - public int fccType; - public int dwDataOffset; - public int dwFlags; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class WAVEFORMATEX { - public System.Int16 wFormatTag; - public System.Int16 nChannels; - public int nSamplesPerSec; - public int nAvgBytesPerSec; - public System.Int16 nBlockAlign; - public System.Int16 wBitsPerSample; - public System.Int16 cbSize; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class CHOOSECOLOR { - public int lStructSize = SizeOf(); //ndirect.DllLib.sizeOf(this); - public IntPtr hwndOwner; - public IntPtr hInstance; - public int rgbResult; - public IntPtr lpCustColors; - public int Flags; - public IntPtr lCustData; - public WndProc lpfnHook; - public string lpTemplateName; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(CHOOSECOLOR)); - } - } - - //public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam); -#endif [StructLayout(LayoutKind.Sequential)] public class BITMAP { @@ -3532,45 +1688,6 @@ public class BITMAP { public int bmBits = 0; } - -#if NEVER - [StructLayout(LayoutKind.Sequential)] - public class ICONINFO { - public int fIcon; - public int xHotspot; - public int yHotspot; - public IntPtr hbmMask; - public IntPtr hbmColor; - } - - - [StructLayout(LayoutKind.Sequential)] - public class DIBSECTION { - public BITMAP dsBm; - public BITMAPINFOHEADER dsBmih; - [MarshalAs(UnmanagedType.ByValArray, SizeConst=3)] - public int[] dsBitfields; - public IntPtr dshSection; - public int dsOffset; - } - - [StructLayout(LayoutKind.Sequential)] - public class LOGPEN { - public int lopnStyle; - // lopnWidth was a by-value POINT structure - public int lopnWidth_x; - public int lopnWidth_y; - public int lopnColor; - } - - [StructLayout(LayoutKind.Sequential)] - public class LOGBRUSH { - public int lbStyle; - public int lbColor; - public IntPtr lbHatch; - } -#endif - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] public class LOGFONT { public LOGFONT() { @@ -3611,82 +1728,6 @@ public LOGFONT( LOGFONT lf ) public string lfFaceName; } -#if NEVER - [StructLayout(LayoutKind.Sequential)] - public class LOGPALETTE { - public short palVersion; - public short palNumEntries; - public int palPalEntry; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - public struct TEXTMETRIC - { - public int tmHeight; - public int tmAscent; - public int tmDescent; - public int tmInternalLeading; - public int tmExternalLeading; - public int tmAveCharWidth; - public int tmMaxCharWidth; - public int tmWeight; - public int tmOverhang; - public int tmDigitizedAspectX; - public int tmDigitizedAspectY; - public char tmFirstChar; - public char tmLastChar; - public char tmDefaultChar; - public char tmBreakChar; - public byte tmItalic; - public byte tmUnderlined; - public byte tmStruckOut; - public byte tmPitchAndFamily; - public byte tmCharSet; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] - public struct TEXTMETRICA - { - public int tmHeight; - public int tmAscent; - public int tmDescent; - public int tmInternalLeading; - public int tmExternalLeading; - public int tmAveCharWidth; - public int tmMaxCharWidth; - public int tmWeight; - public int tmOverhang; - public int tmDigitizedAspectX; - public int tmDigitizedAspectY; - public byte tmFirstChar; - public byte tmLastChar; - public byte tmDefaultChar; - public byte tmBreakChar; - public byte tmItalic; - public byte tmUnderlined; - public byte tmStruckOut; - public byte tmPitchAndFamily; - public byte tmCharSet; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NOTIFYICONDATA { - public int cbSize = SizeOf(); - public IntPtr hWnd; - public int uID; - public int uFlags; - public int uCallbackMessage; - public IntPtr hIcon; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)] - public string szTip; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(NOTIFYICONDATA)); - } - } -#endif - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public class MENUITEMINFO_T { @@ -3707,49 +1748,6 @@ private static int SizeOf() return Marshal.SizeOf(typeof(MENUITEMINFO_T)); } } -#if never - - // This version allows you to read the string that's stuffed - // in the native menu item. You have to do the marshaling on - // your own though. - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class MENUITEMINFO_T_RW - { - public int cbSize = SizeOf(); - public int fMask; - public int fType; - public int fState; - public int wID; - public IntPtr hSubMenu; - public IntPtr hbmpChecked; - public IntPtr hbmpUnchecked; - public IntPtr dwItemData; - public IntPtr dwTypeData; - public int cch; - public IntPtr hbmpItem; // requires WINVER > 5 - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(MENUITEMINFO_T_RW)); - } - } - - - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - public struct MSAAMENUINFO - { - public int dwMSAASignature; - public int cchWText; - public string pszWText; - - public MSAAMENUINFO(string text) { - dwMSAASignature = unchecked((int) MSAA_MENU_SIG); - cchWText = text.Length; - pszWText = text; - } - } -#endif public delegate bool EnumThreadWindowsCallback(IntPtr hWnd, IntPtr lParam); @@ -3821,82 +1819,6 @@ public struct STYLESTRUCT { public int styleNew; } -#if never - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto), CLSCompliantAttribute(false)] - public class CHOOSEFONT { - public int lStructSize = SizeOf(); // ndirect.DllLib.sizeOf(this); - public IntPtr hwndOwner; - public IntPtr hDC; - public IntPtr lpLogFont; - public int iPointSize; - public int Flags; - public int rgbColors; - public IntPtr lCustData; - public WndProc lpfnHook; - public string lpTemplateName; - public IntPtr hInstance; - public string lpszStyle; - public short nFontType; - public short ___MISSING_ALIGNMENT__; - public int nSizeMin; - public int nSizeMax; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(CHOOSEFONT)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class BITMAPINFO { - // bmiHeader was a by-value BITMAPINFOHEADER structure - public int bmiHeader_biSize = 40; // ndirect.DllLib.sizeOf( BITMAPINFOHEADER.class ); - public int bmiHeader_biWidth; - public int bmiHeader_biHeight; - public short bmiHeader_biPlanes; - public short bmiHeader_biBitCount; - public int bmiHeader_biCompression; - public int bmiHeader_biSizeImage; - public int bmiHeader_biXPelsPerMeter; - public int bmiHeader_biYPelsPerMeter; - public int bmiHeader_biClrUsed; - public int bmiHeader_biClrImportant; - - // bmiColors was an embedded array of RGBQUAD structures - public byte bmiColors_rgbBlue; - public byte bmiColors_rgbGreen; - public byte bmiColors_rgbRed; - public byte bmiColors_rgbReserved; - } - - [StructLayout(LayoutKind.Sequential)] - public class BITMAPINFOHEADER { - public int biSize = 40; // ndirect.DllLib.sizeOf( this ); - public int biWidth = 0; - public int biHeight = 0; - public short biPlanes = 0; - public short biBitCount = 0; - public int biCompression = 0; - public int biSizeImage = 0; - public int biXPelsPerMeter = 0; - public int biYPelsPerMeter = 0; - public int biClrUsed = 0; - public int biClrImportant = 0; - } - - - public class Ole { - public const int PICTYPE_UNINITIALIZED = -1; - public const int PICTYPE_NONE = 0; - public const int PICTYPE_BITMAP = 1; - public const int PICTYPE_METAFILE = 2; - public const int PICTYPE_ICON = 3; - public const int PICTYPE_ENHMETAFILE = 4; - public const int STATFLAG_DEFAULT = 0; - public const int STATFLAG_NONAME = 1; - } - -#endif [StructLayout(LayoutKind.Sequential)] public class STATSTG { @@ -3943,59 +1865,6 @@ public class STATSTG [MarshalAs(UnmanagedType.I4)] public int reserved = 0; } -#if never - - [StructLayout(LayoutKind.Sequential)] - public class FILETIME { - public int dwLowDateTime; - public int dwHighDateTime; - } - - [StructLayout(LayoutKind.Sequential)] - public class OVERLAPPED { - public int Internal; - public int InternalHigh; - public int Offset; - public int OffsetHigh; - public IntPtr hEvent; - } - - [StructLayout(LayoutKind.Sequential)] - public class SYSTEMTIME { - public short wYear; - public short wMonth; - public short wDayOfWeek; - public short wDay; - public short wHour; - public short wMinute; - public short wSecond; - public short wMilliseconds; - - public override string ToString() { - return "[SYSTEMTIME: " - + wDay.ToString() +"/" + wMonth.ToString() + "/" + wYear.ToString() - + " " + wHour.ToString() + ":" + wMinute.ToString() + ":" + wSecond.ToString() - + "]"; - } - } - - [ - StructLayout(LayoutKind.Sequential), - CLSCompliantAttribute(false) - ] - public sealed class _POINTL { - public int x; - public int y; - - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagSIZE { - public int cx; - public int cy; - - } -#endif [Serializable] [StructLayout(LayoutKind.Sequential)] @@ -4013,13 +1882,6 @@ public COMRECT(int x, int y, int right, int bottom) this.bottom = bottom; } -// public COMRECT(System.Drawing.Rectangle r) { -// this.left = r.X; -// this.top = r.Y; -// this.right = r.Right; -// this.bottom = r.Bottom; -// } - public COMRECT(RECT rect) { this.left = rect.left; this.top = rect.top; @@ -4036,10 +1898,6 @@ public void CopyTo(COMRECT destRect) { public bool IsEmpty { get { return left == right && top == bottom; } } -// public RECT ToRECT() { -// return new RECT(left, top, right, bottom); -// } - public override string ToString() { return "Left = " + left + " Top " + top + " Right = " + right + " Bottom = " + bottom; } @@ -4051,267 +1909,34 @@ public sealed class tagOleMenuGroupWidths { public int[] widths = new int[6]; } -#if never - [StructLayout(LayoutKind.Sequential)] - [Serializable] - public class MSOCRINFOSTRUCT { - public int cbSize = SizeOf(); // size of MSOCRINFO structure in bytes. - public int uIdleTimeInterval; // If olecrfNeedPeriodicIdleTime is registered - // in grfcrf, component needs to perform - // periodic idle time tasks during an idle phase - // every uIdleTimeInterval milliseconds. - public int grfcrf; // bit flags taken from olecrf values (above) - public int grfcadvf; // bit flags taken from olecadvf values (above) - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(MSOCRINFOSTRUCT)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMLISTVIEW + [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] + public struct POINTF { - public NMHDR hdr; - public int iItem; - public int iSubItem; - public int uNewState; - public int uOldState; - public int uChanged; - public IntPtr lParam; + public float x; + public float y; } - public class ConnectionPointCookie + [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] + public sealed class OLEINPLACEFRAMEINFO { - private UnsafeNativeMethods.IConnectionPoint connectionPoint; - private int cookie; - private static bool connected; - #if DEBUG - private string callStack; - #endif - - /// - /// - /// Creates a connection point to of the given interface type. - /// which will call on a managed code sink that implements that interface. - /// - public ConnectionPointCookie(object source, object sink, Type eventInterface) : this(source, sink, eventInterface, true, out connected){ - } + [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/] + public uint cb; - /// - /// - /// Creates a connection point to of the given interface type. - /// which will call on a managed code sink that implements that interface. - /// - public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException, out bool connected){ - connected = false; - Exception ex = null; - if (source is UnsafeNativeMethods.IConnectionPointContainer) { - UnsafeNativeMethods.IConnectionPointContainer cpc = (UnsafeNativeMethods.IConnectionPointContainer)source; - - try { - Guid tmp = eventInterface.GUID; - if (cpc.FindConnectionPoint(ref tmp, out connectionPoint) != NativeMethods.S_OK) { - connectionPoint = null; - } - } - catch (Exception) { - connectionPoint = null; - } + public bool fMDIApp; + public IntPtr hwndFrame; + public IntPtr hAccel; - if (connectionPoint == null) { - ex = new ArgumentException(SR.GetString(SR.ConnPointSourceIF, eventInterface.Name )); - } - else if (sink == null || !eventInterface.IsInstanceOfType(sink)) { - ex = new InvalidCastException(SR.GetString(SR.ConnPointSinkIF)); - } - else { - int hr = connectionPoint.Advise(sink, ref cookie); - if (hr != S_OK) { - cookie = 0; - Marshal.ReleaseComObject(connectionPoint); - connectionPoint = null; - ex = new ExternalException(SR.GetString(SR.ConnPointAdviseFailed, eventInterface.Name, hr )); - } - else { - connected = true; - } - } - } - else { - ex = new InvalidCastException(SR.GetString(SR.ConnPointSourceIF, "IConnectionPointContainer")); - } + [MarshalAs(UnmanagedType.U4)/*leftover(offset=16, cAccelEntries)*/] + public uint cAccelEntries; + } + [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] + public sealed class tagOLEVERB + { + public int lVerb = 0; - if (throwException && (connectionPoint == null || cookie == 0)) { - if (connectionPoint != null) { - Marshal.ReleaseComObject(connectionPoint); - } - - if (ex == null) { - throw new ArgumentException(SR.GetString(SR.ConnPointCouldNotCreate, eventInterface.Name )); - } - else { - throw ex; - } - } - - #if DEBUG - callStack = Environment.StackTrace; - #endif - } - - /// - /// - /// Disconnect the current connection point. If the object is not connected, - /// this method will do nothing. - /// - public void Disconnect() { - Disconnect(false); - } - - /// - /// - /// Disconnect the current connection point. If the object is not connected, - /// this method will do nothing. - /// - public void Disconnect(bool release) { - if (connectionPoint != null && cookie != 0) { - connectionPoint.Unadvise(cookie); - cookie = 0; - - if (release) { - Marshal.ReleaseComObject(connectionPoint); - } - - connectionPoint = null; - } - } - - /// - /// - ~ConnectionPointCookie(){ - //System.Diagnostics.Debug.Assert(connectionPoint == null || cookie == 0, "We should never finalize an active connection point"); - //Disconnect(); - } - } -#endif - - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public struct POINTF - { - public float x; - public float y; - } - - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public sealed class OLEINPLACEFRAMEINFO - { - [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/] - public uint cb; - - public bool fMDIApp; - public IntPtr hwndFrame; - public IntPtr hAccel; - - [MarshalAs(UnmanagedType.U4)/*leftover(offset=16, cAccelEntries)*/] - public uint cAccelEntries; - } - -#if never - [StructLayout(LayoutKind.Sequential)] - public struct NMLVDISPINFO_UNSAFE - { - // public NMHDR hdr; - public IntPtr hwndFrom; - public IntPtr idFrom; - public int code; - // public LVITEM item; - public int mask; - public int iItem; - public int iSubItem; - public int state; - public int stateMask; - public IntPtr pszText; - public int cchTextMax; - public int iImage; - public IntPtr lParam; - public int iIndent; - public int iGroupId; - public int cColumns; // tile view columns - public IntPtr puColumns; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMHDR - { - public IntPtr hwndFrom; - public IntPtr idFrom; //This is declared as UINT_PTR in winuser.h - public int code; - } - - [ComImport(), Guid("376BD3AA-3845-101B-84ED-08002B2EC713"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IPerPropertyBrowsing { - [PreserveSig] - int GetDisplayString( - int dispID, - [Out, MarshalAs(UnmanagedType.LPArray)] - string[] pBstr); - - [PreserveSig] - int MapPropertyToPage( - int dispID, - [Out] - out Guid pGuid); - - [PreserveSig] - int GetPredefinedStrings( - int dispID, - [Out] - CA_STRUCT pCaStringsOut, - [Out] - CA_STRUCT pCaCookiesOut); - - [PreserveSig] - int GetPredefinedValue( - int dispID, - [In, MarshalAs(UnmanagedType.U4)] - uint dwCookie, - [Out] - VARIANT pVarOut); - } - - [ComImport(), Guid("4D07FC10-F931-11CE-B001-00AA006884E5"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface ICategorizeProperties { - - [PreserveSig] - int MapPropertyToCategory( - int dispID, - ref int categoryID); - - [PreserveSig] - int GetCategoryName( - int propcat, - [In, MarshalAs(UnmanagedType.U4)] - uint lcid, - out string categoryName); - } - - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public sealed class tagSIZEL - { - public int cx = 0; - public int cy = 0; - } -#endif - - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public sealed class tagOLEVERB - { - public int lVerb = 0; - - [MarshalAs(UnmanagedType.LPWStr)] // leftover(offset=4, customMarshal="UniStringMarshaller", lpszVerbName) - public string lpszVerbName = null; + [MarshalAs(UnmanagedType.LPWStr)] // leftover(offset=4, customMarshal="UniStringMarshaller", lpszVerbName) + public string lpszVerbName = null; [MarshalAs(UnmanagedType.U4)] // leftover(offset=8, fuFlags) public uint fuFlags = 0; @@ -4347,16 +1972,9 @@ public sealed class tagCONTROLINFO private static int SizeOf() { return Marshal.SizeOf(typeof(tagCONTROLINFO)); - } - } -#if never - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public sealed class CA_STRUCT - { - public int cElems; - public IntPtr pElems; + } } -#endif + [StructLayout(LayoutKind.Sequential)] public sealed class VARIANT { [MarshalAs(UnmanagedType.I2)] @@ -4372,7 +1990,6 @@ public sealed class VARIANT { public IntPtr data2; - public bool Byref{ get{ return 0 != (vt & (int)tagVT.VT_BYREF); @@ -4404,96 +2021,6 @@ public void SuppressFinalize() GC.SuppressFinalize(this); } -#if never - public static VARIANT FromObject(Object var) { - VARIANT v = new VARIANT(); - - if (var == null) { - v.vt = (int)tagVT.VT_EMPTY; - } - else if (Convert.IsDBNull(var)) { - } - else { - Type t = var.GetType(); - - if (t == typeof(bool)) { - v.vt = (int)tagVT.VT_BOOL; - } - else if (t == typeof(byte)) { - v.vt = (int)tagVT.VT_UI1; - v.data1 = (IntPtr)Convert.ToByte(var); - } - else if (t == typeof(char)) { - v.vt = (int)tagVT.VT_UI2; - v.data1 = (IntPtr)Convert.ToChar(var); - } - else if (t == typeof(string)) { - v.vt = (int)tagVT.VT_BSTR; - v.data1 = SysAllocString(Convert.ToString(var)); - } - else if (t == typeof(short)) { - v.vt = (int)tagVT.VT_I2; - v.data1 = (IntPtr)Convert.ToInt16(var); - } - else if (t == typeof(int)) { - v.vt = (int)tagVT.VT_I4; - v.data1 = (IntPtr)Convert.ToInt32(var); - } - else if (t == typeof(long)) { - v.vt = (int)tagVT.VT_I8; - v.SetLong(Convert.ToInt64(var)); - } - else if (t == typeof(Decimal)) { - v.vt = (int)tagVT.VT_CY; - Decimal c = (Decimal)var; - // SBUrke, it's bizzare that we need to call this as a static! - v.SetLong(Decimal.ToInt64(c)); - } - else if (t == typeof(decimal)) { - v.vt = (int)tagVT.VT_DECIMAL; - Decimal d = Convert.ToDecimal(var); - v.SetLong(Decimal.ToInt64(d)); - } - else if (t == typeof(double)) { - v.vt = (int)tagVT.VT_R8; - // how do we handle double? - } - else if (t == typeof(float) || t == typeof(Single)) { - v.vt = (int)tagVT.VT_R4; - // how do we handle float? - } - else if (t == typeof(DateTime)) { - v.vt = (int)tagVT.VT_DATE; - v.SetLong(Convert.ToDateTime(var).ToFileTime()); - } - else if (t == typeof(SByte)) { - v.vt = (int)tagVT.VT_I1; - v.data1 = (IntPtr)Convert.ToSByte(var); - } - else if (t == typeof(UInt16)) { - v.vt = (int)tagVT.VT_UI2; - v.data1 = (IntPtr)Convert.ToUInt16(var); - } - else if (t == typeof(UInt32)) { - v.vt = (int)tagVT.VT_UI4; - v.data1 = (IntPtr)Convert.ToUInt32(var); - } - else if (t == typeof(UInt64)) { - v.vt = (int)tagVT.VT_UI8; - v.SetLong((long)Convert.ToUInt64(var)); - } - else if (t == typeof(object) || t == typeof(UnsafeNativeMethods.IDispatch) || t.IsCOMObject) { - v.vt = (t == typeof(UnsafeNativeMethods.IDispatch) ? (short)tagVT.VT_DISPATCH : (short)tagVT.VT_UNKNOWN); - v.data1 = Marshal.GetIUnknownForObject(var); - } - else { - Invariant.Assert(false, "Unsupported object type!"); - } - } - return v; - } -#endif - [DllImport(ExternDll.Oleaut32,CharSet=CharSet.Auto)] private static extern IntPtr SysAllocString([In, MarshalAs(UnmanagedType.LPWStr)]string s); @@ -4667,23 +2194,6 @@ private static IntPtr GetRefInt(IntPtr value) { } } -#if never - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public sealed class tagLICINFO - { - [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/] - public int cbLicInfo = SizeOf(); - - public int fRuntimeAvailable; - public int fLicVerified; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(tagLICINFO)); - } - } -#endif - public enum tagVT { VT_EMPTY = 0, VT_NULL = 1, @@ -4737,279 +2247,6 @@ public enum tagVT { } public delegate void TimerProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); -#if never - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class WNDCLASS_D { - public int style; - public WndProc lpfnWndProc; - public int cbClsExtra = 0; - public int cbWndExtra = 0; - public IntPtr hInstance = IntPtr.Zero; - public IntPtr hIcon = IntPtr.Zero; - public IntPtr hCursor = IntPtr.Zero; - public IntPtr hbrBackground = IntPtr.Zero; - public string lpszMenuName = null; - public string lpszClassName = null; - } - - public class MSOCM { - // MSO Component registration flags - public const int msocrfNeedIdleTime = 1; - public const int msocrfNeedPeriodicIdleTime = 2; - public const int msocrfPreTranslateKeys = 4; - public const int msocrfPreTranslateAll = 8; - public const int msocrfNeedSpecActiveNotifs = 16; - public const int msocrfNeedAllActiveNotifs = 32; - public const int msocrfExclusiveBorderSpace = 64; - public const int msocrfExclusiveActivation = 128; - public const int msocrfNeedAllMacEvents = 256; - public const int msocrfMaster = 512; - - // MSO Component registration advise flags (see msocstate enumeration) - public const int msocadvfModal = 1; - public const int msocadvfRedrawOff = 2; - public const int msocadvfWarningsOff = 4; - public const int msocadvfRecording = 8; - - // MSO Component Host flags - public const int msochostfExclusiveBorderSpace = 1; - - // MSO idle flags, passed to IMsoComponent::FDoIdle and - // IMsoStdComponentMgr::FDoIdle. - public const int msoidlefPeriodic = 1; - public const int msoidlefNonPeriodic = 2; - public const int msoidlefPriority = 4; - public const int msoidlefAll = -1; - - // MSO Reasons for pushing a message loop, passed to - // IMsoComponentManager::FPushMessageLoop and - // IMsoComponentHost::FPushMessageLoop. The host should remain in message - // loop until IMsoComponent::FContinueMessageLoop - public const int msoloopMain = -1; // Note this is not an official MSO loop -- it just must be distinct. - public const int msoloopFocusWait = 1; - public const int msoloopDoEvents = 2; - public const int msoloopDebug = 3; - public const int msoloopModalForm = 4; - public const int msoloopModalAlert = 5; - - - /* msocstate values: state IDs passed to - IMsoComponent::OnEnterState, - IMsoComponentManager::OnComponentEnterState/FOnComponentExitState/FInState, - IMsoComponentHost::OnComponentEnterState, - IMsoStdComponentMgr::OnHostEnterState/FOnHostExitState/FInState. - When the host or a component is notified through one of these methods that - another entity (component or host) is entering or exiting a state - identified by one of these state IDs, the host/component should take - appropriate action: - msocstateModal (modal state): - If app is entering modal state, host/component should disable - its toplevel windows, and reenable them when app exits this - state. Also, when this state is entered or exited, host/component - should notify approprate inplace objects via - IOleInPlaceActiveObject::EnableModeless. - msocstateRedrawOff (redrawOff state): - If app is entering redrawOff state, host/component should disable - repainting of its windows, and reenable repainting when app exits - this state. - msocstateWarningsOff (warningsOff state): - If app is entering warningsOff state, host/component should disable - the presentation of any user warnings, and reenable this when - app exits this state. - msocstateRecording (Recording state): - Used to notify host/component when Recording is turned on or off. */ - public const int msocstateModal = 1; - public const int msocstateRedrawOff = 2; - public const int msocstateWarningsOff = 3; - public const int msocstateRecording = 4; - - - /* ** Comments on State Contexts ** - IMsoComponentManager::FCreateSubComponentManager allows one to create a - hierarchical tree of component managers. This tree is used to maintain - multiple contexts with regard to msocstateXXX states. These contexts are - referred to as 'state contexts'. - Each component manager in the tree defines a state context. The - components registered with a particular component manager or any of its - descendents live within that component manager's state context. Calls - to IMsoComponentManager::OnComponentEnterState/FOnComponentExitState - can be used to affect all components, only components within the component - manager's state context, or only those components that are outside of the - component manager's state context. IMsoComponentManager::FInState is used - to query the state of the component manager's state context at its root. - - msoccontext values: context indicators passed to - IMsoComponentManager::OnComponentEnterState/FOnComponentExitState. - These values indicate the state context that is to be affected by the - state change. - In IMsoComponentManager::OnComponentEnterState/FOnComponentExitState, - the comp mgr informs only those components/host that are within the - specified state context. */ - public const int msoccontextAll = 0; - public const int msoccontextMine = 1; - public const int msoccontextOthers = 2; - - /* ** WM_MOUSEACTIVATE Note (for top level compoenents and host) ** - If the active (or tracking) comp's reg info indicates that it - wants mouse messages, then no MA_xxxANDEAT value should be returned - from WM_MOUSEACTIVATE, so that the active (or tracking) comp will be able - to process the resulting mouse message. If one does not want to examine - the reg info, no MA_xxxANDEAT value should be returned from - WM_MOUSEACTIVATE if any comp is active (or tracking). - One can query the reg info of the active (or tracking) component at any - time via IMsoComponentManager::FGetActiveComponent. */ - - /* msogac values: values passed to - IMsoComponentManager::FGetActiveComponent. */ - public const int msogacActive = 0; - public const int msogacTracking = 1; - public const int msogacTrackingOrActive = 2; - - /* msocWindow values: values passed to IMsoComponent::HwndGetWindow. */ - public const int msocWindowFrameToplevel = 0; - public const int msocWindowFrameOwner = 1; - public const int msocWindowComponent = 2; - public const int msocWindowDlgOwner = 3; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class TOOLINFO_T - { - public int cbSize = SizeOf(); - public int uFlags; - public IntPtr hwnd; - public IntPtr uId; - public RECT rect; - public IntPtr hinst; - public string lpszText; - public IntPtr lParam; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(TOOLINFO_T)); - } - } - - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class TOOLINFO_TOOLTIP - { - public int cbSize = SizeOf(); - public int uFlags; - public IntPtr hwnd; - public IntPtr uId; - public RECT rect; - public IntPtr hinst; - public IntPtr lpszText; - public IntPtr lParam; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(TOOLINFO_TOOLTIP)); - } - } - - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagDVTARGETDEVICE { - [MarshalAs(UnmanagedType.U4)] - public uint tdSize; - [MarshalAs(UnmanagedType.U2)] - public ushort tdDriverNameOffset; - [MarshalAs(UnmanagedType.U2)] - public ushort tdDeviceNameOffset; - [MarshalAs(UnmanagedType.U2)] - public ushort tdPortNameOffset; - [MarshalAs(UnmanagedType.U2)] - public ushort tdExtDevmodeOffset; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct TV_ITEM { - public int mask; - public IntPtr hItem; - public int state; - public int stateMask; - public IntPtr /* LPTSTR */ pszText; - public int cchTextMax; - public int iImage; - public int iSelectedImage; - public int cChildren; - public IntPtr lParam; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct TVSORTCB { - public IntPtr hParent; - public NativeMethods.TreeViewCompareCallback lpfnCompare; - public IntPtr lParam; - } - - - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct TV_INSERTSTRUCT { - public IntPtr hParent; - public IntPtr hInsertAfter; - public int item_mask; - public IntPtr item_hItem; - public int item_state; - public int item_stateMask; - public IntPtr /* LPTSTR */ item_pszText; - public int item_cchTextMax; - public int item_iImage; - public int item_iSelectedImage; - public int item_cChildren; - public IntPtr item_lParam; - public int item_iIntegral; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMTREEVIEW - { - public NMHDR nmhdr; - public int action; - public TV_ITEM itemOld; - public TV_ITEM itemNew; - public int ptDrag_X; // This should be declared as POINT - public int ptDrag_Y; // we use unsafe blocks to manipulate - // NMTREEVIEW quickly, and POINT is declared - // as a class. Too much churn to change POINT - // now. - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMTVGETINFOTIP - { - public NMHDR nmhdr; - public string pszText; - public int cchTextMax; - public IntPtr item; - public IntPtr lParam; - - } - - [StructLayout(LayoutKind.Sequential)] - public class NMTVDISPINFO - { - public NMHDR hdr; - public TV_ITEM item; - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class POINTL { - public int x; - public int y; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct HIGHCONTRAST { - public int cbSize; - public int dwFlags; - public string lpszDefaultScheme; - } -#endif [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct HIGHCONTRAST_I { @@ -5017,20 +2254,6 @@ public struct HIGHCONTRAST_I { public int dwFlags; public IntPtr lpszDefaultScheme; } -#if never - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class TCITEM_T - { - public int mask; - public int dwState; - public int dwStateMask; - public string pszText; - public int cchTextMax; - public int iImage; - public IntPtr lParam; - } -#endif [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] public sealed class DISPPARAMS @@ -5043,15 +2266,6 @@ public sealed class DISPPARAMS public uint cNamedArgs; } -#if never - public enum tagINVOKEKIND { - INVOKE_FUNC = 1, - INVOKE_PROPERTYGET = 2, - INVOKE_PROPERTYPUT = 4, - INVOKE_PROPERTYPUTREF = 8 - } -#endif - [StructLayout(LayoutKind.Sequential)] public class EXCEPINFO { [MarshalAs(UnmanagedType.U2)] @@ -5074,68 +2288,6 @@ public class EXCEPINFO { public int scode; } -#if never - public enum tagDESCKIND { - DESCKIND_NONE = 0, - DESCKIND_FUNCDESC = 1, - DESCKIND_VARDESC = 2, - DESCKIND_TYPECOMP = 3, - DESCKIND_IMPLICITAPPOBJ = 4, - DESCKIND_MAX = 5 - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagFUNCDESC { - public int memid; - [MarshalAs(UnmanagedType.U2)] - public short lprgscode; - - // This is marked as NATIVE_TYPE_PTR, - // but the EE doesn't look for that, tries to handle it as - // a ELEMENT_TYPE_VALUECLASS and fails because it - // isn't a NATIVE_TYPE_NESTEDSTRUCT - /*[MarshalAs(UnmanagedType.PTR)]*/ - - public /*NativeMethods.tagELEMDESC*/ IntPtr lprgelemdescParam; - - // cpb, SBurke, the EE chokes on Enums in structs - - public /*NativeMethods.tagFUNCKIND*/ int funckind; - - public /*NativeMethods.tagINVOKEKIND*/ int invkind; - - public /*NativeMethods.tagCALLCONV*/ int callconv; - [MarshalAs(UnmanagedType.I2)] - public short cParams; - [MarshalAs(UnmanagedType.I2)] - public short cParamsOpt; - [MarshalAs(UnmanagedType.I2)] - public short oVft; - [MarshalAs(UnmanagedType.I2)] - public short cScodes; - public NativeMethods.value_tagELEMDESC elemdescFunc; - [MarshalAs(UnmanagedType.U2)] - public ushort wFuncFlags; - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagVARDESC { - public int memid; - public IntPtr lpstrSchema; - public IntPtr unionMember; - public NativeMethods.value_tagELEMDESC elemdescVar; - [MarshalAs(UnmanagedType.U2)] - public ushort wVarFlags; - public /*NativeMethods.tagVARKIND*/ int varkind; - } - - [StructLayout(LayoutKind.Sequential)] - public struct value_tagELEMDESC { - public NativeMethods.tagTYPEDESC tdesc; - public NativeMethods.tagPARAMDESC paramdesc; - } - -#endif [StructLayout(LayoutKind.Sequential)] public struct WINDOWPOS { public IntPtr hwnd; @@ -5146,53 +2298,6 @@ public struct WINDOWPOS { public int cy; public int flags; } -#if never - - [StructLayout(LayoutKind.Sequential)] - public class DRAWITEMSTRUCT { - public int CtlType; - public int CtlID; - public int itemID; - public int itemAction; - public int itemState; - public IntPtr hwndItem; - public IntPtr hDC; - public RECT rcItem; - public IntPtr itemData; - } - - [StructLayout(LayoutKind.Sequential)] - public class MEASUREITEMSTRUCT { - public int CtlType; - public int CtlID; - public int itemID; - public int itemWidth; - public int itemHeight; - public IntPtr itemData; - } - - [StructLayout(LayoutKind.Sequential)] - public class HELPINFO { - public int cbSize = SizeOf(); - public int iContextType; - public int iCtrlId; - public IntPtr hItemHandle; - public int dwContextId; - public POINT MousePos; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(HELPINFO)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class ACCEL { - public byte fVirt; - public short key; - public short cmd; - } -#endif [StructLayout(LayoutKind.Sequential)] public struct MINMAXINFO { @@ -5202,698 +2307,29 @@ public struct MINMAXINFO { public POINT ptMinTrackSize; public POINT ptMaxTrackSize; } -#if never - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class CREATESTRUCT { - public IntPtr lpCreateParams = IntPtr.Zero; - public IntPtr hInstance = IntPtr.Zero; - public IntPtr hMenu = IntPtr.Zero; - public IntPtr hwndParent = IntPtr.Zero; - public int cy = 0; - public int cx = 0; - public int y = 0; - public int x = 0; - public int style = 0; - public string lpszName = null; - public string lpszClass = null; - public int dwExStyle = 0; - } -#endif -#if never - [ComImport(), Guid("B196B28B-BAB4-101A-B69C-00AA00341D07"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface ISpecifyPropertyPages { - void GetPages( - [Out] - NativeMethods.tagCAUUID pPages); + internal abstract class CharBuffer + { + internal static CharBuffer CreateBuffer(int size) + { + if (Marshal.SystemDefaultCharSize == 1) + { + return new AnsiCharBuffer(size); + } + return new UnicodeCharBuffer(size); + } + internal abstract IntPtr AllocCoTaskMem(); + internal abstract string GetString(); + internal abstract void PutCoTaskMem(IntPtr ptr); + internal abstract void PutString(string s); + internal abstract int Length{get;} } - [StructLayout(LayoutKind.Sequential)/*leftover(noAutoOffset)*/] - public sealed class tagCAUUID + internal class AnsiCharBuffer : CharBuffer { - [MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cElems)*/] - public uint cElems; - public IntPtr pElems; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMTOOLBAR - { - public NMHDR hdr; - public int iItem; - public TBBUTTON tbButton; - public int cchText; - public IntPtr pszText; - } - - [StructLayout(LayoutKind.Sequential)] - public struct TBBUTTON { - public int iBitmap; - public int idCommand; - public byte fsState; - public byte fsStyle; - public byte bReserved0; - public byte bReserved1; - public IntPtr dwData; - public IntPtr iString; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class TOOLTIPTEXT - { - public NMHDR hdr; - public IntPtr lpszText; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] - public string szText; - - public IntPtr hinst; - public int uFlags; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] - public class TOOLTIPTEXTA - { - public NMHDR hdr; - public IntPtr lpszText; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)] - public string szText; - - public IntPtr hinst; - public int uFlags; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMTBHOTITEM - { - public NMHDR hdr; - public int idOld; - public int idNew; - public int dwFlags; - } - - public const int HICF_OTHER = 0x00000000; - public const int HICF_MOUSE = 0x00000001; // Triggered by mouse - public const int HICF_ARROWKEYS = 0x00000002; // Triggered by arrow keys - public const int HICF_ACCELERATOR = 0x00000004; // Triggered by accelerator - public const int HICF_DUPACCEL = 0x00000008; // This accelerator is not unique - public const int HICF_ENTERING = 0x00000010; // idOld is invalid - public const int HICF_LEAVING = 0x00000020; // idNew is invalid - public const int HICF_RESELECT = 0x00000040; // hot item reselected - public const int HICF_LMOUSE = 0x00000080; // left mouse button selected - public const int HICF_TOGGLEDROPDOWN = 0x00000100; // Toggle button's dropdown state - - - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)] - public class HDITEM - { - public int mask; - public int cxy; - public string pszText; - public IntPtr hbm; - public int cchTextMax; - public int fmt; - public IntPtr lParam; - public int iImage; - public int iOrder; - public int type; - public IntPtr pvFilter; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct TOOLINFO - { - public int cbSize; - public int uFlags; - public IntPtr hwnd; - public IntPtr uId; - public RECT rect; - public IntPtr hinst; - public string lpszText; - public IntPtr lParam; - } - - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)] - public struct TBBUTTONINFO - { - public int cbSize; - public int dwMask; - public int idCommand; - public int iImage; - public byte fsState; - public byte fsStyle; - public short cx; - public IntPtr lParam; - public IntPtr pszText; - public int cchTest; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class TV_HITTESTINFO { - public int pt_x; - public int pt_y; - public int flags; - public IntPtr hItem; - } - - [StructLayout(LayoutKind.Sequential)] - public class NMTVCUSTOMDRAW - { - public NMCUSTOMDRAW nmcd; - public int clrText; - public int clrTextBk; - public int iLevel; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMCUSTOMDRAW { - public NMHDR nmcd; - public int dwDrawStage; - public IntPtr hdc; - public RECT rc; - public IntPtr dwItemSpec; - public int uItemState; - public IntPtr lItemlParam; - } - - [StructLayout(LayoutKind.Sequential)] - public class NMTTCUSTOMDRAW - { - public NMCUSTOMDRAW nmcd; - public int uDrawFlags; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class MCHITTESTINFO { - public int cbSize = SizeOf(); - public int pt_x; - public int pt_y; - public int uHit; - public short st_wYear; - public short st_wMonth; - public short st_wDayOfWeek; - public short st_wDay; - public short st_wHour; - public short st_wMinute; - public short st_wSecond; - public short st_wMilliseconds; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(MCHITTESTINFO)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMSELCHANGE - { - public NMHDR nmhdr; - public SYSTEMTIME stSelStart; - public SYSTEMTIME stSelEnd; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMDAYSTATE - { - public NMHDR nmhdr; - public SYSTEMTIME stStart; - public int cDayState; - public IntPtr prgDayState; - } - - [StructLayout(LayoutKind.Sequential)] - public struct NMLVCUSTOMDRAW - { - public NMCUSTOMDRAW nmcd; - public int clrText; - public int clrTextBk; - public int iSubItem; - public int dwItemType; - // Item Custom Draw - public int clrFace; - public int iIconEffect; - public int iIconPhase; - public int iPartId; - public int iStateId; - // Group Custom Draw - public RECT rcText; - public uint uAlign; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMLVGETINFOTIP - { - public NMHDR nmhdr; - public int flags; - public IntPtr lpszText; - public int cchTextMax; - public int item; - public int subItem; - public IntPtr lParam; - } - - [StructLayout(LayoutKind.Sequential)] - public class NMLVKEYDOWN - { - public NMHDR hdr; - public short wVKey; - public uint flags; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class LVHITTESTINFO { - public int pt_x; - public int pt_y; - public int flags; - public int iItem; - public int iSubItem; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class LVBKIMAGE - { - public int ulFlags; - public IntPtr hBmp; // not used - public string pszImage; - public int cchImageMax; - public int xOffset; - public int yOffset; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class LVCOLUMN_T - { - public int mask; - public int fmt; - public int cx; - public string pszText; - public int cchTextMax; - public int iSubItem; - public int iImage; - public int iOrder; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct LVFINDINFO { - public int flags; - public string psz; - public IntPtr lParam; - public int ptX; // was POINT pt - public int ptY; - public int vkDirection; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct LVITEM { - public int mask; - public int iItem; - public int iSubItem; - public int state; - public int stateMask; - public string pszText; - public int cchTextMax; - public int iImage; - public IntPtr lParam; - public int iIndent; - public int iGroupId; - public int cColumns; // tile view columns - public IntPtr puColumns; - - public unsafe void Reset() { - pszText = null; - mask = 0; - iItem = 0; - iSubItem = 0; - stateMask = 0; - state = 0; - cchTextMax = 0; - iImage = 0; - lParam = IntPtr.Zero; - iIndent = 0; - iGroupId = 0; - cColumns = 0; - puColumns = IntPtr.Zero; - } - - public override string ToString() { - return "LVITEM: pszText = " + pszText - + ", iItem = " + iItem.ToString() - + ", iSubItem = " + iSubItem.ToString() - + ", state = " + state.ToString() - + ", iGroupId = " + iGroupId.ToString() - + ", cColumns = " + cColumns.ToString(); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public struct LVITEM_NOTEXT { - public int mask; - public int iItem; - public int iSubItem; - public int state; - public int stateMask; - public IntPtr /*string*/ pszText; - public int cchTextMax; - public int iImage; - public IntPtr lParam; - public int iIndent; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class LVCOLUMN { - public int mask; - public int fmt; - public int cx; - public IntPtr /* LPWSTR */ pszText; - public int cchTextMax; - public int iSubItem; - public int iImage; - public int iOrder; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] - public class LVGROUP { - public uint cbSize = (uint)SizeOf(); - public uint mask; - public IntPtr pszHeader; - public int cchHeader; - public IntPtr pszFooter; - public int cchFooter; - public int iGroupId; - public uint stateMask; - public uint state; - public uint uAlign; - - public override string ToString() { - return "LVGROUP: header = " + pszHeader.ToString() + ", iGroupId = " + iGroupId.ToString(); - } - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(LVGROUP)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class LVINSERTMARK { - public uint cbSize = (uint)SizeOf(); - public int dwFlags; - public int iItem; - public int dwReserved = 0; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(LVINSERTMARK)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class LVTILEVIEWINFO { - public uint cbSize = (uint)SizeOf(); - public int dwMask; - public int dwFlags; - public SIZE sizeTile; - public int cLines; - public RECT rcLabelMargin; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(LVTILEVIEWINFO)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMLVCACHEHINT { - public NMHDR hdr; - public int iFrom; - public int iTo; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMLVDISPINFO - { - public NMHDR hdr; - public LVITEM item; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMLVDISPINFO_NOTEXT - { - public NMHDR hdr; - public LVITEM_NOTEXT item; - } - - [StructLayout(LayoutKind.Sequential)] - public class NMLVODSTATECHANGE { - public NMHDR hdr; - public int iFrom; - public int iTo; - public int uNewState; - public int uOldState; - } - - [StructLayout(LayoutKind.Sequential)] - public class CLIENTCREATESTRUCT { - public IntPtr hWindowMenu; - public int idFirstChild; - - public CLIENTCREATESTRUCT(IntPtr hmenu, int idFirst) { - hWindowMenu = hmenu; - idFirstChild = idFirst; - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMDATETIMECHANGE - { - public NMHDR nmhdr; - public int dwFlags; - public SYSTEMTIME st; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMDATETIMEFORMAT - { - public NMHDR nmhdr; - public string pszFormat; - public SYSTEMTIME st; - public string pszDisplay; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] - public string szDisplay; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMDATETIMEFORMATQUERY - { - public NMHDR nmhdr; - public string pszFormat; - public SIZE szMax; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class NMDATETIMEWMKEYDOWN - { - public NMHDR nmhdr; - public int nVirtKey; - public string pszFormat; - public SYSTEMTIME st; - } - - [StructLayout(LayoutKind.Sequential)] - public class COPYDATASTRUCT { - public int dwData; - public int cbData; - public IntPtr lpData; - } - - [StructLayout(LayoutKind.Sequential)] - public class NMHEADER { - public NMHDR nmhdr; - public int iItem; - public int iButton; - public IntPtr pItem; // HDITEM* - } - - [StructLayout(LayoutKind.Sequential)] - public class MOUSEHOOKSTRUCT { - // pt was a by-value POINT structure - public int pt_x = 0; - public int pt_y = 0; - public IntPtr hWnd = IntPtr.Zero; - public int wHitTestCode = 0; - public int dwExtraInfo = 0; - } - - [StructLayout(LayoutKind.Sequential)] - public class CHARRANGE - { - public int cpMin; - public int cpMax; - } - - [StructLayout(LayoutKind.Sequential, Pack=4)] - public class CHARFORMATW - { - public int cbSize = SizeOf(); - public int dwMask; - public int dwEffects; - public int yHeight; - public int yOffset; - public int crTextColor; - public byte bCharSet; - public byte bPitchAndFamily; - [MarshalAs(UnmanagedType.ByValArray, SizeConst=64)] - public byte[] szFaceName = new byte[64]; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(CHARFORMATW)); - } - } - - [StructLayout(LayoutKind.Sequential, Pack=4)] - public class CHARFORMATA - { - public int cbSize = SizeOf(); - public int dwMask; - public int dwEffects; - public int yHeight; - public int yOffset; - public int crTextColor; - public byte bCharSet; - public byte bPitchAndFamily; - [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] - public byte[] szFaceName = new byte[32]; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(CHARFORMATA)); - } - } - - [StructLayout(LayoutKind.Sequential, Pack=4)] - public class CHARFORMAT2A - { - public int cbSize = SizeOf(); - public int dwMask; - public int dwEffects; - public int yHeight; - public int yOffset; - public int crTextColor; - public byte bCharSet; - public byte bPitchAndFamily; - [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] - public byte[] szFaceName = new byte[32]; - public short wWeight; - public short sSpacing; - public int crBackColor; - public int lcid; - public int dwReserved; - public short sStyle; - public short wKerning; - public byte bUnderlineType; - public byte bAnimation; - public byte bRevAuthor; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(CHARFORMAT2A)); - } - } - - [StructLayout(LayoutKind.Sequential)] - public class TEXTRANGE - { - public CHARRANGE chrg; - public IntPtr lpstrText; /* allocated by caller, zero terminated by RichEdit */ - } - - [StructLayout(LayoutKind.Sequential)] - public class GETTEXTLENGTHEX - { // Taken from richedit.h: - public uint flags; // Flags (see GTL_XXX defines) - public uint codepage; // Code page for translation (CP_ACP for default, 1200 for Unicode) - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=4)] - public class SELCHANGE { - public NMHDR nmhdr; - public CHARRANGE chrg; - public int seltyp; - } - - [StructLayout(LayoutKind.Sequential)] - public class PARAFORMAT - { - public int cbSize = SizeOf(); - public int dwMask; - public short wNumbering; - public short wReserved; - public int dxStartIndent; - public int dxRightIndent; - public int dxOffset; - public short wAlignment; - public short cTabCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] - public int[] rgxTabs; - - private static int SizeOf() - { - return Marshal.SizeOf(typeof(PARAFORMAT)); - } - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class FINDTEXT - { - public CHARRANGE chrg; - public string lpstrText; - } - - [StructLayout(LayoutKind.Sequential)] - public class REPASTESPECIAL - { - public int dwAspect; - public int dwParam; - } - - [StructLayout(LayoutKind.Sequential)] - public class ENLINK - { - public NMHDR nmhdr; - public int msg; - public IntPtr wParam; - public IntPtr lParam; - public CHARRANGE charrange; - } -#endif - internal abstract class CharBuffer - { - internal static CharBuffer CreateBuffer(int size) - { - if (Marshal.SystemDefaultCharSize == 1) - { - return new AnsiCharBuffer(size); - } - return new UnicodeCharBuffer(size); - } - - internal abstract IntPtr AllocCoTaskMem(); - internal abstract string GetString(); - internal abstract void PutCoTaskMem(IntPtr ptr); - internal abstract void PutString(string s); - internal abstract int Length{get;} - } - - - internal class AnsiCharBuffer : CharBuffer - { - internal byte[] buffer; - internal int offset; + internal byte[] buffer; + internal int offset; internal AnsiCharBuffer(int size) { @@ -6004,306 +2440,6 @@ internal override void PutString(string s) } } -#if never - [StructLayout(LayoutKind.Sequential)] - public class ENDROPFILES - { - public NMHDR nmhdr; - public IntPtr hDrop; - public int cp; - public bool fProtected; - } - - [StructLayout(LayoutKind.Sequential)] - public class REQRESIZE - { - public NMHDR nmhdr; - public RECT rc; - } - - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] - public class ENPROTECTED - { - public NMHDR nmhdr; - public int msg; - public IntPtr wParam; - public IntPtr lParam; - public CHARRANGE chrg; - } - - [StructLayout(LayoutKind.Sequential)] - public class ENPROTECTED64 - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst=56)] - public byte[] contents = new byte[56]; - } - - public class ActiveX { - public const int OCM__BASE = 0x2000; - public const int DISPID_VALUE = unchecked((int)0x0); - public const int DISPID_UNKNOWN = unchecked((int)0xFFFFFFFF); - public const int DISPID_AUTOSIZE = unchecked((int)0xFFFFFE0C); - public const int DISPID_BACKCOLOR = unchecked((int)0xFFFFFE0B); - public const int DISPID_BACKSTYLE = unchecked((int)0xFFFFFE0A); - public const int DISPID_BORDERCOLOR = unchecked((int)0xFFFFFE09); - public const int DISPID_BORDERSTYLE = unchecked((int)0xFFFFFE08); - public const int DISPID_BORDERWIDTH = unchecked((int)0xFFFFFE07); - public const int DISPID_DRAWMODE = unchecked((int)0xFFFFFE05); - public const int DISPID_DRAWSTYLE = unchecked((int)0xFFFFFE04); - public const int DISPID_DRAWWIDTH = unchecked((int)0xFFFFFE03); - public const int DISPID_FILLCOLOR = unchecked((int)0xFFFFFE02); - public const int DISPID_FILLSTYLE = unchecked((int)0xFFFFFE01); - public const int DISPID_FONT = unchecked((int)0xFFFFFE00); - public const int DISPID_FORECOLOR = unchecked((int)0xFFFFFDFF); - public const int DISPID_ENABLED = unchecked((int)0xFFFFFDFE); - public const int DISPID_HWND = unchecked((int)0xFFFFFDFD); - public const int DISPID_TABSTOP = unchecked((int)0xFFFFFDFC); - public const int DISPID_TEXT = unchecked((int)0xFFFFFDFB); - public const int DISPID_CAPTION = unchecked((int)0xFFFFFDFA); - public const int DISPID_BORDERVISIBLE = unchecked((int)0xFFFFFDF9); - public const int DISPID_APPEARANCE = unchecked((int)0xFFFFFDF8); - public const int DISPID_MOUSEPOINTER = unchecked((int)0xFFFFFDF7); - public const int DISPID_MOUSEICON = unchecked((int)0xFFFFFDF6); - public const int DISPID_PICTURE = unchecked((int)0xFFFFFDF5); - public const int DISPID_VALID = unchecked((int)0xFFFFFDF4); - public const int DISPID_READYSTATE = unchecked((int)0xFFFFFDF3); - public const int DISPID_REFRESH = unchecked((int)0xFFFFFDDA); - public const int DISPID_DOCLICK = unchecked((int)0xFFFFFDD9); - public const int DISPID_ABOUTBOX = unchecked((int)0xFFFFFDD8); - public const int DISPID_CLICK = unchecked((int)0xFFFFFDA8); - public const int DISPID_DBLCLICK = unchecked((int)0xFFFFFDA7); - public const int DISPID_KEYDOWN = unchecked((int)0xFFFFFDA6); - public const int DISPID_KEYPRESS = unchecked((int)0xFFFFFDA5); - public const int DISPID_KEYUP = unchecked((int)0xFFFFFDA4); - public const int DISPID_MOUSEDOWN = unchecked((int)0xFFFFFDA3); - public const int DISPID_MOUSEMOVE = unchecked((int)0xFFFFFDA2); - public const int DISPID_MOUSEUP = unchecked((int)0xFFFFFDA1); - public const int DISPID_ERROREVENT = unchecked((int)0xFFFFFDA0); - public const int DISPID_RIGHTTOLEFT = unchecked((int)0xFFFFFD9D); - public const int DISPID_READYSTATECHANGE = unchecked((int)0xFFFFFD9F); - public const int DISPID_AMBIENT_BACKCOLOR = unchecked((int)0xFFFFFD43); - public const int DISPID_AMBIENT_DISPLAYNAME = unchecked((int)0xFFFFFD42); - public const int DISPID_AMBIENT_FONT = unchecked((int)0xFFFFFD41); - public const int DISPID_AMBIENT_FORECOLOR = unchecked((int)0xFFFFFD40); - public const int DISPID_AMBIENT_LOCALEID = unchecked((int)0xFFFFFD3F); - public const int DISPID_AMBIENT_MESSAGEREFLECT = unchecked((int)0xFFFFFD3E); - public const int DISPID_AMBIENT_SCALEUNITS = unchecked((int)0xFFFFFD3D); - public const int DISPID_AMBIENT_TEXTALIGN = unchecked((int)0xFFFFFD3C); - public const int DISPID_AMBIENT_USERMODE = unchecked((int)0xFFFFFD3B); - public const int DISPID_AMBIENT_UIDEAD = unchecked((int)0xFFFFFD3A); - public const int DISPID_AMBIENT_SHOWGRABHANDLES = unchecked((int)0xFFFFFD39); - public const int DISPID_AMBIENT_SHOWHATCHING = unchecked((int)0xFFFFFD38); - public const int DISPID_AMBIENT_DISPLAYASDEFAULT = unchecked((int)0xFFFFFD37); - public const int DISPID_AMBIENT_SUPPORTSMNEMONICS = unchecked((int)0xFFFFFD36); - public const int DISPID_AMBIENT_AUTOCLIP = unchecked((int)0xFFFFFD35); - public const int DISPID_AMBIENT_APPEARANCE = unchecked((int)0xFFFFFD34); - public const int DISPID_AMBIENT_PALETTE = unchecked((int)0xFFFFFD2A); - public const int DISPID_AMBIENT_TRANSFERPRIORITY = unchecked((int)0xFFFFFD28); - public const int DISPID_AMBIENT_RIGHTTOLEFT = unchecked((int)0xFFFFFD24); - public const int DISPID_Name = unchecked((int)0xFFFFFCE0); - public const int DISPID_Delete = unchecked((int)0xFFFFFCDF); - public const int DISPID_Object = unchecked((int)0xFFFFFCDE); - public const int DISPID_Parent = unchecked((int)0xFFFFFCDD); - public const int DVASPECT_CONTENT = 0x1; - public const int DVASPECT_THUMBNAIL = 0x2; - public const int DVASPECT_ICON = 0x4; - public const int DVASPECT_DOCPRINT = 0x8; - public const int OLEMISC_RECOMPOSEONRESIZE = 0x1; - public const int OLEMISC_ONLYICONIC = 0x2; - public const int OLEMISC_INSERTNOTREPLACE = 0x4; - public const int OLEMISC_STATIC = 0x8; - public const int OLEMISC_CANTLINKINSIDE = 0x10; - public const int OLEMISC_CANLINKBYOLE1 = 0x20; - public const int OLEMISC_ISLINKOBJECT = 0x40; - public const int OLEMISC_INSIDEOUT = 0x80; - public const int OLEMISC_ACTIVATEWHENVISIBLE = 0x100; - public const int OLEMISC_RENDERINGISDEVICEINDEPENDENT = 0x200; - public const int OLEMISC_INVISIBLEATRUNTIME = 0x400; - public const int OLEMISC_ALWAYSRUN = 0x800; - public const int OLEMISC_ACTSLIKEBUTTON = 0x1000; - public const int OLEMISC_ACTSLIKELABEL = 0x2000; - public const int OLEMISC_NOUIACTIVATE = 0x4000; - public const int OLEMISC_ALIGNABLE = 0x8000; - public const int OLEMISC_SIMPLEFRAME = 0x10000; - public const int OLEMISC_SETCLIENTSITEFIRST = 0x20000; - public const int OLEMISC_IMEMODE = 0x40000; - public const int OLEMISC_IGNOREACTIVATEWHENVISIBLE = 0x80000; - public const int OLEMISC_WANTSTOMENUMERGE = 0x100000; - public const int OLEMISC_SUPPORTSMULTILEVELUNDO = 0x200000; - public const int QACONTAINER_SHOWHATCHING = 0x1; - public const int QACONTAINER_SHOWGRABHANDLES = 0x2; - public const int QACONTAINER_USERMODE = 0x4; - public const int QACONTAINER_DISPLAYASDEFAULT = 0x8; - public const int QACONTAINER_UIDEAD = 0x10; - public const int QACONTAINER_AUTOCLIP = 0x20; - public const int QACONTAINER_MESSAGEREFLECT = 0x40; - public const int QACONTAINER_SUPPORTSMNEMONICS = 0x80; - public const int XFORMCOORDS_POSITION = 0x1; - public const int XFORMCOORDS_SIZE = 0x2; - public const int XFORMCOORDS_HIMETRICTOCONTAINER = 0x4; - public const int XFORMCOORDS_CONTAINERTOHIMETRIC = 0x8; - public const int PROPCAT_Nil = unchecked((int)0xFFFFFFFF); - public const int PROPCAT_Misc = unchecked((int)0xFFFFFFFE); - public const int PROPCAT_Font = unchecked((int)0xFFFFFFFD); - public const int PROPCAT_Position = unchecked((int)0xFFFFFFFC); - public const int PROPCAT_Appearance = unchecked((int)0xFFFFFFFB); - public const int PROPCAT_Behavior = unchecked((int)0xFFFFFFFA); - public const int PROPCAT_Data = unchecked((int)0xFFFFFFF9); - public const int PROPCAT_List = unchecked((int)0xFFFFFFF8); - public const int PROPCAT_Text = unchecked((int)0xFFFFFFF7); - public const int PROPCAT_Scale = unchecked((int)0xFFFFFFF6); - public const int PROPCAT_DDE = unchecked((int)0xFFFFFFF5); - public const int GC_WCH_SIBLING = 0x1; - public const int GC_WCH_CONTAINER = 0x2; - public const int GC_WCH_CONTAINED = 0x3; - public const int GC_WCH_ALL = 0x4; - public const int GC_WCH_FREVERSEDIR = 0x8000000; - public const int GC_WCH_FONLYNEXT = 0x10000000; - public const int GC_WCH_FONLYPREV = 0x20000000; - public const int GC_WCH_FSELECTED = 0x40000000; - public const int ALIGN_MIN = 0x0; - public const int ALIGN_NO_CHANGE = 0x0; - public const int ALIGN_TOP = 0x1; - public const int ALIGN_BOTTOM = 0x2; - public const int ALIGN_LEFT = 0x3; - public const int ALIGN_RIGHT = 0x4; - public const int ALIGN_MAX = 0x4; - public const int OLEVERBATTRIB_NEVERDIRTIES = 0x1; - public const int OLEVERBATTRIB_ONCONTAINERMENU = 0x2; - -#endif - -#if NEVER - public static class Util { - public static int MAKELONG(int low, int high) { - return (high << 16) | (low & 0xffff); - } - - public static IntPtr MAKELPARAM(int low, int high) { - return (IntPtr)(MAKELONG(low, high)); - } - - public static int HIWORD(int n) { - return (n >> 16) & 0xffff; - } - - public static int HIWORD(IntPtr n) { - return HIWORD( unchecked((int)(long)n) ); - } - - public static int LOWORD(int n) { - return n & 0xffff; - } - - public static int LOWORD(IntPtr n) { - return LOWORD( unchecked((int)(long)n) ); - } - - public static int SignedHIWORD(IntPtr n) { - return SignedHIWORD( unchecked((int)(long)n) ); - } - public static int SignedLOWORD(IntPtr n) { - return SignedLOWORD( unchecked((int)(long)n) ); - } - - public static int SignedHIWORD(int n) { - int i = (int)(short)((n >> 16) & 0xffff); - - return i; - } - - public static int SignedLOWORD(int n) { - int i = (int)(short)(n & 0xFFFF); - - return i; - } - - /// - /// Computes the string size that should be passed to a typical Win32 call. - /// This will be the character count under NT, and the ubyte count for Windows 95. - /// - public static int GetPInvokeStringLength(String s) { - if (s == null) { - return 0; - } - - if (Marshal.SystemDefaultCharSize == 2) { - return s.Length; - } - else { - if (s.Length == 0) { - return 0; - } - if (s.IndexOf('\0') > -1) { - return GetEmbededNullStringLengthAnsi(s); - } - else { - return lstrlen(s); - } - } - } - - private static int GetEmbededNullStringLengthAnsi(String s) { - int n = s.IndexOf('\0'); - if (n > -1) { - String left = s.Substring(0, n); - String right = s.Substring(n+1); - return GetPInvokeStringLength(left) + GetEmbededNullStringLengthAnsi(right) + 1; - } - else { - return GetPInvokeStringLength(s); - } - } - - [DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto, BestFitMapping = false)] - private static extern int lstrlen(String s); - - } - -#endif - -#if never - - public enum tagTYPEKIND { - TKIND_ENUM = 0, - TKIND_RECORD = 1, - TKIND_MODULE = 2, - TKIND_INTERFACE = 3, - TKIND_DISPATCH = 4, - TKIND_COCLASS = 5, - TKIND_ALIAS = 6, - TKIND_UNION = 7, - TKIND_MAX = 8 - } - - [StructLayout(LayoutKind.Sequential)] - public class tagTLIBATTR { - public Guid guid; - [MarshalAs(UnmanagedType.U4)] - public int lcid; - public NativeMethods.tagSYSKIND syskind; - [MarshalAs(UnmanagedType.U2)] - public ushort wMajorVerNum; - [MarshalAs(UnmanagedType.U2)] - public ushort wMinorVerNum; - [MarshalAs(UnmanagedType.U2)] - public ushort wLibFlags; - } - - [StructLayout(LayoutKind.Sequential)] - public class tagTYPEDESC { - public IntPtr unionMember; - public short vt; - } - - [StructLayout(LayoutKind.Sequential)] - public struct tagPARAMDESC { - public IntPtr pparamdescex; - - [MarshalAs(UnmanagedType.U2)] - public ushort wParamFlags; - } -#endif public static class CommonHandles { static CommonHandles() { } @@ -6359,205 +2495,6 @@ static CommonHandles() { /// public static readonly int Window = HandleCollector.RegisterType("Window", 5, 1000); } -#if never - public enum tagSYSKIND { - SYS_WIN16 = 0, - SYS_MAC = 2 - } - - public delegate bool MonitorEnumProc(IntPtr monitor, IntPtr hdc, IntPtr lprcMonitor, IntPtr lParam); - - [ComImport(), Guid("A7ABA9C1-8983-11cf-8F20-00805F2CD064"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IProvideMultipleClassInfo { - // since the inheritance doesn't seem to work... - // these are from IProvideClassInfo & IProvideClassInfo2 - [PreserveSig] - UnsafeNativeMethods.ITypeInfo GetClassInfo(); - - [PreserveSig] - int GetGUID(int dwGuidKind, [In, Out] ref Guid pGuid); - - [PreserveSig] - int GetMultiTypeInfoCount([In, Out] ref int pcti); - - // we use arrays for most of these since we never use them anyway. - [PreserveSig] - int GetInfoOfIndex(int iti, int dwFlags, - [In, Out] - ref UnsafeNativeMethods.ITypeInfo pTypeInfo, - int pTIFlags, - int pcdispidReserved, - IntPtr piidPrimary, - IntPtr piidSource); - } - - [StructLayout(LayoutKind.Sequential)] - public class EVENTMSG { - public int message; - public int paramL; - public int paramH; - public int time; - public IntPtr hwnd; - } - - [ComImport(), Guid("B196B283-BAB4-101A-B69C-00AA00341D07"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IProvideClassInfo { - [return: MarshalAs(UnmanagedType.Interface)] - UnsafeNativeMethods.ITypeInfo GetClassInfo(); - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagTYPEATTR { - public Guid guid; - [MarshalAs(UnmanagedType.U4)] - public uint lcid; - [MarshalAs(UnmanagedType.U4)] - public uint dwReserved; - public int memidConstructor; - public int memidDestructor; - public IntPtr lpstrSchema; - [MarshalAs(UnmanagedType.U4)] - public uint cbSizeInstance; - public /*NativeMethods.tagTYPEKIND*/ int typekind; - [MarshalAs(UnmanagedType.U2)] - public ushort cFuncs; - [MarshalAs(UnmanagedType.U2)] - public ushort cVars; - [MarshalAs(UnmanagedType.U2)] - public ushort cImplTypes; - [MarshalAs(UnmanagedType.U2)] - public ushort cbSizeVft; - [MarshalAs(UnmanagedType.U2)] - public ushort cbAlignment; - [MarshalAs(UnmanagedType.U2)] - public ushort wTypeFlags; - [MarshalAs(UnmanagedType.U2)] - public ushort wMajorVerNum; - [MarshalAs(UnmanagedType.U2)] - public ushort wMinorVerNum; - - // SBurke these are inline too - //public NativeMethods.tagTYPEDESC tdescAlias; - [MarshalAs(UnmanagedType.U4)] - public int tdescAlias_unionMember; - - [MarshalAs(UnmanagedType.U2)] - public short tdescAlias_vt; - - //public NativeMethods.tagIDLDESC idldescType; - [MarshalAs(UnmanagedType.U4)] - public int idldescType_dwReserved; - - [MarshalAs(UnmanagedType.U2)] - public short idldescType_wIDLFlags; - - - public tagTYPEDESC Get_tdescAlias(){ - tagTYPEDESC td = new tagTYPEDESC(); - td.unionMember = (IntPtr)this.tdescAlias_unionMember; - td.vt = this.tdescAlias_vt; - return td; - } - - public tagIDLDESC Get_idldescType(){ - tagIDLDESC id = new tagIDLDESC(); - id.dwReserved = this.idldescType_dwReserved; - id.wIDLFlags = this.idldescType_wIDLFlags; - return id; - } - } - - public enum tagVARFLAGS { - VARFLAG_FREADONLY = 1, - VARFLAG_FSOURCE = 0x2, - VARFLAG_FBINDABLE = 0x4, - VARFLAG_FREQUESTEDIT = 0x8, - VARFLAG_FDISPLAYBIND = 0x10, - VARFLAG_FDEFAULTBIND = 0x20, - VARFLAG_FHIDDEN = 0x40, - VARFLAG_FDEFAULTCOLLELEM = 0x100, - VARFLAG_FUIDEFAULT = 0x200, - VARFLAG_FNONBROWSABLE = 0x400, - VARFLAG_FREPLACEABLE = 0x800, - VARFLAG_FIMMEDIATEBIND = 0x1000 - } - - [StructLayout(LayoutKind.Sequential)] - public sealed class tagELEMDESC { - public NativeMethods.tagTYPEDESC tdesc; - public NativeMethods.tagPARAMDESC paramdesc; - } - - public enum tagVARKIND { - VAR_PERINSTANCE = 0, - VAR_STATIC = 1, - VAR_CONST = 2, - VAR_DISPATCH = 3 - } - - [StructLayout(LayoutKind.Sequential)] - public struct tagIDLDESC { - [MarshalAs(UnmanagedType.U4)] - public int dwReserved; - [MarshalAs(UnmanagedType.U2)] - public ushort wIDLFlags; - } - - public struct RGBQUAD { - public byte rgbBlue; - public byte rgbGreen; - public byte rgbRed; - public byte rgbReserved; - } - - [StructLayout(LayoutKind.Sequential)] - public class BITMAPINFO_ARRAY { - public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); - - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=BITMAPINFO_MAX_COLORSIZE*4)] - public byte[] bmiColors; // RGBQUAD structs... Blue-Green-Red-Reserved, repeat... - } - - [StructLayout(LayoutKind.Sequential)] - public struct PALETTEENTRY { - public byte peRed; - public byte peGreen; - public byte peBlue; - public byte peFlags; - } - - [StructLayout(LayoutKind.Sequential)] - public struct BITMAPINFO_FLAT { - public int bmiHeader_biSize;// = Marshal.SizeOf(typeof(BITMAPINFOHEADER)); - public int bmiHeader_biWidth; - public int bmiHeader_biHeight; - public short bmiHeader_biPlanes; - public short bmiHeader_biBitCount; - public int bmiHeader_biCompression; - public int bmiHeader_biSizeImage; - public int bmiHeader_biXPelsPerMeter; - public int bmiHeader_biYPelsPerMeter; - public int bmiHeader_biClrUsed; - public int bmiHeader_biClrImportant; - - [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=BITMAPINFO_MAX_COLORSIZE*4)] - public byte[] bmiColors; // RGBQUAD structs... Blue-Green-Red-Reserved, repeat... - } - - - /// - /// This method takes a file URL and converts it to a local path. The trick here is that - /// if there is a '#' in the path, everything after this is treated as a fragment. So - /// we need to append the fragment to the end of the path. - /// - internal static string GetLocalPath(string fileName) { - System.Diagnostics.Debug.Assert(fileName != null && fileName.Length > 0, "Cannot get local path, fileName is not valid"); - - Uri uri = new Uri(fileName, true); - return uri.LocalPath + uri.Fragment; - } - -#endif public const int PBT_APMPOWERSTATUSCHANGE = 0x000A; @@ -6571,105 +2508,13 @@ public struct SYSTEM_POWER_STATUS { public int BatteryFullLifeTime; } -#if never - [StructLayout(LayoutKind.Sequential)] - internal class DLLVERSIONINFO - { - internal uint cbSize; - internal uint dwMajorVersion; - internal uint dwMinorVersion; - internal uint dwBuildNumber; - internal uint dwPlatformID; - } - - public enum OLERENDER - { - OLERENDER_NONE = 0, - OLERENDER_DRAW = 1, - OLERENDER_FORMAT = 2, - OLERENDER_ASIS = 3 - } - - // Theming/Visual Styles stuff - public const int STAP_ALLOW_NONCLIENT = (1 << 0); - public const int STAP_ALLOW_CONTROLS = (1 << 1); - public const int STAP_ALLOW_WEBCONTENT = (1 << 2); - - public const int PS_NULL = 5; - public const int PS_INSIDEFRAME = 6; - - public const int PS_GEOMETRIC = 0x00010000; - public const int PS_ENDCAP_SQUARE = 0x00000100; - - public const int MM_HIMETRIC = 3; - -#endif - // WinEvent -#if never - public const int EVENT_MIN = 0x00000001; - public const int EVENT_MAX = 0x7FFFFFFF; - - public const int EVENT_SYSTEM_SOUND = 0x0001; - public const int EVENT_SYSTEM_ALERT = 0x0002; - public const int EVENT_SYSTEM_FOREGROUND = 0x0003; - public const int EVENT_SYSTEM_MENUSTART = 0x0004; - public const int EVENT_SYSTEM_MENUEND = 0x0005; - public const int EVENT_SYSTEM_MENUPOPUPSTART = 0x0006; - public const int EVENT_SYSTEM_MENUPOPUPEND = 0x0007; - public const int EVENT_SYSTEM_CAPTURESTART = 0x0008; - public const int EVENT_SYSTEM_CAPTUREEND = 0x0009; -#endif public const int EVENT_SYSTEM_MOVESIZESTART = 0x000A; public const int EVENT_SYSTEM_MOVESIZEEND = 0x000B; -#if never - public const int EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C; - public const int EVENT_SYSTEM_CONTEXTHELPEND = 0x000D; - public const int EVENT_SYSTEM_DRAGDROPSTART = 0x000E; - public const int EVENT_SYSTEM_DRAGDROPEND = 0x000F; - public const int EVENT_SYSTEM_DIALOGSTART = 0x0010; - public const int EVENT_SYSTEM_DIALOGEND = 0x0011; - public const int EVENT_SYSTEM_SCROLLINGSTART = 0x0012; - public const int EVENT_SYSTEM_SCROLLINGEND = 0x0013; - public const int EVENT_SYSTEM_SWITCHEND = 0x0015; - public const int EVENT_SYSTEM_MINIMIZESTART = 0x0016; - public const int EVENT_SYSTEM_MINIMIZEEND = 0x0017; - public const int EVENT_SYSTEM_PAINT = 0x0019; - public const int EVENT_CONSOLE_CARET = 0x4001; - public const int EVENT_CONSOLE_UPDATE_REGION = 0x4002; - public const int EVENT_CONSOLE_UPDATE_SIMPLE = 0x4003; - public const int EVENT_CONSOLE_UPDATE_SCROLL = 0x4004; - public const int EVENT_CONSOLE_LAYOUT = 0x4005; - public const int EVENT_CONSOLE_START_APPLICATION = 0x4006; - public const int EVENT_CONSOLE_END_APPLICATION = 0x4007; - public const int EVENT_OBJECT_CREATE = 0x8000; - public const int EVENT_OBJECT_DESTROY = 0x8001; - public const int EVENT_OBJECT_SHOW = 0x8002; - public const int EVENT_OBJECT_HIDE = 0x8003; - public const int EVENT_OBJECT_REORDER = 0x8004; - public const int EVENT_OBJECT_SELECTION = 0x8006; - public const int EVENT_OBJECT_SELECTIONADD = 0x8007; - public const int EVENT_OBJECT_SELECTIONREMOVE = 0x8008; - public const int EVENT_OBJECT_SELECTIONWITHIN = 0x8009; - public const int EVENT_OBJECT_LOCATIONCHANGE = 0x800B; - public const int EVENT_OBJECT_NAMECHANGE = 0x800C; - public const int EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D; - public const int EVENT_OBJECT_VALUECHANGE = 0x800E; - public const int EVENT_OBJECT_PARENTCHANGE = 0x800F; - public const int EVENT_OBJECT_HELPCHANGE = 0x8010; - public const int EVENT_OBJECT_DEFACTIONCHANGE = 0x8011; - public const int EVENT_OBJECT_ACCELERATORCHANGE = 0x8012; -#endif - public const int EVENT_OBJECT_STATECHANGE = 0x800A; public const int EVENT_OBJECT_FOCUS = 0x8005; public const int OBJID_CLIENT = unchecked(unchecked((int)0xFFFFFFFC)); public const int WINEVENT_OUTOFCONTEXT = 0x0000; -#if never - public const int WINEVENT_SKIPOWNTHREAD = 0x0001; - public const int WINEVENT_SKIPOWNPROCESS = 0x0002; - public const int WINEVENT_INCONTEXT = 0x0004; -#endif // the delegate passed to USER for receiving a WinEvent internal delegate void WinEventProcDef (int winEventHook, int eventId, IntPtr hwnd, int idObject, int idChild, int eventThread, int eventTime); @@ -6687,20 +2532,6 @@ public enum WebBrowserReadyState Interactive = 3, Complete = 4 } - -#if never - public const int URLACTION_JAVA_PERMISSIONS = 0x00001C00, - URLACTION_CREDENTIALS_USE = 0x00001A00, - URLACTION_CHANNEL_SOFTDIST_PERMISSIONS = 0x00001E05, - URLACTION_HTML_FONT_DOWNLOAD = 0x00001604; - - public const int URLPOLICY_QUERY = 0x01, - URLPOLICY_ALLOW = 0x00, - URLPOLICY_DISALLOW = 0x03, - URLPOLICY_JAVA_PROHIBIT = 0x00000000, - URLPOLICY_CREDENTIALS_MUST_PROMPT_USER = 0x00010000, - URLPOLICY_CHANNEL_SOFTDIST_PROHIBIT = 0x00010000; -#endif #endregion WebBrowser Related Definitions [StructLayout(LayoutKind.Sequential)] diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs index b0cdf47eb62..63b33f29acc 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs @@ -57,9 +57,6 @@ internal partial class UnsafeNativeMethods { [DllImport(ExternDll.Uxtheme, CharSet = CharSet.Auto, BestFitMapping = false)] public static extern int GetCurrentThemeName(StringBuilder pszThemeFileName, int dwMaxNameChars, StringBuilder pszColorBuff, int dwMaxColorChars, StringBuilder pszSizeBuff, int cchMaxSizeChars); - [DllImport(ExternDll.DwmAPI, BestFitMapping = false)] - public static extern int DwmIsCompositionEnabled(out Int32 enabled); - [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)] public static extern IntPtr GetCurrentThread(); diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs new file mode 100644 index 00000000000..09ee8d39c8f --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/AssemblyInfo.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; + +[assembly: CLSCompliant(false)] + +[assembly: InternalsVisibleTo($"PresentationBuildTasks, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"PresentationCore, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"PresentationFramework, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"PresentationUI, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"ReachFramework, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"System.Windows.Controls.Ribbon, PublicKey={PublicKeys.Ecma}")] +[assembly: InternalsVisibleTo($"System.Windows.Input.Manipulations, PublicKey={PublicKeys.Ecma}")] +[assembly: InternalsVisibleTo($"System.Windows.Presentation, PublicKey={PublicKeys.Ecma}")] +[assembly: InternalsVisibleTo($"System.Xaml, PublicKey={PublicKeys.Ecma}")] +[assembly: InternalsVisibleTo($"UIAutomationClient, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"UIAutomationClientSideProviders, PublicKey={PublicKeys.Ecma}")] +[assembly: InternalsVisibleTo($"UIAutomationProvider, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"UIAutomationTypes, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"WindowsBase, PublicKey={PublicKeys.MicrosoftShared}")] +[assembly: InternalsVisibleTo($"WindowsFormsIntegration, PublicKey={PublicKeys.MicrosoftShared}")] diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.json b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.json new file mode 100644 index 00000000000..46e13e3b078 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://aka.ms/CsWin32.schema.json", + "allowMarshaling": false, + "useSafeHandles": false, + "comInterop": { + "preserveSigMethods": [ + "*" + ] + } +} diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.txt b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.txt new file mode 100644 index 00000000000..046745cf4a2 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/NativeMethods.txt @@ -0,0 +1,22 @@ +AC_SRC_* +CLSID_WICImagingFactory +CoInitialize +CreateWindowEx +DefWindowProc +DestroyWindow +DwmIsCompositionEnabled +GetAncestor +GetClassName +GetProcessHandleFromHwnd +GUID_WICPixelFormat32bppPBGRA +IsWindow +IWICImagingFactory +OpenProcess +RealGetWindowClass +RegisterClassEx +SetActiveWindow +UnregisterClass +UpdateLayeredWindow +WAIT_EVENT +WINDOW_STYLE +WindowFromPhysicalPoint diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj new file mode 100644 index 00000000000..49f61fe1443 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/System.Windows.Primitives.csproj @@ -0,0 +1,34 @@ + + + + System.Windows.Primitives + true + false + enable + AnyCPU + + + $(NoWarn);CS8981;CS3016 + + true + true + true + + $(DefaultItemExcludes);ref\** + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/ref/System.Windows.Primitives-ref.csproj b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/ref/System.Windows.Primitives-ref.csproj new file mode 100644 index 00000000000..586eac483d1 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Primitives/ref/System.Windows.Primitives-ref.csproj @@ -0,0 +1,13 @@ + + + System.Windows.Primitives + System.Windows.Primitives-ref + $(TargetGroup)-$(PackageId)/ + AnyCPU + false + + + + + + diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/UIAutomationClientSideProviders.csproj b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/UIAutomationClientSideProviders.csproj index 9194df2bdae..106e50cb575 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/UIAutomationClientSideProviders.csproj +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/UIAutomationClientSideProviders.csproj @@ -109,8 +109,10 @@ false + + diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/SplashScreenNativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/SplashScreenNativeMethods.cs deleted file mode 100644 index 8979492ae98..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/SplashScreenNativeMethods.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - - -using System; -using System.Runtime.ConstrainedExecution; -using System.Runtime.InteropServices; -using System.Security; -using System.Windows; -using MS.Internal.WindowsBase; - -namespace MS.Win32 -{ - internal sealed partial class UnsafeNativeMethods - { - internal class WIC - { - #region Constants - internal const int WINCODEC_SDK_VERSION = 0x0236; - internal static readonly Guid WICPixelFormat32bppPBGRA = new Guid(0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x10); - #endregion - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateImagingFactory_Proxy")] - internal static extern int CreateImagingFactory( - UInt32 SDKVersion, - out IntPtr ppICodecFactory); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateStream_Proxy")] - internal static extern int /* HRESULT */ CreateStream( - IntPtr pICodecFactory, - out IntPtr /* IWICBitmapStream */ ppIStream); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromMemory_Proxy")] - internal static extern int /*HRESULT*/ InitializeStreamFromMemory( - IntPtr pIWICStream, - IntPtr pbBuffer, - uint cbSize); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromStream_Proxy")] - internal static extern int /*HRESULT*/ CreateDecoderFromStream( - IntPtr pICodecFactory, - IntPtr /* IStream */ pIStream, - ref Guid guidVendor, - UInt32 metadataFlags, - out IntPtr /* IWICBitmapDecoder */ ppIDecode); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrame_Proxy")] - internal static extern int /* HRESULT */ GetFrame( - IntPtr /* IWICBitmapDecoder */ THIS_PTR, - UInt32 index, - out IntPtr /* IWICBitmapFrameDecode */ ppIFrameDecode); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFormatConverter_Proxy")] - internal static extern int /* HRESULT */ CreateFormatConverter( - IntPtr pICodecFactory, - out IntPtr /* IWICFormatConverter */ ppFormatConverter); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFormatConverter_Initialize_Proxy")] - internal static extern int /* HRESULT */ InitializeFormatConverter( - IntPtr /* IWICFormatConverter */ THIS_PTR, - IntPtr /* IWICBitmapSource */ source, - ref Guid dstFormat, - int dither, - IntPtr /* IWICBitmapPalette */ bitmapPalette, - double alphaThreshold, - WICPaletteType paletteTranslate); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFlipRotator_Proxy")] - internal static extern int /* HRESULT */ CreateBitmapFlipRotator( - IntPtr pICodecFactory, - out IntPtr /* IWICBitmapFlipRotator */ ppBitmapFlipRotator); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFlipRotator_Initialize_Proxy")] - internal static extern int /* HRESULT */ InitializeBitmapFlipRotator( - IntPtr /* IWICBitmapFlipRotator */ THIS_PTR, - IntPtr /* IWICBitmapSource */ source, - WICBitmapTransformOptions options); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetSize_Proxy")] - internal static extern int /* HRESULT */ GetBitmapSize( - IntPtr /* IWICBitmapSource */ THIS_PTR, - out Int32 puiWidth, - out Int32 puiHeight); - - [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPixels_Proxy")] - internal static extern int /* HRESULT */ CopyPixels( - IntPtr /* IWICBitmapSource */ THIS_PTR, - ref Int32Rect prc, - Int32 cbStride, - Int32 cbBufferSize, - IntPtr /* BYTE* */ pvPixels); - - - #region enums - - internal enum WICBitmapTransformOptions - { - WICBitmapTransformRotate0 = 0, - WICBitmapTransformRotate90 = 0x1, - WICBitmapTransformRotate180 = 0x2, - WICBitmapTransformRotate270 = 0x3, - WICBitmapTransformFlipHorizontal = 0x8, - WICBitmapTransformFlipVertical = 0x10 - } - - internal enum WICPaletteType - { - WICPaletteTypeCustom = 0, - WICPaletteTypeOptimal = 1, - WICPaletteTypeFixedBW = 2, - WICPaletteTypeFixedHalftone8 = 3, - WICPaletteTypeFixedHalftone27 = 4, - WICPaletteTypeFixedHalftone64 = 5, - WICPaletteTypeFixedHalftone125 = 6, - WICPaletteTypeFixedHalftone216 = 7, - WICPaletteTypeFixedWebPalette = 7, - WICPaletteTypeFixedHalftone252 = 8, - WICPaletteTypeFixedHalftone256 = 9, - WICPaletteTypeFixedGray4 = 10, - WICPaletteTypeFixedGray16 = 11, - WICPaletteTypeFixedGray256 = 12 - }; - - #endregion - } - - internal class HRESULT - { - public static void Check(int hr) - { - if (hr >= 0) - { - return; - } - else - { - // PresentationCore (wgx_render.cs) has a more complete system - // for converting hresults to exceptions for MIL and windows codecs - // but for splash screen we don't want to take a dependency on core. - Marshal.ThrowExceptionForHR(hr, (IntPtr)(-1)); - } - } - } - } -} diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs index d6973702afa..4f019c29bbb 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Utilities.cs @@ -9,8 +9,8 @@ namespace MS.Internal using System; using System.Diagnostics; using System.Runtime.InteropServices; - using System.Security; - using MS.Win32; + using Windows.Win32; + using Windows.Win32.Foundation; /// /// General utility class for macro-type functions. @@ -43,9 +43,8 @@ internal static bool IsCompositionEnabled return false; } - Int32 isDesktopCompositionEnabled = 0; - UnsafeNativeMethods.HRESULT.Check(UnsafeNativeMethods.DwmIsCompositionEnabled(out isDesktopCompositionEnabled)); - return isDesktopCompositionEnabled != 0; + PInvoke.DwmIsCompositionEnabled(out BOOL isDesktopCompositionEnabled).ThrowOnFailure(); + return isDesktopCompositionEnabled; } } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs index 318e9bb3969..20927d06279 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs @@ -2,40 +2,42 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System.ComponentModel; +using System.Globalization; using System.IO; using System.Reflection; using System.Resources; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Security; using System.Windows.Threading; using MS.Internal; -using MS.Internal.Interop; using MS.Internal.KnownBoxes; using MS.Internal.WindowsBase; -using MS.Utility; -using MS.Win32; + +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.Graphics.Gdi; +using Windows.Win32.Graphics.Imaging; +using Windows.Win32.System.Com; +using Windows.Win32.UI.WindowsAndMessaging; namespace System.Windows { public class SplashScreen { - private IntPtr _hwnd = IntPtr.Zero; - private string _resourceName; - private IntPtr _hInstance; - private NativeMethods.BitmapHandle _hBitmap; - private ushort _wndClass; - private DispatcherTimer _dt; + private HWND _hwnd = HWND.Null; + private readonly string _resourceName; + private readonly HINSTANCE _hInstance; + private HBITMAP _hBitmap; + private ushort _windowClass; + private DispatcherTimer _timer; private TimeSpan _fadeoutDuration; private DateTime _fadeoutEnd; - NativeMethods.BLENDFUNCTION _blendFunc; - private ResourceManager _resourceManager; + private BLENDFUNCTION _blendFunction; + private readonly ResourceManager _resourceManager; private Dispatcher _dispatcher; - // keep this delegate alive as long as the window class is registered - private static NativeMethods.WndProc _defWndProc; - private const string CLASSNAME = "SplashScreen"; + private const string ClassName = "SplashScreen"; public SplashScreen(string resourceName) : this(Assembly.GetEntryAssembly(), resourceName) { @@ -44,61 +46,55 @@ public SplashScreen(string resourceName) : this(Assembly.GetEntryAssembly(), res public SplashScreen(Assembly resourceAssembly, string resourceName) { ArgumentNullException.ThrowIfNull(resourceAssembly); - if (String.IsNullOrEmpty(resourceName)) + if (string.IsNullOrEmpty(resourceName)) { - throw new ArgumentNullException("resourceName"); + throw new ArgumentNullException(nameof(resourceName)); } + _resourceName = resourceName.ToLowerInvariant(); - _hInstance = Marshal.GetHINSTANCE(resourceAssembly.ManifestModule); - AssemblyName name = new AssemblyName(resourceAssembly.FullName); - _resourceManager = new ResourceManager(name.Name + ".g", resourceAssembly); + _hInstance = (HINSTANCE)Marshal.GetHINSTANCE(resourceAssembly.ManifestModule); + AssemblyName name = new(resourceAssembly.FullName); + _resourceManager = new ResourceManager($"{name.Name}.g", resourceAssembly); } public void Show(bool autoClose) { - Show(autoClose, false); + Show(autoClose, topMost: false); } - public void Show(bool autoClose, bool topMost) + public unsafe void Show(bool autoClose, bool topMost) { + if (!_hwnd.IsNull) + { + return; + } + // If we've already been shown it isn't an error to call show // again (maybe you forgot) since you will still be shown state. - if (_hwnd == IntPtr.Zero) + + using UnmanagedMemoryStream resourceStream = GetResourceStream() + ?? throw new IOException(SR.Format(SR.UnableToLocateResource, _resourceName)); + + resourceStream.Seek(0, SeekOrigin.Begin); // ensure stream position + + CreateLayeredWindowFromImgBuffer(new(resourceStream.PositionPointer, (int)resourceStream.Length), topMost); + + if (autoClose) { - UnmanagedMemoryStream umemStream; - using (umemStream = GetResourceStream()) - { - if (umemStream != null) + Dispatcher.CurrentDispatcher.BeginInvoke( + DispatcherPriority.Loaded, + (DispatcherOperationCallback)(arg => { - umemStream.Seek(0, SeekOrigin.Begin); // ensure stream position - IntPtr pImageSrcBuffer; - unsafe - { - pImageSrcBuffer = new IntPtr(umemStream.PositionPointer); - } - - if (CreateLayeredWindowFromImgBuffer(pImageSrcBuffer, umemStream.Length, topMost) && autoClose == true) - { - Dispatcher.CurrentDispatcher.BeginInvoke( - DispatcherPriority.Loaded, - (DispatcherOperationCallback)(arg => - { - ((SplashScreen)arg).Close(TimeSpan.FromSeconds(0.3)); - return null; - }), - this); - } - // The HWND that we just created is owned by this thread. When we close we should ensure that it - // does not get accessed from a different thread. We don't want to reference the .CurrentDispatcher - // property before the window is created due to cold start performance concerns. - _dispatcher = Dispatcher.CurrentDispatcher; - } - else - { - throw new IOException(SR.Format(SR.UnableToLocateResource, _resourceName)); - } - } + ((SplashScreen)arg).Close(TimeSpan.FromSeconds(0.3)); + return null; + }), + this); } + + // The HWND that we just created is owned by this thread. When we close we should ensure that it + // does not get accessed from a different thread. We don't want to reference the .CurrentDispatcher + // property before the window is created due to cold start performance concerns. + _dispatcher = Dispatcher.CurrentDispatcher; } // This is 200-300 ms slower than Assembly.GetManifestResourceStream() but works with localization. @@ -106,8 +102,8 @@ private UnmanagedMemoryStream GetResourceStream() { // Try to get the stream with the string the developer supplied, in the app.g.cs case // this will always work. - UnmanagedMemoryStream stream = _resourceManager.GetStream(_resourceName, System.Globalization.CultureInfo.CurrentUICulture); - if (stream != null) + UnmanagedMemoryStream stream = _resourceManager.GetStream(_resourceName, CultureInfo.CurrentUICulture); + if (stream is not null) { return stream; } @@ -117,93 +113,95 @@ private UnmanagedMemoryStream GetResourceStream() // slow URI class to get the correct name. We try to avoid doing this in the common case // since URI has quite a bit of code associated with it. string resourceName = ResourceIDHelper.GetResourceIDFromRelativePath(_resourceName); - return _resourceManager.GetStream(resourceName, System.Globalization.CultureInfo.CurrentUICulture); + return _resourceManager.GetStream(resourceName, CultureInfo.CurrentUICulture); } - private IntPtr CreateWindow(NativeMethods.BitmapHandle hBitmap, int width, int height, bool topMost) + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] + private static LRESULT WndProc(HWND hWnd, uint Msg, WPARAM wParam, LPARAM lParam) => + PInvoke.DefWindowProc(hWnd, Msg, wParam, lParam); + + private unsafe HWND CreateWindow(HBITMAP hBitmap, int width, int height, bool topMost) { - if (_defWndProc == null) + fixed (char* className = ClassName) { - _defWndProc = new MS.Win32.NativeMethods.WndProc(UnsafeNativeMethods.DefWindowProc); + WNDCLASSEXW wndClass = new() + { + cbSize = (uint)sizeof(WNDCLASSEXW), + style = WNDCLASS_STYLES.CS_HREDRAW | WNDCLASS_STYLES.CS_VREDRAW, + lpszClassName = className, + lpfnWndProc = &WndProc, + hInstance = _hInstance + }; + + // We chose to ignore re-registration errors in RegisterClassEx on the off chance that the user + // wants to open multiple splash screens. + _windowClass = PInvoke.RegisterClassEx(wndClass); } - MS.Win32.NativeMethods.WNDCLASSEX_D wndClass = new MS.Win32.NativeMethods.WNDCLASSEX_D(); - wndClass.cbSize = Marshal.SizeOf(typeof(MS.Win32.NativeMethods.WNDCLASSEX_D)); - wndClass.style = 3; /* CS_HREDRAW | CS_VREDRAW */ - wndClass.lpfnWndProc = null; - wndClass.hInstance = _hInstance; - wndClass.hCursor = IntPtr.Zero; - wndClass.lpszClassName = CLASSNAME; - wndClass.lpszMenuName = string.Empty; - wndClass.lpfnWndProc = _defWndProc; - - // We chose to ignore re-registration errors in RegisterClassEx on the off chance that the user - // wants to open multiple splash screens. - _wndClass = MS.Win32.UnsafeNativeMethods.IntRegisterClassEx(wndClass); - if (_wndClass == 0) + if (_windowClass == 0) { - var lastWin32Error = Marshal.GetLastWin32Error(); - if (lastWin32Error != 0x582) /* class already registered */ + int lastWin32Error = Marshal.GetLastWin32Error(); + if (lastWin32Error != (int)WIN32_ERROR.ERROR_CLASS_ALREADY_EXISTS) + { throw new Win32Exception(lastWin32Error); + } } - int screenWidth = MS.Win32.UnsafeNativeMethods.GetSystemMetrics(SM.CXSCREEN); - int screenHeight = MS.Win32.UnsafeNativeMethods.GetSystemMetrics(SM.CYSCREEN); + int screenWidth = PInvokeCore.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSCREEN); + int screenHeight = PInvokeCore.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSCREEN); int x = (screenWidth - width) / 2; int y = (screenHeight - height) / 2; - HandleRef nullHandle = new HandleRef(null, IntPtr.Zero); - int windowCreateFlags = - (int) NativeMethods.WS_EX_WINDOWEDGE | - NativeMethods.WS_EX_TOOLWINDOW | - NativeMethods.WS_EX_LAYERED | - (topMost ? NativeMethods.WS_EX_TOPMOST : 0); + WINDOW_EX_STYLE windowCreateFlags = WINDOW_EX_STYLE.WS_EX_WINDOWEDGE + | WINDOW_EX_STYLE.WS_EX_TOOLWINDOW + | WINDOW_EX_STYLE.WS_EX_LAYERED + | (topMost ? WINDOW_EX_STYLE.WS_EX_TOPMOST : 0); // CreateWindowEx will either succeed or throw - IntPtr hWnd = MS.Win32.UnsafeNativeMethods.CreateWindowEx( + HWND hwnd = PInvoke.CreateWindowEx( windowCreateFlags, - CLASSNAME, SR.SplashScreenIsLoading, - MS.Win32.NativeMethods.WS_POPUP | MS.Win32.NativeMethods.WS_VISIBLE, + ClassName, + SR.SplashScreenIsLoading, + WINDOW_STYLE.WS_POPUP | WINDOW_STYLE.WS_VISIBLE, x, y, width, height, - nullHandle, nullHandle, new HandleRef(null, _hInstance), IntPtr.Zero); + HWND.Null, + HMENU.Null, + _hInstance, + null); // Display the image on the window - IntPtr hScreenDC = UnsafeNativeMethods.GetDC(new HandleRef()); - IntPtr memDC = UnsafeNativeMethods.CreateCompatibleDC(new HandleRef(null, hScreenDC)); - IntPtr hOldBitmap = UnsafeNativeMethods.SelectObject(new HandleRef(null, memDC), hBitmap.MakeHandleRef(null).Handle); - - NativeMethods.POINT newSize = new NativeMethods.POINT(width, height); - NativeMethods.POINT newLocation = new NativeMethods.POINT(x, y); - NativeMethods.POINT sourceLocation = new NativeMethods.POINT(0, 0); - _blendFunc = new NativeMethods.BLENDFUNCTION(); - _blendFunc.BlendOp = NativeMethods.AC_SRC_OVER; - _blendFunc.BlendFlags = 0; - _blendFunc.SourceConstantAlpha = 255; - _blendFunc.AlphaFormat = 1; /*AC_SRC_ALPHA*/ - - bool result; - unsafe - { - result = UnsafeNativeMethods.UpdateLayeredWindow(hWnd, hScreenDC, &newLocation, &newSize, - memDC, &sourceLocation, 0, ref _blendFunc, NativeMethods.ULW_ALPHA); - } - - UnsafeNativeMethods.SelectObject(new HandleRef(null, memDC), hOldBitmap); - UnsafeNativeMethods.ReleaseDC(new HandleRef(), new HandleRef(null, memDC)); - UnsafeNativeMethods.ReleaseDC(new HandleRef(), new HandleRef(null, hScreenDC)); + using GetDcScope screenContext = GetDcScope.ScreenDC; + using CreateDcScope memoryContext = new(screenContext); + using SelectObjectScope selectObjectScope = new(memoryContext, hBitmap); - if (result == false) + BLENDFUNCTION blendFunction = new() { - UnsafeNativeMethods.HRESULT.Check(Marshal.GetHRForLastWin32Error()); + BlendOp = (byte)PInvoke.AC_SRC_OVER, + SourceConstantAlpha = 255, + AlphaFormat = (byte)PInvoke.AC_SRC_ALPHA + }; + + if (!PInvoke.UpdateLayeredWindow( + hwnd, + screenContext, + new(x, y), + new(width, height), + memoryContext, + new(0, 0), + default, + blendFunction, + UPDATE_LAYERED_WINDOW_FLAGS.ULW_ALPHA)) + { + ((HRESULT)Marshal.GetHRForLastWin32Error()).ThrowOnFailure(); } - return hWnd; + return hwnd; } public void Close(TimeSpan fadeoutDuration) { object result = null; - if (_dispatcher != null) + if (_dispatcher is not null) { if (_dispatcher.CheckAccess()) { @@ -218,16 +216,15 @@ public void Close(TimeSpan fadeoutDuration) if (result != BooleanBoxes.TrueBox) { // If all else fails try to destroy the resources on this thread - // this will probably end up throwing but it will be the same - // exception as the previous version. + // this will probably end up throwing but it will be the same + // exception as the previous version. DestroyResources(); } } - - private object CloseInternal(Object fadeOutArg) + private object CloseInternal(object fadeOutArg) { - TimeSpan fadeoutDuration = (TimeSpan) fadeOutArg; + TimeSpan fadeoutDuration = (TimeSpan)fadeOutArg; if (fadeoutDuration <= TimeSpan.Zero) { DestroyResources(); @@ -237,16 +234,16 @@ private object CloseInternal(Object fadeOutArg) // In the case where the developer has specified AutoClose=True and then calls // Close(non_zero_timespan) before the auto close operation is dispatched we begin // the fadeout immidiately and ignore the later call to close. - if (_dt != null || _hwnd == IntPtr.Zero) + if (_timer is not null || _hwnd.IsNull) { return BooleanBoxes.TrueBox; } - // by default close gets called as soon as the first application window is created + // By default close gets called as soon as the first application window is created // since it will have become the active window we need to steal back the active window // status so that the fade out animation is visible. - IntPtr prevHwnd = UnsafeNativeMethods.SetActiveWindow(new HandleRef(null, _hwnd)); - if (prevHwnd == IntPtr.Zero) + HWND previousWindow = PInvoke.SetActiveWindow(_hwnd); + if (previousWindow.IsNull) { // SetActiveWindow fails (returns NULL) if the application is not in the foreground. // If this is the case, don't bother animating the fade out. @@ -254,180 +251,186 @@ private object CloseInternal(Object fadeOutArg) return BooleanBoxes.TrueBox; } - _dt = new DispatcherTimer(); - _dt.Interval = TimeSpan.FromMilliseconds(30); // shoot for ~30 fps + _timer = new DispatcherTimer + { + // Shoot for ~30 fps + Interval = TimeSpan.FromMilliseconds(30) + }; + _fadeoutDuration = fadeoutDuration; _fadeoutEnd = DateTime.UtcNow + _fadeoutDuration; - _dt.Tick += new EventHandler(Fadeout_Tick); - _dt.Start(); + _timer.Tick += Fadeout_Tick; + _timer.Start(); return BooleanBoxes.TrueBox; } private void Fadeout_Tick(object unused, EventArgs args) { - DateTime dtNow = DateTime.UtcNow; - if (dtNow >= _fadeoutEnd) + DateTime now = DateTime.UtcNow; + if (now >= _fadeoutEnd) { DestroyResources(); } else { - double progress = (_fadeoutEnd - dtNow).TotalMilliseconds / _fadeoutDuration.TotalMilliseconds; - _blendFunc.SourceConstantAlpha = (byte)(255 * progress); - unsafe - { - UnsafeNativeMethods.UpdateLayeredWindow(_hwnd, IntPtr.Zero, null, null, IntPtr.Zero, null, 0, ref _blendFunc, NativeMethods.ULW_ALPHA); - } + double progress = (_fadeoutEnd - now).TotalMilliseconds / _fadeoutDuration.TotalMilliseconds; + _blendFunction.SourceConstantAlpha = (byte)(255 * progress); + PInvoke.UpdateLayeredWindow( + _hwnd, + HDC.Null, + null, + null, + HDC.Null, + null, + default, + _blendFunction, + UPDATE_LAYERED_WINDOW_FLAGS.ULW_ALPHA); } } - private void DestroyResources() + private unsafe void DestroyResources(bool finalizer = false) { - if (_dt != null) + if (!finalizer) { - _dt.Stop(); - _dt = null; + _timer?.Stop(); + _timer = null; } - if (_hwnd != IntPtr.Zero) + + if (!_hwnd.IsNull) { - HandleRef hwnd = new HandleRef(null, _hwnd); - if (UnsafeNativeMethods.IsWindow(hwnd)) + if (PInvoke.IsWindow(_hwnd)) { - UnsafeNativeMethods.IntDestroyWindow(hwnd); + PInvoke.DestroyWindow(_hwnd); } - _hwnd = IntPtr.Zero; + + _hwnd = HWND.Null; } - if (_hBitmap != null && !_hBitmap.IsClosed) + + if (!_hBitmap.IsNull) { - UnsafeNativeMethods.DeleteObject(_hBitmap.MakeHandleRef(null).Handle); - _hBitmap.Close(); - _hBitmap = null; + PInvokeCore.DeleteObject(_hBitmap); + _hBitmap = HBITMAP.Null; } - if (_wndClass != 0) + + if (_windowClass != 0) { // Attempt to unregister the window class. If the application has a second // splash screen which is still open this call will fail. That's OK. - if (UnsafeNativeMethods.IntUnregisterClass(new IntPtr(_wndClass), _hInstance) != 0) - { - _defWndProc = null; // Can safely release the wndproc delegate when there are no more splash screen instances - } - _wndClass = 0; + PInvoke.UnregisterClass((PCWSTR)(char*)(nint)_windowClass, _hInstance); + _windowClass = 0; } - if (_resourceManager != null) + + // Mark this so it doesn't get finalized and try to release resources again. + GC.SuppressFinalize(this); + + if (!finalizer) { - _resourceManager.ReleaseAllResources(); + _resourceManager?.ReleaseAllResources(); } } - private bool CreateLayeredWindowFromImgBuffer(IntPtr pImgBuffer, long cImgBufferLen, bool topMost) + private unsafe void CreateLayeredWindowFromImgBuffer(Span buffer, bool topMost) { - bool bSuccess = false; - IntPtr pImagingFactory = IntPtr.Zero; - IntPtr pDecoder = IntPtr.Zero; - IntPtr pIStream = IntPtr.Zero; - IntPtr pDecodedFrame = IntPtr.Zero; - IntPtr pBitmapSourceFormatConverter = IntPtr.Zero; - IntPtr pBitmapFlipRotator = IntPtr.Zero; - try { - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.CreateImagingFactory(UnsafeNativeMethods.WIC.WINCODEC_SDK_VERSION, out pImagingFactory)); + PInvoke.CoInitialize().ThrowOnFailure(); + PInvokeCore.CoCreateInstance( + PInvoke.CLSID_WICImagingFactory, + null, + CLSCTX.CLSCTX_INPROC_SERVER, + out IWICImagingFactory* pImagingFactory).ThrowOnFailure(); - // Use the WIC stream class to wrap the unmanaged pointer - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.CreateStream(pImagingFactory, out pIStream)); + using ComScope scope = new(pImagingFactory); - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.InitializeStreamFromMemory(pIStream, pImgBuffer, (uint)cImgBufferLen)); + // Use the WIC stream class to wrap the unmanaged pointer + using ComScope pIStream = new(null); + pImagingFactory->CreateStream(pIStream).ThrowOnFailure(); + pIStream.Value->InitializeFromMemory(buffer).ThrowOnFailure(); // Create an object that will decode the encoded image - Guid vendor = Guid.Empty; - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.CreateDecoderFromStream(pImagingFactory, pIStream, - ref vendor, 0, out pDecoder)); + using ComScope pDecoder = new(null); + pImagingFactory->CreateDecoderFromStream( + (IStream*)(void*)pIStream, + IID.NULL(), + WICDecodeOptions.WICDecodeMetadataCacheOnDemand, + pDecoder).ThrowOnFailure(); // Get the frame from the decoder. Most image formats have only a single frame, in the case // of animated gifs we are ok with only displaying the first frame of the animation. - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.GetFrame(pDecoder, 0, out pDecodedFrame)); + using ComScope pDecodedFrame = new(null); + pDecoder.Value->GetFrame(0, pDecodedFrame).ThrowOnFailure(); - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.CreateFormatConverter(pImagingFactory, out pBitmapSourceFormatConverter)); + using ComScope pBitmapSourceFormatConverter = new(null); + pImagingFactory->CreateFormatConverter(pBitmapSourceFormatConverter).ThrowOnFailure(); // Convert the image from whatever format it is in to 32bpp premultiplied alpha BGRA - Guid pixelFormat = UnsafeNativeMethods.WIC.WICPixelFormat32bppPBGRA; - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.InitializeFormatConverter(pBitmapSourceFormatConverter, pDecodedFrame, - ref pixelFormat, 0 /*DitherTypeNone*/, IntPtr.Zero, - 0, UnsafeNativeMethods.WIC.WICPaletteType.WICPaletteTypeCustom)); + pBitmapSourceFormatConverter.Value->Initialize( + (IWICBitmapSource*)(void*)pDecodedFrame, + PInvoke.GUID_WICPixelFormat32bppPBGRA, + WICBitmapDitherType.WICBitmapDitherTypeNone, + null, + 0, + WICBitmapPaletteType.WICBitmapPaletteTypeCustom).ThrowOnFailure(); + // Reorient the image - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.CreateBitmapFlipRotator(pImagingFactory, out pBitmapFlipRotator)); + using ComScope pBitmapFlipRotator = new(null); + pImagingFactory->CreateBitmapFlipRotator(pBitmapFlipRotator).ThrowOnFailure(); - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.InitializeBitmapFlipRotator(pBitmapFlipRotator, pBitmapSourceFormatConverter, - UnsafeNativeMethods.WIC.WICBitmapTransformOptions.WICBitmapTransformFlipVertical)); - Int32 width, height; - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.GetBitmapSize(pBitmapFlipRotator, out width, out height)); + pBitmapFlipRotator.Value->Initialize( + (IWICBitmapSource*)(void*)pBitmapSourceFormatConverter, + WICBitmapTransformOptions.WICBitmapTransformFlipVertical).ThrowOnFailure(); - Int32 stride = width * 4; + pBitmapFlipRotator.Value->GetSize(out uint width, out uint height).ThrowOnFailure(); - // initialize the bitmap header - MS.Win32.NativeMethods.BITMAPINFO bmInfo = new MS.Win32.NativeMethods.BITMAPINFO(width, height, 32 /*bpp*/); - bmInfo.bmiHeader_biCompression = MS.Win32.NativeMethods.BI_RGB; - bmInfo.bmiHeader_biSizeImage = (int)(stride * height); + uint stride = width * 4; - // Create a 32bpp DIB. This DIB must have an alpha channel for UpdateLayeredWindow to succeed. - IntPtr pBitmapBits = IntPtr.Zero; - _hBitmap = UnsafeNativeMethods.CreateDIBSection(new HandleRef(), ref bmInfo, 0 /* DIB_RGB_COLORS*/, ref pBitmapBits, null, 0); + // Initialize the bitmap header + BITMAPINFOHEADER bmInfo = new() + { + biSize = (uint)sizeof(BITMAPINFOHEADER), + biWidth = (int)width, + biHeight = (int)height, + biBitCount = 32, + biPlanes = 1, + biCompression = (uint)BI_COMPRESSION.BI_RGB, + biSizeImage = stride * height + }; - // Copy the decoded image to the new buffer which backs the HBITMAP - Int32Rect rect = new Int32Rect(0, 0, width, height); - UnsafeNativeMethods.HRESULT.Check( - UnsafeNativeMethods.WIC.CopyPixels(pBitmapFlipRotator, ref rect, stride, stride * height, pBitmapBits)); + // Create a 32bpp DIB. This DIB must have an alpha channel for UpdateLayeredWindow to succeed. + void* pBitmapBits = null; - _hwnd = CreateWindow(_hBitmap, width, height, topMost); + _hBitmap = PInvokeCore.CreateDIBSection(default, (BITMAPINFO*)&bmInfo, DIB_USAGE.DIB_RGB_COLORS, &pBitmapBits, HANDLE.Null, 0); - bSuccess = true; - } - finally - { - if (pImagingFactory != IntPtr.Zero) - { - Marshal.Release(pImagingFactory); - } - if (pDecoder != IntPtr.Zero) - { - Marshal.Release(pDecoder); - } - if (pIStream != IntPtr.Zero) + if (_hBitmap.IsNull) { - Marshal.Release(pIStream); - } - if (pDecodedFrame != IntPtr.Zero) - { - Marshal.Release(pDecodedFrame); - } - if (pBitmapSourceFormatConverter != IntPtr.Zero) - { - Marshal.Release(pBitmapSourceFormatConverter); - } - if (pBitmapFlipRotator != IntPtr.Zero) - { - Marshal.Release(pBitmapFlipRotator); + throw new Win32Exception(); } - if (bSuccess == false) + // Copy the decoded image to the new buffer which backs the HBITMAP + WICRect rect = new() { - DestroyResources(); // cleans up _hwnd and _hBitmap - } + X = 0, + Y = 0, + Width = (int)width, + Height = (int)height + }; + + pBitmapFlipRotator.Value->CopyPixels(&rect, stride, stride * height, (byte*)pBitmapBits).ThrowOnFailure(); + + _hwnd = CreateWindow(_hBitmap, (int)width, (int)height, topMost); + } + catch + { + // Cleans up _hwnd and _hBitmap + DestroyResources(); + throw; } + } - return bSuccess; + ~SplashScreen() + { + DestroyResources(finalizer: true); } } } - diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj index e3aa0622062..6e819ddcde1 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj @@ -278,7 +278,6 @@ - @@ -378,6 +377,7 @@ + @@ -395,6 +395,7 @@ false +