diff --git a/Directory.Build.props b/Directory.Build.props
index 3de84a18463..1c94b5e5e2a 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -24,8 +24,9 @@
true
opencover
[System.Windows.*]*
-
-
+
+ [Microsoft.DotNet.XUnitExtensions]*,[xunit*]*
+
Obsolete,ExcludeFromCodeCoverage
@@ -39,4 +40,9 @@
true
+
+
+ $(MicrosoftNETCoreAppPackageVersion)
+
+
diff --git a/Directory.Build.targets b/Directory.Build.targets
index ebfe8c81517..e94b652da15 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -22,4 +22,18 @@
-
\ No newline at end of file
+
+
+
+ $(MicrosoftNETCoreAppPackageVersion)
+
+
+
+
+
+
+
+
+
+
diff --git a/Documentation/building.md b/Documentation/building.md
index 1b5e8212a1f..e9ca49a8252 100644
--- a/Documentation/building.md
+++ b/Documentation/building.md
@@ -40,6 +40,8 @@ Note that this does **not** build using your machine-wide installed version of t
* Other error may be from MSBuild tasks. You need to examine the build logs to investigate.
* The logs are generated at `artifacts\log\Debug\Build.binlog`
* The file format is an MSBuild Binary Log. Install the [MSBuild Structured Log Viewer][msbuild-log-viewer] to view them.
+* WinForms uses Visual Studio MSBuild but sometimes with a preview .NET Core SDK; so if you have a non-preview version of [Visual Studio][VS-download] (i.e. a release version), then you may need to enable `use preview` for .NET Core SDKs in VS.
+ * you can do this in VS at Tools :arrow_right: options :arrow_right: Projects and Solutions :arrow_right: .net core :arrow_right: use previews
## Creating a package
@@ -49,4 +51,5 @@ To create the Microsoft.Private.Winforms package, run `.\build -pack`
[corefx-windows-instructions]: https://github.com/dotnet/corefx/blob/master/Documentation/building/windows-instructions.md
[latest-core-build]: https://github.com/dotnet/core/blob/master/daily-builds.md
-[msbuild-log-viewer]: http://msbuildlog.com/
\ No newline at end of file
+[msbuild-log-viewer]: http://msbuildlog.com/
+[VS-download]: https://visualstudio.microsoft.com/downloads/
diff --git a/Documentation/developer-guide.md b/Documentation/developer-guide.md
index 77bc6b05948..03e23b3e38c 100644
--- a/Documentation/developer-guide.md
+++ b/Documentation/developer-guide.md
@@ -6,7 +6,7 @@ The [Issue Guide](issue-guide.md) describes our approach to using GitHub issues.
## Machine Setup
-Follow the [Building CoreFX on Windows][corefx-windows-instructions] instructions. However, we recommend Visual Studio 2019 Preview 1.
+Follow the [Building CoreFX on Windows][corefx-windows-instructions] instructions. In particular, [Visual Studio 2019 Preview][vs-preview] is required to develop on .NET Core.
Windows Forms requires the following workloads and components be selected when installing Visual Studio:
@@ -39,6 +39,7 @@ You first need to [Fork][fork] and [Clone][clone] this WinForms repository. This
[comment]: <> (URI Links)
[corefx-windows-instructions]: https://github.com/dotnet/corefx/blob/master/Documentation/building/windows-instructions.md
+[vs-preview]: https://visualstudio.microsoft.com/vs/preview/
[fork]: https://github.com/dotnet/corefx/wiki/Checking-out-the-code-repository#fork-the-repository
[clone]: https://github.com/dotnet/corefx/wiki/Checking-out-the-code-repository#clone-the-repository
[git-commands]: https://github.com/dotnet/corefx/wiki/git-reference
diff --git a/Documentation/getting-started.md b/Documentation/getting-started.md
index 94d4a978b36..16140c1261b 100644
--- a/Documentation/getting-started.md
+++ b/Documentation/getting-started.md
@@ -6,7 +6,7 @@ This document describes the experience of using WinForms on .NET Core. The [Deve
Choose one of these options:
-1. [.NET Core 3.0 SDK Preview 1 (recommended)][.net-core-3.0-sdk-preview-1]
+1. [.NET Core 3.0 SDK Preview 1 (recommended)][.net-core-3.0-sdk-preview]
1. [.NET Core 3.0 daily build (latest changes, but less stable)][.net-core-3.0-daily]
@@ -34,6 +34,6 @@ To port your existing WinForms application from .NET Framework to .NET Core 3.0,
[comment]: <> (URI Links)
-[.net-core-3.0-sdk-preview-1]: https://www.microsoft.com/net/download
+[.net-core-3.0-sdk-preview]: https://dotnet.microsoft.com/download/dotnet-core/3.0
[.net-core-3.0-daily]: https://github.com/dotnet/core/blob/master/daily-builds.md
-[.net-core-3.0-samples]: https://github.com/dotnet/samples/tree/master/windowsforms
\ No newline at end of file
+[.net-core-3.0-samples]: https://github.com/dotnet/samples/tree/master/windowsforms
diff --git a/Documentation/porting-guidelines.md b/Documentation/porting-guidelines.md
index 55c9eabeb14..cbeafa15de3 100644
--- a/Documentation/porting-guidelines.md
+++ b/Documentation/porting-guidelines.md
@@ -85,6 +85,10 @@ For additional information and assistance, we recommend checking out [this artic
## Migration tips
+### Include the System.Windows.Forms.Datavisualization Pack
+
+If you wish to use types previously associated with the [Charting control in the .NET Framework][framework-charting], you should add a package reference to the [NuGet package of Data Visualization][nuget-dataviz] ported to .NET Core. For more information about Data Visualization and the Charting control in .NET Core, including a sample application demonstrating its use, see the [winforms-datavisualization repository][dataviz]
+
### Include the Windows.Compatibility Pack
Windows applications like Windows Forms and WPF often use APIs that aren't referenced by default in .NET Core. The reason is that .NET Core tries to reduce the risk that new applications accidentally depend on legacy technologies or on APIs that are Windows-only. However, when porting existing Windows applications, neither of these two aspects is a concern. To simplify your porting efforts, you can simply reference the [Windows Compatibility Pack][compat-pack], which will give
@@ -115,5 +119,8 @@ System.PlatformNotSupportedException: 'Configuration files are not supported.'
[api-port]: https://blogs.msdn.microsoft.com/dotnet/2018/08/08/are-your-windows-forms-and-wpf-applications-ready-for-net-core-3-0/
[pkg-config]: https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference
[sdk-tool]:https://github.com/hvanbakel/CsprojToVs2017
+[framework-charting]: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting
+[nuget-dataviz]: https://www.nuget.org/packages/System.windows.forms.datavisualization
+[dataviz]: https://github.com/dotnet/winforms-datavisualization
[compat-pack]: https://docs.microsoft.com/en-us/dotnet/core/porting/windows-compat-pack
-[wcf-supported]: https://github.com/dotnet/wcf/blob/master/release-notes/SupportedFeatures-v2.1.0.md
\ No newline at end of file
+[wcf-supported]: https://github.com/dotnet/wcf/blob/master/release-notes/SupportedFeatures-v2.1.0.md
diff --git a/Winforms.sln b/Winforms.sln
index 360bde95e34..5d702209575 100644
--- a/Winforms.sln
+++ b/Winforms.sln
@@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Tests", "src\System.Windows.Forms\tests\UnitTests\System.Windows.Forms.Tests.csproj", "{AB38E262-F206-4820-8F29-23C5F72A4A16}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Private.Winforms", "pkg\Microsoft.Private.Winforms.csproj", "{F133342A-3040-4005-A2F0-7685AA7CB82D}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Design.Editors", "src\System.Windows.Forms.Design.Editors\src\System.Windows.Forms.Design.Editors.csproj", "{B50AC96F-2655-4687-A404-16DF51882CBC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Windows.Forms.Design.Editors.Tests", "src\System.Windows.Forms.Design.Editors\tests\UnitTests\System.Windows.Forms.Design.Editors.Tests.csproj", "{27F24D0C-5F0A-472E-AE12-98B386A13D50}"
@@ -23,6 +21,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Design.Facad
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Design.Facade", "src\System.Design\src\System.Design.Facade.csproj", "{9BEC2806-D8E0-443B-8B58-9D344E0C2D24}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Private.Winforms", "pkg\Microsoft.Private.Winforms\Microsoft.Private.Winforms.csproj", "{F133342A-3040-4005-A2F0-7685AA7CB82D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Dotnet.Winforms.ProjectTemplates", "pkg\Microsoft.Dotnet.WinForms.ProjectTemplates\Microsoft.Dotnet.Winforms.ProjectTemplates.csproj", "{36A5139E-3E9C-42BD-95EE-818153A487DB}"
+EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pkg", "pkg", "{989F376E-AE19-43B0-A3E6-96A7E22B4E80}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}"
@@ -116,6 +118,10 @@ Global
{6103E743-057D-41C6-946C-23A751A08748}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6103E743-057D-41C6-946C-23A751A08748}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6103E743-057D-41C6-946C-23A751A08748}.Release|Any CPU.Build.0 = Release|Any CPU
+ {36A5139E-3E9C-42BD-95EE-818153A487DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {36A5139E-3E9C-42BD-95EE-818153A487DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {36A5139E-3E9C-42BD-95EE-818153A487DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {36A5139E-3E9C-42BD-95EE-818153A487DB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -139,6 +145,7 @@ Global
{351D8601-6E21-45E8-B3B9-847C4540BD4E} = {088DD24C-DF6B-45F3-A8BC-592580A4B2A9}
{6103E743-057D-41C6-946C-23A751A08748} = {088DD24C-DF6B-45F3-A8BC-592580A4B2A9}
{088DD24C-DF6B-45F3-A8BC-592580A4B2A9} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
+ {36A5139E-3E9C-42BD-95EE-818153A487DB} = {989F376E-AE19-43B0-A3E6-96A7E22B4E80}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B1B0433-F612-4E5A-BE7E-FCF5B9F6E136}
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 1e492df7685..c631379ca9a 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -5,7 +5,8 @@
# so they can be used to control yaml flow.
variables:
-
+ _PublishUsingPipelines: true
+ _DotNetArtifactsCategory: WINDOWSDESKTOP
# clean the local repo on the build agents
Build.Repository.Clean: true
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index d2a895b395d..dbaa4b8edbc 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -7,73 +7,77 @@ Note: if the Uri is a new place, you will need to add a subscription from that p
-->
-
- https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+
+
+
+
+ https://github.com/dotnet/core-setup
+ a2ccf1ad6ed1735ed1b1631661710c755356db00
-
+
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
- https://github.com/dotnet/core-setup
- 4ea0233e38681384ee91d7a72c011db9c02e35ff
+
+ https://github.com/dotnet/corefx
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
-
-
+
https://github.com/dotnet/corefx
- 2c1cf10610d8102e080b203ff396707eeced15bd
+ bdd2014f2d1863a296f76b5c90152ae016854afc
-
- https://github.com/dotnet/arcade
- 505e38906e1ee2d032c41bb297de0958307db946
+
+
+ https://github.com/dotnet/coreclr
+ 8808f4eab10d1760182590cad4964f566b9c88ca
+ 5596
-
- https://github.com/dotnet/arcade
- 505e38906e1ee2d032c41bb297de0958307db946
+
+ https://github.com/dotnet/coreclr
+ 8808f4eab10d1760182590cad4964f566b9c88ca
+ 5596
-
+
+
https://github.com/dotnet/arcade
- 505e38906e1ee2d032c41bb297de0958307db946
+ e02c88fca482f1141a9bb310c97be20b0ebd0465
-
+
https://github.com/dotnet/arcade
- 505e38906e1ee2d032c41bb297de0958307db946
+ e02c88fca482f1141a9bb310c97be20b0ebd0465
-
- https://github.com/dotnet/coreclr
- 2520798548b0c414f513aaaf708399f8ef5a4f6c
- 5596
+
+ https://github.com/dotnet/arcade
+ e02c88fca482f1141a9bb310c97be20b0ebd0465
-
- https://github.com/dotnet/coreclr
- 2520798548b0c414f513aaaf708399f8ef5a4f6c
- 5596
+
+ https://github.com/dotnet/arcade
+ e02c88fca482f1141a9bb310c97be20b0ebd0465
diff --git a/eng/Versions.props b/eng/Versions.props
index 407d263b9c3..bcb91b47b1b 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -3,7 +3,7 @@
4.8.0
- preview4
+ preview6
false
@@ -12,28 +12,35 @@
https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json
-
+
+
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 4.6.0-preview4.19181.2
- 3.0.0-preview4.19181.2
+ 3.0.0-preview6-27625-10
-
+
- 3.0.0-preview4-27525-72
+ 3.0.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
+ 4.6.0-preview6.19225.3
-
+
- 1.0.0-beta.19201.12
- 2.4.0-beta.19201.12
+ 3.0.0-preview5-27616-73
+ 3.0.0-preview6-27624-71
-
+
+
+ 1.0.0-beta.19224.9
+ 2.4.0-beta.19224.9
+
+
+
2.4.1-pre.build.4059
$(XUnitVersion)
diff --git a/eng/ci.yml b/eng/ci.yml
index 0c669dcf2c7..011a835469c 100644
--- a/eng/ci.yml
+++ b/eng/ci.yml
@@ -14,8 +14,9 @@ jobs:
enablePublishBuildArtifacts: true
enablePublishTestResults: true
enablePublishBuildAssets: true
+ enablePublishUsingPipelines: $(_PublishUsingPipelines)
enableTelemetry: true
- helixRepo: $(repoName)
+ helixRepo: ${{ parameters.repoName }}
jobs:
- job: Windows_NT
@@ -47,13 +48,7 @@ jobs:
# needed for helix jobs
- name: _TestHelixAgentPool
- value: 'Windows.10.Amd64.Open'
- - name: _WinformsControlsTestBinDir
- value: $(BUILD.SOURCESDIRECTORY)\artifacts\bin\WinformsControlsTest\$(_BuildConfig)\netcoreapp3.0
- - name: _WinformsFuncTestBinDir
- value: $(BUILD.SOURCESDIRECTORY)\artifacts\bin\System.Windows.Forms.Func.Tests\$(_BuildConfig)\netcoreapp3.0
- - name: _HelixStagingDir
- value: $(BUILD.STAGINGDIRECTORY)\helix\functests
+ value: 'Windows.10.Amd64.ClientRS5.Open'
- name: _HelixSource
value: ${{ parameters.repoName }}/$(Build.SourceBranch)
- name: _HelixToken
@@ -89,6 +84,8 @@ jobs:
value: /p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1)
/p:DotNetPublishBlobFeedUrl=$(_PublishBlobFeedUrl)
/p:DotNetPublishToBlobFeed=$(_DotNetPublishToBlobFeed)
+ /p:DotNetPublishUsingPipelines=$(_PublishUsingPipelines)
+ /p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory)
/p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat)
/p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat)
- name: _OfficialBuildIdArgs
@@ -96,7 +93,7 @@ jobs:
# Windows.81.Amd64 will fail on Debug.Assert in TryGetSystemMetricsForDpi in UnsafeNativeMethods
- name: _TestHelixAgentPool
- value: 'Windows.10.Amd64'
+ value: 'Windows.10.Amd64.ClientRS5'
- name: _HelixSource
value: official/${{ parameters.repoName }}/$(Build.SourceBranch)
- name: _HelixToken
@@ -218,13 +215,13 @@ jobs:
# Publish the nuget package as a build artifact (only for release, ensuring package contents are real-signed)
- task: PublishPipelineArtifact@0
inputs:
- artifactName: 'Package'
+ artifactName: 'Packages'
targetPath: '$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping'
- displayName: Publish package to build artifacts
+ displayName: Publish transport NuGet package & templates package to build artifacts
continueOnError: true
condition: and(succeeded(), eq(variables['_BuildConfig'], 'Release'))
# Run component governance detection (only for release; only for internal)
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: Component Governance Detection
- condition: and(succeeded(), eq(variables['_BuildConfig'], 'Release'))
\ No newline at end of file
+ condition: and(succeeded(), eq(variables['_BuildConfig'], 'Release'))
diff --git a/eng/common/CheckSymbols.ps1 b/eng/common/CheckSymbols.ps1
new file mode 100644
index 00000000000..b8d84607b89
--- /dev/null
+++ b/eng/common/CheckSymbols.ps1
@@ -0,0 +1,158 @@
+param(
+ [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where NuGet packages to be checked are stored
+ [Parameter(Mandatory=$true)][string] $ExtractPath, # Full path to directory where the packages will be extracted during validation
+ [Parameter(Mandatory=$true)][string] $SymbolToolPath # Full path to directory where dotnet symbol-tool was installed
+)
+
+Add-Type -AssemblyName System.IO.Compression.FileSystem
+
+function FirstMatchingSymbolDescriptionOrDefault {
+ param(
+ [string] $FullPath, # Full path to the module that has to be checked
+ [string] $TargetServerParam, # Parameter to pass to `Symbol Tool` indicating the server to lookup for symbols
+ [string] $SymbolsPath
+ )
+
+ $FileName = [System.IO.Path]::GetFileName($FullPath)
+ $Extension = [System.IO.Path]::GetExtension($FullPath)
+
+ # Those below are potential symbol files that the `dotnet symbol` might
+ # return. Which one will be returned depend on the type of file we are
+ # checking and which type of file was uploaded.
+
+ # The file itself is returned
+ $SymbolPath = $SymbolsPath + "\" + $FileName
+
+ # PDB file for the module
+ $PdbPath = $SymbolPath.Replace($Extension, ".pdb")
+
+ # PDB file for R2R module (created by crossgen)
+ $NGenPdb = $SymbolPath.Replace($Extension, ".ni.pdb")
+
+ # DBG file for a .so library
+ $SODbg = $SymbolPath.Replace($Extension, ".so.dbg")
+
+ # DWARF file for a .dylib
+ $DylibDwarf = $SymbolPath.Replace($Extension, ".dylib.dwarf")
+
+ .\dotnet-symbol.exe --symbols --modules --windows-pdbs $TargetServerParam $FullPath -o $SymbolsPath | Out-Null
+
+ if (Test-Path $PdbPath) {
+ return "PDB"
+ }
+ elseif (Test-Path $NGenPdb) {
+ return "NGen PDB"
+ }
+ elseif (Test-Path $SODbg) {
+ return "DBG for SO"
+ }
+ elseif (Test-Path $DylibDwarf) {
+ return "Dwarf for Dylib"
+ }
+ elseif (Test-Path $SymbolPath) {
+ return "Module"
+ }
+ else {
+ return $null
+ }
+}
+
+function CountMissingSymbols {
+ param(
+ [string] $PackagePath # Path to a NuGet package
+ )
+
+ # Ensure input file exist
+ if (!(Test-Path $PackagePath)) {
+ throw "Input file does not exist: $PackagePath"
+ }
+
+ # Extensions for which we'll look for symbols
+ $RelevantExtensions = @(".dll", ".exe", ".so", ".dylib")
+
+ # How many files are missing symbol information
+ $MissingSymbols = 0
+
+ $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath)
+ $PackageGuid = New-Guid
+ $ExtractPath = Join-Path -Path $ExtractPath -ChildPath $PackageGuid
+ $SymbolsPath = Join-Path -Path $ExtractPath -ChildPath "Symbols"
+
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($PackagePath, $ExtractPath)
+
+ # Makes easier to reference `symbol tool`
+ Push-Location $SymbolToolPath
+
+ Get-ChildItem -Recurse $ExtractPath |
+ Where-Object {$RelevantExtensions -contains $_.Extension} |
+ ForEach-Object {
+ if ($_.FullName -Match "\\ref\\") {
+ Write-Host "`t Ignoring reference assembly file" $_.FullName
+ return
+ }
+
+ $SymbolsOnMSDL = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--microsoft-symbol-server" $SymbolsPath
+ $SymbolsOnSymWeb = FirstMatchingSymbolDescriptionOrDefault $_.FullName "--internal-server" $SymbolsPath
+
+ Write-Host -NoNewLine "`t Checking file" $_.FullName "... "
+
+ if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) {
+ Write-Host "Symbols found on MSDL (" $SymbolsOnMSDL ") and SymWeb (" $SymbolsOnSymWeb ")"
+ }
+ else {
+ $MissingSymbols++
+
+ if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) {
+ Write-Host "No symbols found on MSDL or SymWeb!"
+ }
+ else {
+ if ($SymbolsOnMSDL -eq $null) {
+ Write-Host "No symbols found on MSDL!"
+ }
+ else {
+ Write-Host "No symbols found on SymWeb!"
+ }
+ }
+ }
+ }
+
+ Pop-Location
+
+ return $MissingSymbols
+}
+
+function CheckSymbolsAvailable {
+ if (Test-Path $ExtractPath) {
+ Remove-Item $ExtractPath -Force -Recurse -ErrorAction SilentlyContinue
+ }
+
+ Get-ChildItem "$InputPath\*.nupkg" |
+ ForEach-Object {
+ $FileName = $_.Name
+
+ # These packages from Arcade-Services include some native libraries that
+ # our current symbol uploader can't handle. Below is a workaround until
+ # we get issue: https://github.com/dotnet/arcade/issues/2457 sorted.
+ if ($FileName -Match "Microsoft\.DotNet\.Darc\.") {
+ Write-Host "Ignoring Arcade-services file: $FileName"
+ Write-Host
+ return
+ }
+ elseif ($FileName -Match "Microsoft\.DotNet\.Maestro\.Tasks\.") {
+ Write-Host "Ignoring Arcade-services file: $FileName"
+ Write-Host
+ return
+ }
+
+ Write-Host "Validating $FileName "
+ $Status = CountMissingSymbols "$InputPath\$FileName"
+
+ if ($Status -ne 0) {
+ Write-Error "Missing symbols for $Status modules in the package $FileName"
+ }
+
+ Write-Host
+ }
+}
+
+CheckSymbolsAvailable
diff --git a/eng/common/PublishToPackageFeed.proj b/eng/common/PublishToPackageFeed.proj
index ccb81e8c355..e17f72644e3 100644
--- a/eng/common/PublishToPackageFeed.proj
+++ b/eng/common/PublishToPackageFeed.proj
@@ -1,11 +1,13 @@
-
+
+
+
netcoreapp2.1
@@ -41,6 +43,16 @@
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
https://dotnetfeed.blob.core.windows.net/arcade-validation/index.json
+ https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json
+ https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore-tooling/index.json
+ https://dotnetfeed.blob.core.windows.net/aspnet-entityframeworkcore/index.json
+ https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json
+ https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json
+ https://dotnetfeed.blob.core.windows.net/dotnet-sdk/index.json
+ https://dotnetfeed.blob.core.windows.net/dotnet-tools-internal/index.json
+ https://dotnetfeed.blob.core.windows.net/dotnet-toolset/index.json
+ https://dotnetfeed.blob.core.windows.net/dotnet-windowsdesktop/index.json
+ https://dotnetfeed.blob.core.windows.net/nuget-nugetclient/index.json
+
+
+
+
+ netcoreapp2.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3650
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/eng/common/SigningValidation.proj b/eng/common/SigningValidation.proj
index 17e40d12877..7045fb6fb9d 100644
--- a/eng/common/SigningValidation.proj
+++ b/eng/common/SigningValidation.proj
@@ -1,18 +1,20 @@
-
+
+
-
+ - PackageBasePath : Directory containing all files that need to be validated.
+ - SignCheckVersion : Version of SignCheck package to be used.
+ - SignValidationExclusionList : ItemGroup containing exclusion list to be forwarded to SignCheck.
+ - EnableJarSigningCheck : Whether .jar files should be validated.
+ - EnableStrongNameCheck : Whether strong name check should be performed.
+ -->
+
netcoreapp2.1
diff --git a/eng/common/darc-init.ps1 b/eng/common/darc-init.ps1
index 29c443212b4..81ffd16779c 100644
--- a/eng/common/darc-init.ps1
+++ b/eng/common/darc-init.ps1
@@ -19,7 +19,7 @@ function InstallDarcCli ($darcVersion) {
# Until we can anonymously query the BAR API for the latest arcade-services
# build applied to the PROD channel, this is hardcoded.
if (-not $darcVersion) {
- $darcVersion = '1.1.0-beta.19175.6'
+ $darcVersion = '1.1.0-beta.19205.4'
}
$arcadeServicesSource = 'https://dotnetfeed.blob.core.windows.net/dotnet-arcade/index.json'
diff --git a/eng/common/darc-init.sh b/eng/common/darc-init.sh
old mode 100644
new mode 100755
index cab6cd5bf9f..bd7eb463986
--- a/eng/common/darc-init.sh
+++ b/eng/common/darc-init.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
source="${BASH_SOURCE[0]}"
-darcVersion="1.1.0-beta.19175.6"
+darcVersion="1.1.0-beta.19205.4"
while [[ $# > 0 ]]; do
opt="$(echo "$1" | awk '{print tolower($0)}')"
diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj
index 1a81ff906f6..1a39a7ef3f6 100644
--- a/eng/common/internal/Tools.csproj
+++ b/eng/common/internal/Tools.csproj
@@ -12,8 +12,12 @@
-
- https://devdiv.pkgs.visualstudio.com/_packaging/8f470c7e-ac49-4afe-a6ee-cf784e438b93/nuget/v3/index.json;
+
+
+ https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json;
+
+
+ $(RestoreSources);
https://devdiv.pkgs.visualstudio.com/_packaging/VS/nuget/v3/index.json;
diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml
index 74dd81fdc0a..7839b70bb70 100644
--- a/eng/common/templates/job/job.yml
+++ b/eng/common/templates/job/job.yml
@@ -43,9 +43,12 @@ parameters:
# Optional: enable sending telemetry
enableTelemetry: false
- # Optional: define the helix repo for telemeetry (example: 'dotnet/arcade')
+ # Optional: define the helix repo for telemetry (example: 'dotnet/arcade')
helixRepo: ''
+ # Optional: define the helix type for telemetry (example: 'build/product/')
+ helixType: ''
+
# Required: name of the job
name: ''
@@ -122,6 +125,8 @@ jobs:
displayName: 'Send Helix Start Telemetry'
inputs:
helixRepo: ${{ parameters.helixRepo }}
+ ${{ if ne(parameters.helixType, '') }}:
+ helixType: ${{ parameters.helixType }}
buildConfig: $(_BuildConfig)
runAsPublic: ${{ parameters.runAsPublic }}
continueOnError: ${{ parameters.continueOnError }}
diff --git a/eng/common/templates/phases/publish-build-assets.yml b/eng/common/templates/phases/publish-build-assets.yml
index 211967debab..a0a8074282a 100644
--- a/eng/common/templates/phases/publish-build-assets.yml
+++ b/eng/common/templates/phases/publish-build-assets.yml
@@ -5,6 +5,7 @@ parameters:
condition: succeeded()
continueOnError: false
runAsPublic: false
+ publishUsingPipelines: false
phases:
- phase: Asset_Registry_Publish
displayName: Publish to Build Asset Registry
@@ -36,6 +37,7 @@ phases:
/p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests'
/p:BuildAssetRegistryToken=$(MaestroAccessToken)
/p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com
+ /p:PublishUsingPipelines=${{ parameters.publishUsingPipelines }}
/p:Configuration=$(_BuildConfig)
condition: ${{ parameters.condition }}
continueOnError: ${{ parameters.continueOnError }}
diff --git a/eng/common/templates/steps/helix-publish.yml b/eng/common/templates/steps/helix-publish.yml
deleted file mode 100644
index 470ab65da0c..00000000000
--- a/eng/common/templates/steps/helix-publish.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-parameters:
- HelixSource: 'pr/dotnet-github-anon-kaonashi-bot'
- HelixType: ̓'tests/default'
- HelixBuild: $(Build.BuildNumber)
- HelixTargetQueues: ''
- HelixAccessToken: ''
- HelixPreCommands: ''
- HelixPostCommands: ''
- WorkItemDirectory: ''
- WorkItemCommand: ''
- CorrelationPayloadDirectory: ''
- XUnitProjects: ''
- XUnitTargetFramework: ''
- XUnitRunnerVersion: ''
- IncludeDotNetCli: false
- DotNetCliPackageType: ''
- DotNetCliVersion: ''
- EnableXUnitReporter: false
- WaitForWorkItemCompletion: true
- condition: succeeded()
- continueOnError: false
-
-steps:
- - task: DotNetCoreCLI@2
- inputs:
- command: custom
- projects: eng/common/helixpublish.proj
- custom: msbuild
- arguments: '/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog'
- displayName: Send job to Helix
- env:
- HelixSource: ${{ parameters.HelixSource }}
- HelixType: ${{ parameters.HelixType }}
- HelixBuild: ${{ parameters.HelixBuild }}
- HelixTargetQueues: ${{ parameters.HelixTargetQueues }}
- HelixAccessToken: ${{ parameters.HelixAccessToken }}
- HelixPreCommands: ${{ parameters.HelixPreCommands }}
- HelixPostCommands: ${{ parameters.HelixPostCommands }}
- WorkItemDirectory: ${{ parameters.WorkItemDirectory }}
- WorkItemCommand: ${{ parameters.WorkItemCommand }}
- CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }}
- XUnitProjects: ${{ parameters.XUnitProjects }}
- XUnitRuntimeTargetFramework: ${{ parameters.XUnitTargetFramework }}
- XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }}
- IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }}
- DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }}
- DotNetCliVersion: ${{ parameters.DotNetCliVersion }}
- EnableXUnitReporter: ${{ parameters.EnableXUnitReporter }}
- WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }}
- condition: ${{ parameters.condition }}
- continueOnError: ${{ parameters.continueOnError }}
diff --git a/eng/common/templates/steps/send-to-helix.yml b/eng/common/templates/steps/send-to-helix.yml
index 7c185e94147..d1ce577db5b 100644
--- a/eng/common/templates/steps/send-to-helix.yml
+++ b/eng/common/templates/steps/send-to-helix.yml
@@ -23,7 +23,7 @@ parameters:
WaitForWorkItemCompletion: true # optional -- true will make the task wait until work items have been completed and fail the build if work items fail. False is "fire and forget."
IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set
Creator: '' # optional -- if the build is external, use this to specify who is sending the job
- DisplayNamePrefix: 'Send job to Helix' # optional -- rename the beginning of the displayName of the steps in AzDO
+ DisplayNamePrefix: 'Run Tests' # optional -- rename the beginning of the displayName of the steps in AzDO
condition: succeeded() # optional -- condition for step to execute; defaults to succeeded()
continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false
diff --git a/global.json b/global.json
index 7bff5a4fe96..0ce915fd3f7 100644
--- a/global.json
+++ b/global.json
@@ -1,17 +1,17 @@
{
"tools": {
- "dotnet": "3.0.100-preview4-010924",
+ "dotnet": "3.0.100-preview5-011162",
"vs": {
"version": "16.0"
},
"xcopy-msbuild": "16.0.0-rc1-alpha"
},
"sdk": {
- "version": "3.0.100-preview4-010924"
+ "version": "3.0.100-preview5-011162"
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19201.12",
- "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19201.12",
- "Microsoft.NET.Sdk.IL": "3.0.0-preview4-27525-72"
+ "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19224.9",
+ "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19224.9",
+ "Microsoft.NET.Sdk.IL": "3.0.0-preview6-27624-71"
}
}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/Microsoft.Dotnet.Winforms.ProjectTemplates.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/Microsoft.Dotnet.Winforms.ProjectTemplates.csproj
new file mode 100644
index 00000000000..9c3f4ceed31
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/Microsoft.Dotnet.Winforms.ProjectTemplates.csproj
@@ -0,0 +1,79 @@
+
+
+
+ netcoreapp
+ 3.0
+ $(TargetFrameworkName)$(TargetFrameworkVersion)
+ false
+ false
+
+
+
+
+ true
+
+
+
+ false
+ false
+ false
+
+
+
+
+ false
+
+
+
+
+ Microsoft.Dotnet.WinForms.ProjectTemplates
+ Project templates for .NET Core Windows Forms projects
+ Microsoft
+ https://github.com/dotnet/winforms
+ Windows Forms WinForms Project Templates .NET Core
+
+
+
+
+ .\
+
+
+
+
+
+
+ .\
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ BuildOnlySettings;
+ PrepareForBuild;
+ PreBuildEvent;
+ ResolveReferences;
+ GetTargetPath;
+ PrepareForRun;
+ IncrementalClean;
+ PostBuildEvent
+
+
+
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/dotnetcli.host.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/dotnetcli.host.json
new file mode 100644
index 00000000000..22ab4a3929f
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/dotnetcli.host.json
@@ -0,0 +1,24 @@
+{
+ "$schema": "http://json.schemastore.org/dotnetcli.host",
+ "symbolInfo": {
+ "TargetFrameworkOverride": {
+ "isHidden": "true",
+ "longName": "target-framework-override",
+ "shortName": ""
+ },
+ "Framework": {
+ "longName": "framework"
+ },
+ "skipRestore": {
+ "longName": "no-restore",
+ "shortName": ""
+ },
+ "langVersion": {
+ "longName": "langVersion",
+ "shortName": ""
+ }
+ },
+ "usageExamples": [
+ ""
+ ]
+}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json
new file mode 100644
index 00000000000..e9226dbf010
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json
@@ -0,0 +1,86 @@
+{
+ "$schema": "http://json.schemastore.org/template",
+ "author": "Microsoft",
+ "classifications": ["Common", "WinForms"],
+ "name": "Windows Forms (WinForms) Application",
+ "generatorVersions": "[1.0.0.0-*)",
+ "description": "A project for creating a .NET Core Windows Forms (WinForms) Application",
+ "groupIdentity": "Microsoft.Common.WinForms",
+ "precedence": "3000",
+ "identity": "Microsoft.Common.WinForms",
+ "shortName": "winforms",
+ "tags": {
+ "language": "C#",
+ "type": "project"
+ },
+ "sourceName": "Company.WinFormsApplication1",
+ "preferNameDirectory": true,
+ "symbols": {
+ "TargetFrameworkOverride": {
+ "type": "parameter",
+ "description": "Overrides the target framework",
+ "replaces": "TargetFrameworkOverride",
+ "datatype": "string",
+ "defaultValue": ""
+ },
+ "Framework": {
+ "type": "parameter",
+ "description": "The target framework for the project.",
+ "datatype": "choice",
+ "choices": [
+ {
+ "choice": "netcoreapp3.0",
+ "description": "Target netcoreapp3.0"
+ }
+ ],
+ "replaces": "netcoreapp3.0",
+ "defaultValue": "netcoreapp3.0"
+ },
+ "langVersion": {
+ "type": "parameter",
+ "datatype": "text",
+ "description": "Sets langVersion in the created project file",
+ "defaultValue": "",
+ "replaces": "$(ProjectLanguageVersion)"
+ },
+ "HostIdentifier": {
+ "type": "bind",
+ "binding": "HostIdentifier"
+ },
+ "skipRestore": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "If specified, skips the automatic restore of the project on create.",
+ "defaultValue": "false"
+ }
+ },
+ "primaryOutputs": [
+ { "path": "Company.WinFormsApplication1.csproj" },
+ {
+ "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
+ "path": "Form1.cs"
+ }
+ ],
+ "defaultName": "WinFormsApp1",
+ "postActions": [
+ {
+ "condition": "(!skipRestore)",
+ "description": "Restore NuGet packages required by this project.",
+ "manualInstructions": [
+ { "text": "Run 'dotnet restore'" }
+ ],
+ "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
+ "continueOnError": true
+ },
+ {
+ "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
+ "description": "Opens Form1.cs in the editor",
+ "manualInstructions": [ ],
+ "actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
+ "args": {
+ "files": "1"
+ },
+ "continueOnError": true
+ }
+ ]
+}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj
new file mode 100644
index 00000000000..9dd6eb88bed
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj
@@ -0,0 +1,12 @@
+
+
+
+ WinExe
+ netcoreapp3.0
+ TargetFrameworkOverride
+ Company.WinFormsApplication1
+ $(ProjectLanguageVersion)
+ true
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.Designer.cs
new file mode 100644
index 00000000000..5ee8d7b46e1
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.Designer.cs
@@ -0,0 +1,40 @@
+namespace Company.WinFormsApplication1
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "Form1";
+ }
+
+ #endregion
+ }
+}
+
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.cs
new file mode 100644
index 00000000000..0ac1f900f5d
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Company.WinFormsApplication1
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ }
+}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.resx b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.resx
new file mode 100644
index 00000000000..1af7de150c9
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs
new file mode 100644
index 00000000000..0b950cc7851
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Company.WinFormsApplication1
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.cs.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.cs.xlf
new file mode 100644
index 00000000000..aa40faef86f
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.cs.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.de.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.de.xlf
new file mode 100644
index 00000000000..caab0ce76f7
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.de.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.es.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.es.xlf
new file mode 100644
index 00000000000..37761f811ce
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.es.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.fr.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.fr.xlf
new file mode 100644
index 00000000000..366eb9d5436
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.fr.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.it.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.it.xlf
new file mode 100644
index 00000000000..e68d3fe2676
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.it.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ja.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ja.xlf
new file mode 100644
index 00000000000..2943ecce294
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ja.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ko.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ko.xlf
new file mode 100644
index 00000000000..83cb763b8f6
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ko.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.pl.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.pl.xlf
new file mode 100644
index 00000000000..58b6edd6da0
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.pl.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.pt-BR.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.pt-BR.xlf
new file mode 100644
index 00000000000..073f6c00557
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.pt-BR.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ru.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ru.xlf
new file mode 100644
index 00000000000..5d784e2bc56
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.ru.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.tr.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.tr.xlf
new file mode 100644
index 00000000000..9ae0ede5336
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.tr.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.zh-Hans.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.zh-Hans.xlf
new file mode 100644
index 00000000000..2dbdc8d0ce3
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.zh-Hans.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.zh-Hant.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.zh-Hant.xlf
new file mode 100644
index 00000000000..8782e525d98
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/xlf/Form1.zh-Hant.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/dotnetcli.host.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/dotnetcli.host.json
new file mode 100644
index 00000000000..22ab4a3929f
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/dotnetcli.host.json
@@ -0,0 +1,24 @@
+{
+ "$schema": "http://json.schemastore.org/dotnetcli.host",
+ "symbolInfo": {
+ "TargetFrameworkOverride": {
+ "isHidden": "true",
+ "longName": "target-framework-override",
+ "shortName": ""
+ },
+ "Framework": {
+ "longName": "framework"
+ },
+ "skipRestore": {
+ "longName": "no-restore",
+ "shortName": ""
+ },
+ "langVersion": {
+ "longName": "langVersion",
+ "shortName": ""
+ }
+ },
+ "usageExamples": [
+ ""
+ ]
+}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json
new file mode 100644
index 00000000000..f30b7c910b8
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/.template.config/template.json
@@ -0,0 +1,86 @@
+{
+ "$schema": "http://json.schemastore.org/template",
+ "author": "Microsoft",
+ "classifications": ["Common", "WinForms"],
+ "name": "Windows Forms (WinForms) Application",
+ "generatorVersions": "[1.0.0.0-*)",
+ "description": "A project for creating a .NET Core Windows Forms (WinForms) Application",
+ "groupIdentity": "Microsoft.Common.WinForms",
+ "precedence": "3000",
+ "identity": "Microsoft.Common.WinForms.VisualBasic.3.0",
+ "shortName": "winforms",
+ "tags": {
+ "language": "VB",
+ "type": "project"
+ },
+ "sourceName": "Company.WinFormsApplication1",
+ "preferNameDirectory": true,
+ "symbols": {
+ "TargetFrameworkOverride": {
+ "type": "parameter",
+ "description": "Overrides the target framework",
+ "replaces": "TargetFrameworkOverride",
+ "datatype": "string",
+ "defaultValue": ""
+ },
+ "Framework": {
+ "type": "parameter",
+ "description": "The target framework for the project.",
+ "datatype": "choice",
+ "choices": [
+ {
+ "choice": "netcoreapp3.0",
+ "description": "Target netcoreapp3.0"
+ }
+ ],
+ "replaces": "netcoreapp3.0",
+ "defaultValue": "netcoreapp3.0"
+ },
+ "langVersion": {
+ "type": "parameter",
+ "datatype": "text",
+ "description": "Sets langVersion in the created project file",
+ "defaultValue": "",
+ "replaces": "$(ProjectLanguageVersion)"
+ },
+ "HostIdentifier": {
+ "type": "bind",
+ "binding": "HostIdentifier"
+ },
+ "skipRestore": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "If specified, skips the automatic restore of the project on create.",
+ "defaultValue": "false"
+ }
+ },
+ "primaryOutputs": [
+ { "path": "Company.WinFormsApplication1.vbproj" },
+ {
+ "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
+ "path": "Form1.vb"
+ }
+ ],
+ "defaultName": "WinFormsApp1",
+ "postActions": [
+ {
+ "condition": "(!skipRestore)",
+ "description": "Restore NuGet packages required by this project.",
+ "manualInstructions": [
+ { "text": "Run 'dotnet restore'" }
+ ],
+ "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
+ "continueOnError": true
+ },
+ {
+ "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
+ "description": "Opens Form1.vb in the editor",
+ "manualInstructions": [ ],
+ "actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
+ "args": {
+ "files": "1"
+ },
+ "continueOnError": true
+ }
+ ]
+}
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Company.WinFormsApplication1.vbproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Company.WinFormsApplication1.vbproj
new file mode 100644
index 00000000000..4c54d1a376e
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Company.WinFormsApplication1.vbproj
@@ -0,0 +1,19 @@
+
+
+
+ WinExe
+ netcoreapp3.0
+ TargetFrameworkOverride
+ Company.WinFormsApplication1
+ Company.WinFormsApplication1.Form1
+ $(ProjectLanguageVersion)
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.Designer.vb b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.Designer.vb
new file mode 100644
index 00000000000..a418df0ea8d
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.Designer.vb
@@ -0,0 +1,31 @@
+ _
+Partial Class Form1
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ Try
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+ components = New System.ComponentModel.Container()
+ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+ Me.ClientSize = New System.Drawing.Size(800, 450)
+ Me.Text = "Form1"
+ End Sub
+
+End Class
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.resx b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.resx
new file mode 100644
index 00000000000..1af7de150c9
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.vb b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.vb
new file mode 100644
index 00000000000..17d659563f3
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/Form1.vb
@@ -0,0 +1,3 @@
+Public Class Form1
+
+End Class
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.cs.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.cs.xlf
new file mode 100644
index 00000000000..aa40faef86f
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.cs.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.de.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.de.xlf
new file mode 100644
index 00000000000..caab0ce76f7
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.de.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.es.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.es.xlf
new file mode 100644
index 00000000000..37761f811ce
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.es.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.fr.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.fr.xlf
new file mode 100644
index 00000000000..366eb9d5436
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.fr.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.it.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.it.xlf
new file mode 100644
index 00000000000..e68d3fe2676
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.it.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ja.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ja.xlf
new file mode 100644
index 00000000000..2943ecce294
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ja.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ko.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ko.xlf
new file mode 100644
index 00000000000..83cb763b8f6
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ko.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.pl.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.pl.xlf
new file mode 100644
index 00000000000..58b6edd6da0
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.pl.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.pt-BR.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.pt-BR.xlf
new file mode 100644
index 00000000000..073f6c00557
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.pt-BR.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ru.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ru.xlf
new file mode 100644
index 00000000000..5d784e2bc56
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.ru.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.tr.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.tr.xlf
new file mode 100644
index 00000000000..9ae0ede5336
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.tr.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.zh-Hans.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.zh-Hans.xlf
new file mode 100644
index 00000000000..2dbdc8d0ce3
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.zh-Hans.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.zh-Hant.xlf b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.zh-Hant.xlf
new file mode 100644
index 00000000000..8782e525d98
--- /dev/null
+++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-VisualBasic/xlf/Form1.zh-Hant.xlf
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pkg/Microsoft.Private.Winforms.csproj b/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj
similarity index 74%
rename from pkg/Microsoft.Private.Winforms.csproj
rename to pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj
index aa41a551f85..47b1e68d3a4 100644
--- a/pkg/Microsoft.Private.Winforms.csproj
+++ b/pkg/Microsoft.Private.Winforms/Microsoft.Private.Winforms.csproj
@@ -14,18 +14,26 @@
-->
+ netcoreapp
+ 3.0
+ $(TargetFrameworkName)$(TargetFrameworkVersion)
+
+
+
+
+ true
+
+
false
false
false
+
- netcoreapp3.0
- true
-
+
false
-
@@ -45,24 +53,25 @@
-
+
-
+
-
+
-
+
-
+
-
+
+
+
-
diff --git a/src/Common/src/ClientUtils.cs b/src/Common/src/ClientUtils.cs
index 246116a1c8f..0f1072e6bbc 100644
--- a/src/Common/src/ClientUtils.cs
+++ b/src/Common/src/ClientUtils.cs
@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
-#if WINFORMS_NAMESPACE
+#if DRAWING_DESIGN_NAMESPACE
namespace System.Windows.Forms
#elif DRAWING_NAMESPACE
namespace System.Drawing
@@ -270,7 +270,7 @@ private static void Debug_NonSequentialEnumIsDefinedCheck(System.Enum value, int
/// -----------------------------------------------------------------
///
///
-#if WINFORMS_NAMESPACE || WINFORMS_PUBLIC_GRAPHICS_LIBRARY || DRAWING_NAMESPACE
+#if DRAWING_DESIGN_NAMESPACE || WINFORMS_PUBLIC_GRAPHICS_LIBRARY || DRAWING_NAMESPACE
internal class WeakRefCollection : IList {
private int refCheckThreshold = int.MaxValue; // this means this is disabled by default.
private ArrayList _innerList;
diff --git a/src/Common/src/CompModSwitches.cs b/src/Common/src/CompModSwitches.cs
index ae6bdd9c862..a02feae0396 100644
--- a/src/Common/src/CompModSwitches.cs
+++ b/src/Common/src/CompModSwitches.cs
@@ -6,15 +6,10 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.ComponentModel.CompModSwitches.get_LayoutPerformance():System.Diagnostics.TraceSwitch")]
namespace System.ComponentModel {
- using System.Diagnostics;
+ using System.Diagnostics;
- ///
- // Shared between dlls
-
internal static class CompModSwitches {
-#if WINDOWS_FORMS_SWITCHES
-
private static TraceSwitch activeX;
private static TraceSwitch flowLayout;
private static TraceSwitch dataCursor;
@@ -23,17 +18,17 @@ internal static class CompModSwitches {
private static TraceSwitch dataGridKeys;
private static TraceSwitch dataGridLayout;
private static TraceSwitch dataGridPainting;
- private static TraceSwitch dataGridParents;
+ private static TraceSwitch dataGridParents;
private static TraceSwitch dataGridScrolling;
- private static TraceSwitch dataGridSelection;
- private static TraceSwitch dataObject;
+ private static TraceSwitch dataGridSelection;
+ private static TraceSwitch dataObject;
private static TraceSwitch dataView;
private static TraceSwitch debugGridView;
- private static TraceSwitch dgCaptionPaint;
- private static TraceSwitch dgEditColumnEditing;
+ private static TraceSwitch dgCaptionPaint;
+ private static TraceSwitch dgEditColumnEditing;
private static TraceSwitch dgRelationShpRowLayout;
private static TraceSwitch dgRelationShpRowPaint;
- private static TraceSwitch dgRowPaint;
+ private static TraceSwitch dgRowPaint;
private static TraceSwitch dragDrop;
private static TraceSwitch imeMode;
private static TraceSwitch msaa;
@@ -44,7 +39,11 @@ internal static class CompModSwitches {
private static TraceSwitch setBounds;
private static BooleanSwitch lifetimeTracing;
-
+
+ private static TraceSwitch s_handleLeak;
+ private static BooleanSwitch s_traceCollect;
+ private static BooleanSwitch s_commonDesignerServices;
+
public static TraceSwitch ActiveX {
get {
if (activeX == null) {
@@ -52,7 +51,7 @@ public static TraceSwitch ActiveX {
}
return activeX;
}
- }
+ }
public static TraceSwitch DataCursor {
get {
@@ -89,7 +88,7 @@ public static TraceSwitch DataGridKeys {
return dataGridKeys;
}
}
-
+
public static TraceSwitch DataGridLayout {
get {
if (dataGridLayout == null) {
@@ -107,7 +106,7 @@ public static TraceSwitch DataGridPainting {
return dataGridPainting;
}
}
-
+
public static TraceSwitch DataGridParents {
get {
if (dataGridParents == null) {
@@ -134,7 +133,7 @@ public static TraceSwitch DataGridSelection {
return dataGridSelection;
}
}
-
+
public static TraceSwitch DataObject {
get {
if (dataObject == null) {
@@ -151,7 +150,7 @@ public static TraceSwitch DataView {
}
return dataView;
}
- }
+ }
public static TraceSwitch DebugGridView {
get {
@@ -160,8 +159,8 @@ public static TraceSwitch DebugGridView {
}
return debugGridView;
}
- }
-
+ }
+
public static TraceSwitch DGCaptionPaint {
get {
if (dgCaptionPaint == null) {
@@ -170,7 +169,7 @@ public static TraceSwitch DGCaptionPaint {
return dgCaptionPaint;
}
}
-
+
public static TraceSwitch DGEditColumnEditing {
get {
if (dgEditColumnEditing == null) {
@@ -179,7 +178,7 @@ public static TraceSwitch DGEditColumnEditing {
return dgEditColumnEditing;
}
}
-
+
public static TraceSwitch DGRelationShpRowLayout {
get {
if (dgRelationShpRowLayout == null) {
@@ -188,7 +187,7 @@ public static TraceSwitch DGRelationShpRowLayout {
return dgRelationShpRowLayout;
}
}
-
+
public static TraceSwitch DGRelationShpRowPaint {
get {
if (dgRelationShpRowPaint == null) {
@@ -196,8 +195,8 @@ public static TraceSwitch DGRelationShpRowPaint {
}
return dgRelationShpRowPaint;
}
- }
-
+ }
+
public static TraceSwitch DGRowPaint {
get {
if (dgRowPaint == null) {
@@ -223,8 +222,8 @@ public static TraceSwitch FlowLayout {
}
return flowLayout;
}
- }
-
+ }
+
public static TraceSwitch ImeMode {
get {
if (imeMode == null) {
@@ -242,7 +241,7 @@ public static TraceSwitch LayoutPerformance {
return layoutPerformance;
}
}
-
+
public static TraceSwitch LayoutSuspendResume {
get {
if (layoutSuspendResume == null) {
@@ -260,7 +259,7 @@ public static BooleanSwitch LifetimeTracing {
return lifetimeTracing;
}
}
-
+
public static TraceSwitch MSAA {
get {
if (msaa == null) {
@@ -269,7 +268,7 @@ public static TraceSwitch MSAA {
return msaa;
}
}
-
+
public static TraceSwitch MSOComponentManager {
get {
if (msoComponentManager == null) {
@@ -278,7 +277,7 @@ public static TraceSwitch MSOComponentManager {
return msoComponentManager;
}
}
-
+
public static TraceSwitch RichLayout {
get {
if (richLayout == null) {
@@ -286,8 +285,7 @@ public static TraceSwitch RichLayout {
}
return richLayout;
}
- }
-
+ }
public static TraceSwitch SetBounds {
get {
@@ -296,32 +294,36 @@ public static TraceSwitch SetBounds {
}
return setBounds;
}
- }
-
- #endif
-
-
-
- private static TraceSwitch handleLeak;
+ }
public static TraceSwitch HandleLeak {
get {
- if (handleLeak == null) {
- handleLeak = new TraceSwitch("HANDLELEAK", "HandleCollector: Track Win32 Handle Leaks");
+ if (s_handleLeak == null) {
+ s_handleLeak = new TraceSwitch("HANDLELEAK", "HandleCollector: Track Win32 Handle Leaks");
}
- return handleLeak;
+ return s_handleLeak;
}
}
- private static BooleanSwitch traceCollect;
public static BooleanSwitch TraceCollect {
get {
- if (traceCollect == null) {
- traceCollect = new BooleanSwitch("TRACECOLLECT", "HandleCollector: Trace HandleCollector operations");
+ if (s_traceCollect == null) {
+ s_traceCollect = new BooleanSwitch("TRACECOLLECT", "HandleCollector: Trace HandleCollector operations");
}
- return traceCollect;
+ return s_traceCollect;
}
}
+ public static BooleanSwitch CommonDesignerServices
+ {
+ get
+ {
+ if (s_commonDesignerServices == null)
+ {
+ s_commonDesignerServices = new BooleanSwitch("CommonDesignerServices", "Assert if any common designer service is not found.");
+ }
+ return s_commonDesignerServices;
+ }
+ }
}
}
diff --git a/src/Common/src/DpiHelper.cs b/src/Common/src/DpiHelper.cs
index 013636236d7..ca30e7a25e2 100644
--- a/src/Common/src/DpiHelper.cs
+++ b/src/Common/src/DpiHelper.cs
@@ -6,15 +6,10 @@
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
-#if WINFORMS_NAMESPACE
-using CAPS = System.Windows.Forms.NativeMethods;
-#elif WINFORMS_DESIGN_NAMESPACE
+#if DRAWING_DESIGN_NAMESPACE
using CAPS = System.Windows.Forms.NativeMethods;
#elif DRAWING_NAMESPACE
using CAPS = System.Drawing.SafeNativeMethods;
-#elif DRAWINGDESIGN_NAMESPACE
-using System.Drawing.Design;
-using CAPS = System.Drawing.Design.NativeMethods;
#else
using CAPS = System.Experimental.Gdi;
#endif
@@ -292,6 +287,17 @@ public static Bitmap CreateResizedBitmap(Bitmap logicalImage, Size targetImageSi
return ScaleBitmapToSize(logicalImage, targetImageSize);
}
+ ///
+ /// Creating bitmap from Icon resource
+ ///
+ public static Bitmap GetBitmapFromIcon(Type t, string name)
+ {
+ Icon b = new Icon(t, name);
+ Bitmap bitmap = b.ToBitmap();
+ b.Dispose();
+ return bitmap;
+ }
+
///
/// Create a new bitmap scaled for the device units.
/// When displayed on the device, the scaled image will have same size as the original image would have when displayed at 96dpi.
@@ -314,7 +320,7 @@ public static void ScaleBitmapLogicalToDevice(ref Bitmap logicalBitmap, int devi
// This method is used only in System.Design, thus excluding the rest.
// This is particularly important for System.Drawing, which should not depend
// on System.Windows.Forms assembly, where "Button" type is defined.
-#if (!DRAWING_NAMESPACE && !DRAWINGDESIGN_NAMESPACE && !WINFORMS_NAMESPACE)
+#if (!DRAWING_NAMESPACE && !DRAWING_DESIGN_NAMESPACE)
///
/// Create a new button bitmap scaled for the device units.
/// Note: original image might be disposed.
diff --git a/src/Common/src/Interop/Interop.EditMessages.cs b/src/Common/src/Interop/Interop.EditMessages.cs
new file mode 100644
index 00000000000..cc696a39c72
--- /dev/null
+++ b/src/Common/src/Interop/Interop.EditMessages.cs
@@ -0,0 +1,135 @@
+// 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.
+
+internal static partial class Interop
+{
+ public static class EditMessages
+ {
+ public const int EM_GETSEL = 0x00B0;
+ public const int EM_SETSEL = 0x00B1;
+ public const int EM_SCROLL = 0x00B5;
+ public const int EM_GETMODIFY = 0x00B8;
+ public const int EM_SETMODIFY = 0x00B9;
+ public const int EM_GETLINECOUNT = 0x00BA;
+ public const int EM_REPLACESEL = 0x00C2;
+ public const int EM_GETLINE = 0x00C4;
+ public const int EM_LIMITTEXT = 0x00C5;
+ public const int EM_CANUNDO = 0x00C6;
+ public const int EM_UNDO = 0x00C7;
+ public const int EM_SETPASSWORDCHAR = 0x00CC;
+ public const int EM_GETPASSWORDCHAR = 0x00D2;
+ public const int EM_EMPTYUNDOBUFFER = 0x00CD;
+ public const int EM_SETREADONLY = 0x00CF;
+ public const int EM_SETMARGINS = 0x00D3;
+ public const int EM_LINEFROMCHAR = 0x00C9;
+ public const int EM_GETFIRSTVISIBLELINE = 0x00CE;
+ public const int EM_LINEINDEX = 0x00BB;
+
+ public const int EM_GETLIMITTEXT = (WindowMessages.WM_USER + 37);
+
+ public const int EM_POSFROMCHAR = (WindowMessages.WM_USER + 38);
+ public const int EM_CHARFROMPOS = (WindowMessages.WM_USER + 39);
+
+ public const int EM_SCROLLCARET = (WindowMessages.WM_USER + 49);
+ public const int EM_CANPASTE = (WindowMessages.WM_USER + 50);
+ public const int EM_DISPLAYBAND = (WindowMessages.WM_USER + 51);
+ public const int EM_EXGETSEL = (WindowMessages.WM_USER + 52);
+ public const int EM_EXLIMITTEXT = (WindowMessages.WM_USER + 53);
+ public const int EM_EXLINEFROMCHAR = (WindowMessages.WM_USER + 54);
+ public const int EM_EXSETSEL = (WindowMessages.WM_USER + 55);
+ public const int EM_FINDTEXT = (WindowMessages.WM_USER + 56);
+ public const int EM_FORMATRANGE = (WindowMessages.WM_USER + 57);
+ public const int EM_GETCHARFORMAT = (WindowMessages.WM_USER + 58);
+ public const int EM_GETEVENTMASK = (WindowMessages.WM_USER + 59);
+ public const int EM_GETOLEINTERFACE = (WindowMessages.WM_USER + 60);
+ public const int EM_GETPARAFORMAT = (WindowMessages.WM_USER + 61);
+ public const int EM_GETSELTEXT = (WindowMessages.WM_USER + 62);
+ public const int EM_HIDESELECTION = (WindowMessages.WM_USER + 63);
+ public const int EM_PASTESPECIAL = (WindowMessages.WM_USER + 64);
+ public const int EM_REQUESTRESIZE = (WindowMessages.WM_USER + 65);
+ public const int EM_SELECTIONTYPE = (WindowMessages.WM_USER + 66);
+ public const int EM_SETBKGNDCOLOR = (WindowMessages.WM_USER + 67);
+ public const int EM_SETCHARFORMAT = (WindowMessages.WM_USER + 68);
+ public const int EM_SETEVENTMASK = (WindowMessages.WM_USER + 69);
+ public const int EM_SETOLECALLBACK = (WindowMessages.WM_USER + 70);
+ public const int EM_SETPARAFORMAT = (WindowMessages.WM_USER + 71);
+ public const int EM_SETTARGETDEVICE = (WindowMessages.WM_USER + 72);
+ public const int EM_STREAMIN = (WindowMessages.WM_USER + 73);
+ public const int EM_STREAMOUT = (WindowMessages.WM_USER + 74);
+ public const int EM_GETTEXTRANGE = (WindowMessages.WM_USER + 75);
+ public const int EM_FINDWORDBREAK = (WindowMessages.WM_USER + 76);
+ public const int EM_SETOPTIONS = (WindowMessages.WM_USER + 77);
+ public const int EM_GETOPTIONS = (WindowMessages.WM_USER + 78);
+ public const int EM_FINDTEXTEX = (WindowMessages.WM_USER + 79);
+ public const int EM_GETWORDBREAKPROCEX = (WindowMessages.WM_USER + 80);
+ public const int EM_SETWORDBREAKPROCEX = (WindowMessages.WM_USER + 81);
+
+ // Richedit v2.0 messages
+ public const int EM_SETUNDOLIMIT = (WindowMessages.WM_USER + 82);
+ public const int EM_REDO = (WindowMessages.WM_USER + 84);
+ public const int EM_CANREDO = (WindowMessages.WM_USER + 85);
+ public const int EM_GETUNDONAME = (WindowMessages.WM_USER + 86);
+ public const int EM_GETREDONAME = (WindowMessages.WM_USER + 87);
+ public const int EM_STOPGROUPTYPING = (WindowMessages.WM_USER + 88);
+
+ public const int EM_SETTEXTMODE = (WindowMessages.WM_USER + 89);
+ public const int EM_GETTEXTMODE = (WindowMessages.WM_USER + 90);
+
+ public const int EM_AUTOURLDETECT = (WindowMessages.WM_USER + 91);
+ public const int EM_GETAUTOURLDETECT = (WindowMessages.WM_USER + 92);
+ public const int EM_SETPALETTE = (WindowMessages.WM_USER + 93);
+ public const int EM_GETTEXTEX = (WindowMessages.WM_USER + 94);
+ public const int EM_GETTEXTLENGTHEX = (WindowMessages.WM_USER + 95);
+
+ // Asia specific messages
+ public const int EM_SETPUNCTUATION = (WindowMessages.WM_USER + 100);
+ public const int EM_GETPUNCTUATION = (WindowMessages.WM_USER + 101);
+ public const int EM_SETWORDWRAPMODE = (WindowMessages.WM_USER + 102);
+ public const int EM_GETWORDWRAPMODE = (WindowMessages.WM_USER + 103);
+ public const int EM_SETIMECOLOR = (WindowMessages.WM_USER + 104);
+ public const int EM_GETIMECOLOR = (WindowMessages.WM_USER + 105);
+ public const int EM_SETIMEOPTIONS = (WindowMessages.WM_USER + 106);
+ public const int EM_GETIMEOPTIONS = (WindowMessages.WM_USER + 107);
+ public const int EM_CONVPOSITION = (WindowMessages.WM_USER + 108);
+
+ public const int EM_SETLANGOPTIONS = (WindowMessages.WM_USER + 120);
+ public const int EM_GETLANGOPTIONS = (WindowMessages.WM_USER + 121);
+ public const int EM_GETIMECOMPMODE = (WindowMessages.WM_USER + 122);
+
+ public const int EM_FINDTEXTW = (WindowMessages.WM_USER + 123);
+ public const int EM_FINDTEXTEXW = (WindowMessages.WM_USER + 124);
+
+ // Rich TextBox 3.0 Asia msgs
+ public const int EM_RECONVERSION = (WindowMessages.WM_USER + 125);
+ public const int EM_SETIMEMODEBIAS = (WindowMessages.WM_USER + 126);
+ public const int EM_GETIMEMODEBIAS = (WindowMessages.WM_USER + 127);
+
+ // BiDi Specific messages
+ public const int EM_SETBIDIOPTIONS = (WindowMessages.WM_USER + 200);
+ public const int EM_GETBIDIOPTIONS = (WindowMessages.WM_USER + 201);
+
+ public const int EM_SETTYPOGRAPHYOPTIONS = (WindowMessages.WM_USER + 202);
+ public const int EM_GETTYPOGRAPHYOPTIONS = (WindowMessages.WM_USER + 203);
+
+ // Extended TextBox style specific messages
+ public const int EM_SETEDITSTYLE = (WindowMessages.WM_USER + 204);
+ public const int EM_GETEDITSTYLE = (WindowMessages.WM_USER + 205);
+
+ // Ole Objects Disabling message
+ public const int EM_SETQUERYRTFOBJ = (WindowMessages.WM_USER + 270);
+
+ // Pegasus outline mode messages (RE 3.0)
+ // Outline mode message
+ internal const int EM_OUTLINE = Interop.WindowMessages.WM_USER + 220;
+
+ // Message for getting and restoring scroll pos
+ internal const int EM_GETSCROLLPOS = Interop.WindowMessages.WM_USER + 221;
+ internal const int EM_SETSCROLLPOS = Interop.WindowMessages.WM_USER + 222;
+
+ // Change fontsize in current selection by wparam
+ internal const int EM_SETFONTSIZE = Interop.WindowMessages.WM_USER + 223;
+ internal const int EM_GETZOOM = Interop.WindowMessages.WM_USER + 224;
+ internal const int EM_SETZOOM = Interop.WindowMessages.WM_USER + 225;
+ }
+}
\ No newline at end of file
diff --git a/src/Common/src/Interop/Interop.HRESULT.cs b/src/Common/src/Interop/Interop.HRESULT.cs
new file mode 100644
index 00000000000..addf249e199
--- /dev/null
+++ b/src/Common/src/Interop/Interop.HRESULT.cs
@@ -0,0 +1,11 @@
+// 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.
+
+internal static partial class Interop
+{
+ public static class HRESULT
+ {
+ public const int S_OK = 0;
+ }
+}
diff --git a/src/Common/src/Interop/Interop.Libraries.cs b/src/Common/src/Interop/Interop.Libraries.cs
new file mode 100644
index 00000000000..bb9384e9a4b
--- /dev/null
+++ b/src/Common/src/Interop/Interop.Libraries.cs
@@ -0,0 +1,14 @@
+// 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.
+
+internal static partial class Interop
+{
+ public static partial class Libraries
+ {
+ internal const string Kernel32 = "kernel32.dll";
+ internal const string Gdi32 = "gdi32.dll";
+ internal const string User32 = "user32.dll";
+ internal const string Shell32 = "shell32.dll";
+ }
+}
diff --git a/src/Common/src/Interop/Interop.WindowMessages.cs b/src/Common/src/Interop/Interop.WindowMessages.cs
new file mode 100644
index 00000000000..c65205b6454
--- /dev/null
+++ b/src/Common/src/Interop/Interop.WindowMessages.cs
@@ -0,0 +1,225 @@
+// 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.
+
+internal static partial class Interop
+{
+ public static class WindowMessages
+ {
+ public const int WM_NULL = 0x0000;
+ public const int WM_CREATE = 0x0001;
+ public const int WM_DELETEITEM = 0x002D;
+ public const int WM_DESTROY = 0x0002;
+ public const int WM_MOVE = 0x0003;
+ public const int WM_SIZE = 0x0005;
+ public const int WM_ACTIVATE = 0x0006;
+ public const int WM_SETFOCUS = 0x0007;
+ public const int WM_KILLFOCUS = 0x0008;
+ public const int WM_ENABLE = 0x000A;
+ public const int WM_SETREDRAW = 0x000B;
+ public const int WM_SETTEXT = 0x000C;
+ public const int WM_GETTEXT = 0x000D;
+ public const int WM_GETTEXTLENGTH = 0x000E;
+ public const int WM_PAINT = 0x000F;
+ public const int WM_CLOSE = 0x0010;
+ public const int WM_QUERYENDSESSION = 0x0011;
+ public const int WM_QUIT = 0x0012;
+ public const int WM_QUERYOPEN = 0x0013;
+ public const int WM_ERASEBKGND = 0x0014;
+ public const int WM_SYSCOLORCHANGE = 0x0015;
+ public const int WM_ENDSESSION = 0x0016;
+ public const int WM_SHOWWINDOW = 0x0018;
+ public const int WM_WININICHANGE = 0x001A;
+ public const int WM_SETTINGCHANGE = 0x001A;
+ public const int WM_DEVMODECHANGE = 0x001B;
+ public const int WM_ACTIVATEAPP = 0x001C;
+ public const int WM_FONTCHANGE = 0x001D;
+ public const int WM_TIMECHANGE = 0x001E;
+ public const int WM_CANCELMODE = 0x001F;
+ public const int WM_SETCURSOR = 0x0020;
+ public const int WM_MOUSEACTIVATE = 0x0021;
+ public const int WM_CHILDACTIVATE = 0x0022;
+ public const int WM_QUEUESYNC = 0x0023;
+ public const int WM_GETMINMAXINFO = 0x0024;
+ public const int WM_PAINTICON = 0x0026;
+ public const int WM_ICONERASEBKGND = 0x0027;
+ public const int WM_NEXTDLGCTL = 0x0028;
+ public const int WM_SPOOLERSTATUS = 0x002A;
+ public const int WM_DRAWITEM = 0x002B;
+ public const int WM_MEASUREITEM = 0x002C;
+ public const int WM_VKEYTOITEM = 0x002E;
+ public const int WM_CHARTOITEM = 0x002F;
+ public const int WM_SETFONT = 0x0030;
+ public const int WM_GETFONT = 0x0031;
+ public const int WM_SETHOTKEY = 0x0032;
+ public const int WM_GETHOTKEY = 0x0033;
+ public const int WM_QUERYDRAGICON = 0x0037;
+ public const int WM_COMPAREITEM = 0x0039;
+ public const int WM_GETOBJECT = 0x003D;
+ public const int WM_COMPACTING = 0x0041;
+ public const int WM_COMMNOTIFY = 0x0044;
+ public const int WM_WINDOWPOSCHANGING = 0x0046;
+ public const int WM_WINDOWPOSCHANGED = 0x0047;
+ public const int WM_POWER = 0x0048;
+ public const int WM_COPYDATA = 0x004A;
+ public const int WM_CANCELJOURNAL = 0x004B;
+ public const int WM_NOTIFY = 0x004E;
+ public const int WM_INPUTLANGCHANGEREQUEST = 0x0050;
+ public const int WM_INPUTLANGCHANGE = 0x0051;
+ public const int WM_TCARD = 0x0052;
+ public const int WM_HELP = 0x0053;
+ public const int WM_USERCHANGED = 0x0054;
+ public const int WM_NOTIFYFORMAT = 0x0055;
+ public const int WM_CONTEXTMENU = 0x007B;
+ public const int WM_STYLECHANGING = 0x007C;
+ public const int WM_STYLECHANGED = 0x007D;
+ public const int WM_DISPLAYCHANGE = 0x007E;
+ public const int WM_GETICON = 0x007F;
+ public const int WM_SETICON = 0x0080;
+ public const int WM_NCCREATE = 0x0081;
+ public const int WM_NCDESTROY = 0x0082;
+ public const int WM_NCCALCSIZE = 0x0083;
+ public const int WM_NCHITTEST = 0x0084;
+ public const int WM_NCPAINT = 0x0085;
+ public const int WM_NCACTIVATE = 0x0086;
+ public const int WM_GETDLGCODE = 0x0087;
+ public const int WM_NCMOUSEMOVE = 0x00A0;
+ public const int WM_NCMOUSELEAVE = 0x02A2;
+ public const int WM_NCLBUTTONDOWN = 0x00A1;
+ public const int WM_NCLBUTTONUP = 0x00A2;
+ public const int WM_NCLBUTTONDBLCLK = 0x00A3;
+ public const int WM_NCRBUTTONDOWN = 0x00A4;
+ public const int WM_NCRBUTTONUP = 0x00A5;
+ public const int WM_NCRBUTTONDBLCLK = 0x00A6;
+ public const int WM_NCMBUTTONDOWN = 0x00A7;
+ public const int WM_NCMBUTTONUP = 0x00A8;
+ public const int WM_NCMBUTTONDBLCLK = 0x00A9;
+ public const int WM_NCXBUTTONDOWN = 0x00AB;
+ public const int WM_NCXBUTTONUP = 0x00AC;
+ public const int WM_NCXBUTTONDBLCLK = 0x00AD;
+ public const int WM_KEYFIRST = 0x0100;
+ public const int WM_KEYDOWN = 0x0100;
+ public const int WM_KEYUP = 0x0101;
+ public const int WM_CHAR = 0x0102;
+ public const int WM_DEADCHAR = 0x0103;
+ public const int WM_CTLCOLOR = 0x0019;
+ public const int WM_SYSKEYDOWN = 0x0104;
+ public const int WM_SYSKEYUP = 0x0105;
+ public const int WM_SYSCHAR = 0x0106;
+ public const int WM_SYSDEADCHAR = 0x0107;
+ public const int WM_KEYLAST = 0x0108;
+ public const int WM_IME_STARTCOMPOSITION = 0x010D;
+ public const int WM_IME_ENDCOMPOSITION = 0x010E;
+ public const int WM_IME_COMPOSITION = 0x010F;
+ public const int WM_IME_KEYLAST = 0x010F;
+ public const int WM_INITDIALOG = 0x0110;
+ public const int WM_COMMAND = 0x0111;
+ public const int WM_SYSCOMMAND = 0x0112;
+ public const int WM_TIMER = 0x0113;
+ public const int WM_HSCROLL = 0x0114;
+ public const int WM_VSCROLL = 0x0115;
+ public const int WM_INITMENU = 0x0116;
+ public const int WM_INITMENUPOPUP = 0x0117;
+ public const int WM_MENUSELECT = 0x011F;
+ public const int WM_MENUCHAR = 0x0120;
+ public const int WM_ENTERIDLE = 0x0121;
+ public const int WM_UNINITMENUPOPUP = 0x0125;
+ public const int WM_CHANGEUISTATE = 0x0127;
+ public const int WM_UPDATEUISTATE = 0x0128;
+ public const int WM_QUERYUISTATE = 0x0129;
+ public const int WM_CTLCOLORMSGBOX = 0x0132;
+ public const int WM_CTLCOLOREDIT = 0x0133;
+ public const int WM_CTLCOLORLISTBOX = 0x0134;
+ public const int WM_CTLCOLORBTN = 0x0135;
+ public const int WM_CTLCOLORDLG = 0x0136;
+ public const int WM_CTLCOLORSCROLLBAR = 0x0137;
+ public const int WM_CTLCOLORSTATIC = 0x0138;
+ public const int WM_MOUSEFIRST = 0x0200;
+ public const int WM_MOUSEMOVE = 0x0200;
+ public const int WM_LBUTTONDOWN = 0x0201;
+ public const int WM_LBUTTONUP = 0x0202;
+ public const int WM_LBUTTONDBLCLK = 0x0203;
+ public const int WM_RBUTTONDOWN = 0x0204;
+ public const int WM_RBUTTONUP = 0x0205;
+ public const int WM_RBUTTONDBLCLK = 0x0206;
+ public const int WM_MBUTTONDOWN = 0x0207;
+ public const int WM_MBUTTONUP = 0x0208;
+ public const int WM_MBUTTONDBLCLK = 0x0209;
+ public const int WM_NCMOUSEHOVER = 0x02A0;
+ public const int WM_XBUTTONDOWN = 0x020B;
+ public const int WM_XBUTTONUP = 0x020C;
+ public const int WM_XBUTTONDBLCLK = 0x020D;
+ public const int WM_MOUSEWHEEL = 0x020A;
+ public const int WM_MOUSELAST = 0x020A;
+ public const int WM_PARENTNOTIFY = 0x0210;
+ public const int WM_ENTERMENULOOP = 0x0211;
+ public const int WM_EXITMENULOOP = 0x0212;
+ public const int WM_NEXTMENU = 0x0213;
+ public const int WM_SIZING = 0x0214;
+ public const int WM_CAPTURECHANGED = 0x0215;
+ public const int WM_MOVING = 0x0216;
+ public const int WM_POWERBROADCAST = 0x0218;
+ public const int WM_DEVICECHANGE = 0x0219;
+ public const int WM_IME_SETCONTEXT = 0x0281;
+ public const int WM_IME_NOTIFY = 0x0282;
+ public const int WM_IME_CONTROL = 0x0283;
+ public const int WM_IME_COMPOSITIONFULL = 0x0284;
+ public const int WM_IME_SELECT = 0x0285;
+ public const int WM_IME_CHAR = 0x0286;
+ public const int WM_IME_KEYDOWN = 0x0290;
+ public const int WM_IME_KEYUP = 0x0291;
+ public const int WM_MDICREATE = 0x0220;
+ public const int WM_MDIDESTROY = 0x0221;
+ public const int WM_MDIACTIVATE = 0x0222;
+ public const int WM_MDIRESTORE = 0x0223;
+ public const int WM_MDINEXT = 0x0224;
+ public const int WM_MDIMAXIMIZE = 0x0225;
+ public const int WM_MDITILE = 0x0226;
+ public const int WM_MDICASCADE = 0x0227;
+ public const int WM_MDIICONARRANGE = 0x0228;
+ public const int WM_MDIGETACTIVE = 0x0229;
+ public const int WM_MDISETMENU = 0x0230;
+ public const int WM_ENTERSIZEMOVE = 0x0231;
+ public const int WM_EXITSIZEMOVE = 0x0232;
+ public const int WM_DROPFILES = 0x0233;
+ public const int WM_MDIREFRESHMENU = 0x0234;
+ public const int WM_MOUSEHOVER = 0x02A1;
+ public const int WM_MOUSELEAVE = 0x02A3;
+ public const int WM_DPICHANGED = 0x02E0;
+ public const int WM_GETDPISCALEDSIZE = 0x02E1;
+ public const int WM_DPICHANGED_BEFOREPARENT = 0x02E2;
+ public const int WM_DPICHANGED_AFTERPARENT = 0x02E3;
+ public const int WM_CUT = 0x0300;
+ public const int WM_COPY = 0x0301;
+ public const int WM_PASTE = 0x0302;
+ public const int WM_CLEAR = 0x0303;
+ public const int WM_UNDO = 0x0304;
+ public const int WM_RENDERFORMAT = 0x0305;
+ public const int WM_RENDERALLFORMATS = 0x0306;
+ public const int WM_DESTROYCLIPBOARD = 0x0307;
+ public const int WM_DRAWCLIPBOARD = 0x0308;
+ public const int WM_PAINTCLIPBOARD = 0x0309;
+ public const int WM_VSCROLLCLIPBOARD = 0x030A;
+ public const int WM_SIZECLIPBOARD = 0x030B;
+ public const int WM_ASKCBFORMATNAME = 0x030C;
+ public const int WM_CHANGECBCHAIN = 0x030D;
+ public const int WM_HSCROLLCLIPBOARD = 0x030E;
+ public const int WM_QUERYNEWPALETTE = 0x030F;
+ public const int WM_PALETTEISCHANGING = 0x0310;
+ public const int WM_PALETTECHANGED = 0x0311;
+ public const int WM_HOTKEY = 0x0312;
+ public const int WM_PRINT = 0x0317;
+ public const int WM_PRINTCLIENT = 0x0318;
+ public const int WM_THEMECHANGED = 0x031A;
+ public const int WM_HANDHELDFIRST = 0x0358;
+ public const int WM_HANDHELDLAST = 0x035F;
+ public const int WM_AFXFIRST = 0x0360;
+ public const int WM_AFXLAST = 0x037F;
+ public const int WM_PENWINFIRST = 0x0380;
+ public const int WM_PENWINLAST = 0x038F;
+ public const int WM_APP = unchecked((int)0x8000);
+ public const int WM_USER = 0x0400;
+ public const int WM_REFLECT = WM_USER + 0x1C00;
+ public const int WM_CHOOSEFONT_GETLOGFONT = (0x0400+1);
+ }
+}
\ No newline at end of file
diff --git a/src/Common/src/Interop/Kernel32/Interop.MAX_PATH.cs b/src/Common/src/Interop/Kernel32/Interop.MAX_PATH.cs
new file mode 100644
index 00000000000..f7fa32669ba
--- /dev/null
+++ b/src/Common/src/Interop/Kernel32/Interop.MAX_PATH.cs
@@ -0,0 +1,11 @@
+// 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.
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ internal const int MAX_PATH = 260;
+ }
+}
diff --git a/src/Common/src/Interop/Kernel32/Interop.MAX_UNICODESTRING_LEN.cs b/src/Common/src/Interop/Kernel32/Interop.MAX_UNICODESTRING_LEN.cs
new file mode 100644
index 00000000000..f79886c337d
--- /dev/null
+++ b/src/Common/src/Interop/Kernel32/Interop.MAX_UNICODESTRING_LEN.cs
@@ -0,0 +1,11 @@
+// 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.
+
+internal partial class Interop
+{
+ internal partial class Kernel32
+ {
+ internal const int MAX_UNICODESTRING_LEN = short.MaxValue;
+ }
+}
diff --git a/src/Common/src/Interop/Shell32/Interop.SHBrowseForFolder.cs b/src/Common/src/Interop/Shell32/Interop.SHBrowseForFolder.cs
new file mode 100644
index 00000000000..19af10c12b0
--- /dev/null
+++ b/src/Common/src/Interop/Shell32/Interop.SHBrowseForFolder.cs
@@ -0,0 +1,53 @@
+// 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.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+internal static partial class Interop
+{
+ public static partial class Shell32
+ {
+ [DllImport(Libraries.Shell32)]
+ public static extern CoTaskMemSafeHandle SHBrowseForFolderW(ref BROWSEINFO lpbi);
+
+ public delegate int BrowseCallbackProc(IntPtr hwnd, int msg, IntPtr lParam, IntPtr lpData);
+
+ public static class BrowseInfoFlags
+ {
+ public const uint BIF_RETURNONLYFSDIRS = 0x00000001;
+ public const uint BIF_DONTGOBELOWDOMAIN = 0x00000002;
+ public const uint BIF_RETURNFSANCESTORS = 0x00000008;
+ public const uint BIF_EDITBOX = 0x00000010;
+ public const uint BIF_NEWDIALOGSTYLE = 0x00000040;
+ public const uint BIF_NONEWFOLDERBUTTON = 0x00000200;
+
+ public const uint BIF_BROWSEFORCOMPUTER = 0x00001000;
+ public const uint BIF_BROWSEFORPRINTER = 0x00002000;
+ public const uint BIF_BROWSEFOREVERYTHING = 0x00004000;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public unsafe struct BROWSEINFO
+ {
+ public IntPtr hwndOwner;
+
+ public CoTaskMemSafeHandle pidlRoot;
+
+ public char *pszDisplayName;
+
+ public string lpszTitle;
+
+ public uint ulFlags;
+
+ public BrowseCallbackProc lpfn;
+
+ public IntPtr lParam;
+
+ public int iImage;
+ }
+ }
+}
diff --git a/src/Common/src/Interop/Shell32/Interop.SHGetKnownFolderPath.cs b/src/Common/src/Interop/Shell32/Interop.SHGetKnownFolderPath.cs
new file mode 100644
index 00000000000..0947eb7fc54
--- /dev/null
+++ b/src/Common/src/Interop/Shell32/Interop.SHGetKnownFolderPath.cs
@@ -0,0 +1,15 @@
+// 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.InteropServices;
+
+internal static partial class Interop
+{
+ public static partial class Shell32
+ {
+ [DllImport(Libraries.Shell32, CharSet = CharSet.Unicode, SetLastError = false, BestFitMapping = false, ExactSpelling = true)]
+ public static extern int SHGetKnownFolderPath(ref Guid rfid, uint dwFlags, IntPtr hToken, out string pszPath);
+ }
+}
diff --git a/src/Common/src/Interop/Shell32/Interop.SHGetPathFromIDListLongPath.cs b/src/Common/src/Interop/Shell32/Interop.SHGetPathFromIDListLongPath.cs
new file mode 100644
index 00000000000..f3d91119478
--- /dev/null
+++ b/src/Common/src/Interop/Shell32/Interop.SHGetPathFromIDListLongPath.cs
@@ -0,0 +1,79 @@
+// 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.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+internal static partial class Interop
+{
+ public static partial class Shell32
+ {
+ [DllImport(ExternDll.Shell32, EntryPoint = "SHGetPathFromIDListEx", ExactSpelling = true)]
+ private static extern bool SHGetPathFromIDListEx(IntPtr pidl, IntPtr pszPath, int cchPath, int flags);
+
+ public static bool SHGetPathFromIDListLongPath(IntPtr pidl, out string path)
+ {
+ IntPtr pszPath = Marshal.AllocHGlobal((Interop.Kernel32.MAX_PATH + 1) * sizeof(char));
+ int length = Interop.Kernel32.MAX_PATH;
+ try
+ {
+ if (!SHGetPathFromIDListLongPath(pidl, ref pszPath, length))
+ {
+ path = null;
+ return false;
+ }
+
+ path = Marshal.PtrToStringAuto(pszPath);
+ return true;
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(pszPath);
+ }
+ }
+
+ public unsafe static bool SHGetPathFromIDListLongPath(IntPtr pidl, ref IntPtr pszPath, int length)
+ {
+ // SHGetPathFromIDListEx is basically a helper to get IShellFolder.DisplayNameOf() with some
+ // extra functionally built in if the various flags are set.
+
+ // SHGetPathFromIDListEx copies into the ouput buffer using StringCchCopyW, which truncates
+ // when there isn't enough space (with a terminating null) and fails. Long paths can be
+ // extracted by simply increasing the buffer size whenever the buffer is full.
+
+ // To get the equivalent functionality we could call SHBindToParent on the PIDL to get IShellFolder
+ // and then invoke IShellFolder.DisplayNameOf directly. This would avoid long path contortions as
+ // we could directly convert from STRRET, calling CoTaskMemFree manually. (Presuming the type is
+ // STRRET_WSTR, of course. Otherwise we can just fall back to StrRetToBufW and give up for > MAX_PATH.
+ // Presumption is that we shouldn't be getting back ANSI results, and if we are they are likely
+ // some very old component that won't have a > MAX_PATH string.)
+
+ // While we could avoid contortions and avoid intermediate buffers by invoking IShellFolder directly,
+ // it isn't without cost as we'd be initializing a COM wrapper (RCW) for IShellFolder. Presumably
+ // this is much less overhead then looping and copying to intermediate buffers before creating a string.
+ // Additionally, implementing this would allow us to short circuit the one caller (FolderBrowserDialog)
+ // who doesn't care about the path, but just wants to know that we have an IShellFolder.
+ while (SHGetPathFromIDListEx(pidl, pszPath, length, 0) == false)
+ {
+ if (length >= Kernel32.MAX_UNICODESTRING_LEN
+ || *(char*)pszPath.ToPointer() == '\0')
+ {
+ // Already at the maximum size string, or no data was copied in. Fail.
+ return false;
+ }
+
+ // Try giving the API a larger buffer
+ length = length * 2;
+ if (length > Kernel32.MAX_UNICODESTRING_LEN)
+ length = Kernel32.MAX_UNICODESTRING_LEN;
+
+ pszPath = Marshal.ReAllocHGlobal(pszPath, (IntPtr)(length * sizeof(char)));
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/Common/src/Interop/Shell32/Interop.SHGetSpecialFolderLocation.cs b/src/Common/src/Interop/Shell32/Interop.SHGetSpecialFolderLocation.cs
new file mode 100644
index 00000000000..f79c1bbe073
--- /dev/null
+++ b/src/Common/src/Interop/Shell32/Interop.SHGetSpecialFolderLocation.cs
@@ -0,0 +1,16 @@
+// 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.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+internal static partial class Interop
+{
+ public static partial class Shell32
+ {
+ [DllImport(Libraries.Shell32, EntryPoint = "SHGetSpecialFolderLocation", ExactSpelling = true)]
+ public static extern int SHGetSpecialFolderLocation(IntPtr hwnd, int csidl, out CoTaskMemSafeHandle ppidl);
+ }
+}
diff --git a/src/Common/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs b/src/Common/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs
new file mode 100644
index 00000000000..1f7ac1d4019
--- /dev/null
+++ b/src/Common/src/Microsoft/Win32/SafeHandles/CoTaskMemSafeHandle.cs
@@ -0,0 +1,25 @@
+// 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.InteropServices;
+
+namespace Microsoft.Win32.SafeHandles
+{
+ internal sealed class CoTaskMemSafeHandle : SafeHandle
+ {
+ internal CoTaskMemSafeHandle() : base(IntPtr.Zero, true)
+ {
+ }
+
+ public override bool IsInvalid => IsClosed || handle == IntPtr.Zero;
+
+ protected override bool ReleaseHandle()
+ {
+ Marshal.FreeCoTaskMem(handle);
+ handle = IntPtr.Zero;
+ return true;
+ }
+ }
+}
diff --git a/src/Common/src/NativeMethods.cs b/src/Common/src/NativeMethods.cs
index 10eb0da4654..1c01ae0a4ab 100644
--- a/src/Common/src/NativeMethods.cs
+++ b/src/Common/src/NativeMethods.cs
@@ -46,7 +46,6 @@ namespace System.Windows.Forms {
using Accessibility;
using System.Runtime.InteropServices;
using System;
- using System.Security.Permissions;
using System.Collections;
using System.Diagnostics;
using System.IO;
@@ -55,7 +54,8 @@ namespace System.Windows.Forms {
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.Versioning;
-
+ using static System.Windows.Forms.NativeMethods;
+
///
internal static class NativeMethods {
@@ -360,27 +360,7 @@ public const int
CONNECT_E_NOCONNECTION = unchecked((int)0x80040200),
CONNECT_E_CANNOTCONNECT = unchecked((int)0x80040202),
CTRLINFO_EATS_RETURN = 1,
- CTRLINFO_EATS_ESCAPE = 2,
- CSIDL_DESKTOP = 0x0000, //
- CSIDL_INTERNET = 0x0001, // Internet Explorer (icon on desktop)
- CSIDL_PROGRAMS = 0x0002, // Start Menu\Programs
- CSIDL_PERSONAL = 0x0005, // My Documents
- CSIDL_FAVORITES = 0x0006, // \Favorites
- CSIDL_STARTUP = 0x0007, // Start Menu\Programs\Startup
- CSIDL_RECENT = 0x0008, // \Recent
- CSIDL_SENDTO = 0x0009, // \SendTo
- CSIDL_STARTMENU = 0x000b, // \Start Menu
- CSIDL_DESKTOPDIRECTORY = 0x0010, // \Desktop
- CSIDL_TEMPLATES = 0x0015,
- CSIDL_APPDATA = 0x001a, // \Application Data
- CSIDL_LOCAL_APPDATA = 0x001c, // \Local Settings\Applicaiton Data (non roaming)
- CSIDL_INTERNET_CACHE = 0x0020,
- CSIDL_COOKIES = 0x0021,
- CSIDL_HISTORY = 0x0022,
- CSIDL_COMMON_APPDATA = 0x0023, // All Users\Application Data
- CSIDL_SYSTEM = 0x0025, // GetSystemDirectory()
- CSIDL_PROGRAM_FILES = 0x0026, // C:\Program Files
- CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
+ CTRLINFO_EATS_ESCAPE = 2;
public const int DUPLICATE = 0x06,
DISPID_UNKNOWN = (-1),
@@ -490,29 +470,7 @@ public const int
EN_ALIGN_LTR_EC = 0x0700,
EN_ALIGN_RTL_EC = 0x0701,
EC_LEFTMARGIN = 0x0001,
- EC_RIGHTMARGIN = 0x0002,
- EM_GETSEL = 0x00B0,
- EM_SETSEL = 0x00B1,
- EM_SCROLL = 0x00B5,
- EM_SCROLLCARET = 0x00B7,
- EM_GETMODIFY = 0x00B8,
- EM_SETMODIFY = 0x00B9,
- EM_GETLINECOUNT = 0x00BA,
- EM_REPLACESEL = 0x00C2,
- EM_GETLINE = 0x00C4,
- EM_LIMITTEXT = 0x00C5,
- EM_CANUNDO = 0x00C6,
- EM_UNDO = 0x00C7,
- EM_SETPASSWORDCHAR = 0x00CC,
- EM_GETPASSWORDCHAR = 0x00D2,
- EM_EMPTYUNDOBUFFER = 0x00CD,
- EM_SETREADONLY = 0x00CF,
- EM_SETMARGINS = 0x00D3,
- EM_POSFROMCHAR = 0x00D6,
- EM_CHARFROMPOS = 0x00D7,
- EM_LINEFROMCHAR = 0x00C9,
- EM_GETFIRSTVISIBLELINE = 0x00CE,
- EM_LINEINDEX = 0x00BB;
+ EC_RIGHTMARGIN = 0x0002;
public const int ERROR_INVALID_HANDLE = 6;
public const int ERROR_CLASS_ALREADY_EXISTS = 1410;
@@ -975,6 +933,12 @@ public const int
public const int LOCALE_IMEASURE = 0x0000000D; // 0 = metric, 1 = US
+ public const int TVM_SETEXTENDEDSTYLE = TV_FIRST + 44;
+ public const int TVM_GETEXTENDEDSTYLE = TV_FIRST + 45;
+
+ public const int TVS_EX_FADEINOUTEXPANDOS = 0x0040;
+ public const int TVS_EX_DOUBLEBUFFER = 0x0004;
+
public static readonly int LOCALE_USER_DEFAULT = MAKELCID(LANG_USER_DEFAULT);
public static readonly int LANG_USER_DEFAULT = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
@@ -1000,8 +964,6 @@ public static int MAKELCID(int lgid, int sort) {
public const int MEMBERID_NIL = (-1),
- MAX_PATH = 260,
- MAX_UNICODESTRING_LEN = short.MaxValue, // maximum unicode string length
ERROR_INSUFFICIENT_BUFFER = 122, //https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
MA_ACTIVATE = 0x0001,
MA_ACTIVATEANDEAT = 0x0002,
@@ -1094,10 +1056,10 @@ public static int MAKELCID(int lgid, int sort) {
NIIF_INFO = 0x00000001,
NIIF_WARNING = 0x00000002,
NIIF_ERROR = 0x00000003,
- NIN_BALLOONSHOW = (WM_USER + 2),
- NIN_BALLOONHIDE = (WM_USER + 3),
- NIN_BALLOONTIMEOUT = (WM_USER + 4),
- NIN_BALLOONUSERCLICK = (WM_USER + 5),
+ NIN_BALLOONSHOW = (Interop.WindowMessages.WM_USER + 2),
+ NIN_BALLOONHIDE = (Interop.WindowMessages.WM_USER + 3),
+ NIN_BALLOONTIMEOUT = (Interop.WindowMessages.WM_USER + 4),
+ NIN_BALLOONUSERCLICK = (Interop.WindowMessages.WM_USER + 5),
NFR_ANSI = 1,
NFR_UNICODE = 2,
NM_CLICK = ((0-0)-2),
@@ -1605,7 +1567,7 @@ public static bool Failed(int hr) {
TTM_POP = (0x0400 + 28),
TTM_ADJUSTRECT = (0x400 + 31),
TTM_SETDELAYTIME = (0x0400 + 3),
- TTM_SETTITLE = (WM_USER + 33), // wParam = TTI_*, lParam = wchar* szTitle
+ TTM_SETTITLE = (Interop.WindowMessages.WM_USER + 33), // wParam = TTI_*, lParam = wchar* szTitle
TTM_ADDTOOL = (0x0400 + 50),
TTM_DELTOOL = (0x0400 + 51),
TTM_NEWTOOLRECT = (0x0400 + 52),
@@ -1809,265 +1771,53 @@ public static bool Failed(int hr) {
VK_INSERT = 0x002D,
VK_DELETE = 0x002E;
- public const int WH_JOURNALPLAYBACK = 1,
- WH_GETMESSAGE = 3,
- WH_MOUSE = 7,
- WSF_VISIBLE = 0x0001,
- WM_NULL = 0x0000,
- WM_CREATE = 0x0001,
- WM_DELETEITEM = 0x002D,
- WM_DESTROY = 0x0002,
- WM_MOVE = 0x0003,
- WM_SIZE = 0x0005,
- WM_ACTIVATE = 0x0006,
- WA_INACTIVE = 0,
- WA_ACTIVE = 1,
- WA_CLICKACTIVE = 2,
- WM_SETFOCUS = 0x0007,
- WM_KILLFOCUS = 0x0008,
- WM_ENABLE = 0x000A,
- WM_SETREDRAW = 0x000B,
- WM_SETTEXT = 0x000C,
- WM_GETTEXT = 0x000D,
- WM_GETTEXTLENGTH = 0x000E,
- WM_PAINT = 0x000F,
- WM_CLOSE = 0x0010,
- WM_QUERYENDSESSION = 0x0011,
- WM_QUIT = 0x0012,
- WM_QUERYOPEN = 0x0013,
- WM_ERASEBKGND = 0x0014,
- WM_SYSCOLORCHANGE = 0x0015,
- WM_ENDSESSION = 0x0016,
- WM_SHOWWINDOW = 0x0018,
- WM_WININICHANGE = 0x001A,
- WM_SETTINGCHANGE = 0x001A,
- WM_DEVMODECHANGE = 0x001B,
- WM_ACTIVATEAPP = 0x001C,
- WM_FONTCHANGE = 0x001D,
- WM_TIMECHANGE = 0x001E,
- WM_CANCELMODE = 0x001F,
- WM_SETCURSOR = 0x0020,
- WM_MOUSEACTIVATE = 0x0021,
- WM_CHILDACTIVATE = 0x0022,
- WM_QUEUESYNC = 0x0023,
- WM_GETMINMAXINFO = 0x0024,
- WM_PAINTICON = 0x0026,
- WM_ICONERASEBKGND = 0x0027,
- WM_NEXTDLGCTL = 0x0028,
- WM_SPOOLERSTATUS = 0x002A,
- WM_DRAWITEM = 0x002B,
- WM_MEASUREITEM = 0x002C,
- WM_VKEYTOITEM = 0x002E,
- WM_CHARTOITEM = 0x002F,
- WM_SETFONT = 0x0030,
- WM_GETFONT = 0x0031,
- WM_SETHOTKEY = 0x0032,
- WM_GETHOTKEY = 0x0033,
- WM_QUERYDRAGICON = 0x0037,
- WM_COMPAREITEM = 0x0039,
- WM_GETOBJECT = 0x003D,
- WM_COMPACTING = 0x0041,
- WM_COMMNOTIFY = 0x0044,
- WM_WINDOWPOSCHANGING = 0x0046,
- WM_WINDOWPOSCHANGED = 0x0047,
- WM_POWER = 0x0048,
- WM_COPYDATA = 0x004A,
- WM_CANCELJOURNAL = 0x004B,
- WM_NOTIFY = 0x004E,
- WM_INPUTLANGCHANGEREQUEST = 0x0050,
- WM_INPUTLANGCHANGE = 0x0051,
- WM_TCARD = 0x0052,
- WM_HELP = 0x0053,
- WM_USERCHANGED = 0x0054,
- WM_NOTIFYFORMAT = 0x0055,
- WM_CONTEXTMENU = 0x007B,
- WM_STYLECHANGING = 0x007C,
- WM_STYLECHANGED = 0x007D,
- WM_DISPLAYCHANGE = 0x007E,
- WM_GETICON = 0x007F,
- WM_SETICON = 0x0080,
- WM_NCCREATE = 0x0081,
- WM_NCDESTROY = 0x0082,
- WM_NCCALCSIZE = 0x0083,
- WM_NCHITTEST = 0x0084,
- WM_NCPAINT = 0x0085,
- WM_NCACTIVATE = 0x0086,
- WM_GETDLGCODE = 0x0087,
- WM_NCMOUSEMOVE = 0x00A0,
- WM_NCMOUSELEAVE = 0x02A2,
- WM_NCLBUTTONDOWN = 0x00A1,
- WM_NCLBUTTONUP = 0x00A2,
- WM_NCLBUTTONDBLCLK = 0x00A3,
- WM_NCRBUTTONDOWN = 0x00A4,
- WM_NCRBUTTONUP = 0x00A5,
- WM_NCRBUTTONDBLCLK = 0x00A6,
- WM_NCMBUTTONDOWN = 0x00A7,
- WM_NCMBUTTONUP = 0x00A8,
- WM_NCMBUTTONDBLCLK = 0x00A9,
- WM_NCXBUTTONDOWN = 0x00AB,
- WM_NCXBUTTONUP = 0x00AC,
- WM_NCXBUTTONDBLCLK = 0x00AD,
- WM_KEYFIRST = 0x0100,
- WM_KEYDOWN = 0x0100,
- WM_KEYUP = 0x0101,
- WM_CHAR = 0x0102,
- WM_DEADCHAR = 0x0103,
- WM_CTLCOLOR = 0x0019,
- WM_SYSKEYDOWN = 0x0104,
- WM_SYSKEYUP = 0x0105,
- WM_SYSCHAR = 0x0106,
- WM_SYSDEADCHAR = 0x0107,
- WM_KEYLAST = 0x0108,
- WM_IME_STARTCOMPOSITION = 0x010D,
- WM_IME_ENDCOMPOSITION = 0x010E,
- WM_IME_COMPOSITION = 0x010F,
- WM_IME_KEYLAST = 0x010F,
- WM_INITDIALOG = 0x0110,
- WM_COMMAND = 0x0111,
- WM_SYSCOMMAND = 0x0112,
- WM_TIMER = 0x0113,
- WM_HSCROLL = 0x0114,
- WM_VSCROLL = 0x0115,
- WM_INITMENU = 0x0116,
- WM_INITMENUPOPUP = 0x0117,
- WM_MENUSELECT = 0x011F,
- WM_MENUCHAR = 0x0120,
- WM_ENTERIDLE = 0x0121,
- WM_UNINITMENUPOPUP = 0x0125,
- WM_CHANGEUISTATE = 0x0127,
- WM_UPDATEUISTATE = 0x0128,
- WM_QUERYUISTATE = 0x0129,
- WM_CTLCOLORMSGBOX = 0x0132,
- WM_CTLCOLOREDIT = 0x0133,
- WM_CTLCOLORLISTBOX = 0x0134,
- WM_CTLCOLORBTN = 0x0135,
- WM_CTLCOLORDLG = 0x0136,
- WM_CTLCOLORSCROLLBAR = 0x0137,
- WM_CTLCOLORSTATIC = 0x0138,
- WM_MOUSEFIRST = 0x0200,
- WM_MOUSEMOVE = 0x0200,
- WM_LBUTTONDOWN = 0x0201,
- WM_LBUTTONUP = 0x0202,
- WM_LBUTTONDBLCLK = 0x0203,
- WM_RBUTTONDOWN = 0x0204,
- WM_RBUTTONUP = 0x0205,
- WM_RBUTTONDBLCLK = 0x0206,
- WM_MBUTTONDOWN = 0x0207,
- WM_MBUTTONUP = 0x0208,
- WM_MBUTTONDBLCLK = 0x0209,
- WM_XBUTTONDOWN = 0x020B,
- WM_XBUTTONUP = 0x020C,
- WM_XBUTTONDBLCLK = 0x020D,
- WM_MOUSEWHEEL = 0x020A,
- WM_MOUSELAST = 0x020A;
-
- public const int WHEEL_DELTA = 120,
- WM_PARENTNOTIFY = 0x0210,
- WM_ENTERMENULOOP = 0x0211,
- WM_EXITMENULOOP = 0x0212,
- WM_NEXTMENU = 0x0213,
- WM_SIZING = 0x0214,
- WM_CAPTURECHANGED = 0x0215,
- WM_MOVING = 0x0216,
- WM_POWERBROADCAST = 0x0218,
- WM_DEVICECHANGE = 0x0219,
- WM_IME_SETCONTEXT = 0x0281,
- WM_IME_NOTIFY = 0x0282,
- WM_IME_CONTROL = 0x0283,
- WM_IME_COMPOSITIONFULL = 0x0284,
- WM_IME_SELECT = 0x0285,
- WM_IME_CHAR = 0x0286,
- WM_IME_KEYDOWN = 0x0290,
- WM_IME_KEYUP = 0x0291,
- WM_MDICREATE = 0x0220,
- WM_MDIDESTROY = 0x0221,
- WM_MDIACTIVATE = 0x0222,
- WM_MDIRESTORE = 0x0223,
- WM_MDINEXT = 0x0224,
- WM_MDIMAXIMIZE = 0x0225,
- WM_MDITILE = 0x0226,
- WM_MDICASCADE = 0x0227,
- WM_MDIICONARRANGE = 0x0228,
- WM_MDIGETACTIVE = 0x0229,
- WM_MDISETMENU = 0x0230,
- WM_ENTERSIZEMOVE = 0x0231,
- WM_EXITSIZEMOVE = 0x0232,
- WM_DROPFILES = 0x0233,
- WM_MDIREFRESHMENU = 0x0234,
- WM_MOUSEHOVER = 0x02A1,
- WM_MOUSELEAVE = 0x02A3,
- WM_DPICHANGED = 0x02E0,
- WM_GETDPISCALEDSIZE = 0x02e1,
- WM_DPICHANGED_BEFOREPARENT = 0x02E2,
- WM_DPICHANGED_AFTERPARENT = 0x02E3,
- WM_CUT = 0x0300,
- WM_COPY = 0x0301,
- WM_PASTE = 0x0302,
- WM_CLEAR = 0x0303,
- WM_UNDO = 0x0304,
- WM_RENDERFORMAT = 0x0305,
- WM_RENDERALLFORMATS = 0x0306,
- WM_DESTROYCLIPBOARD = 0x0307,
- WM_DRAWCLIPBOARD = 0x0308,
- WM_PAINTCLIPBOARD = 0x0309,
- WM_VSCROLLCLIPBOARD = 0x030A,
- WM_SIZECLIPBOARD = 0x030B,
- WM_ASKCBFORMATNAME = 0x030C,
- WM_CHANGECBCHAIN = 0x030D,
- WM_HSCROLLCLIPBOARD = 0x030E,
- WM_QUERYNEWPALETTE = 0x030F,
- WM_PALETTEISCHANGING = 0x0310,
- WM_PALETTECHANGED = 0x0311,
- WM_HOTKEY = 0x0312,
- WM_PRINT = 0x0317,
- WM_PRINTCLIENT = 0x0318,
- WM_THEMECHANGED = 0x031A,
- WM_HANDHELDFIRST = 0x0358,
- WM_HANDHELDLAST = 0x035F,
- WM_AFXFIRST = 0x0360,
- WM_AFXLAST = 0x037F,
- WM_PENWINFIRST = 0x0380,
- WM_PENWINLAST = 0x038F,
- WM_APP = unchecked((int)0x8000),
- WM_USER = 0x0400,
- WM_REFLECT = NativeMethods.WM_USER + 0x1C00,
- WS_OVERLAPPED = 0x00000000,
- WS_POPUP = unchecked((int)0x80000000),
- WS_CHILD = 0x40000000,
- WS_MINIMIZE = 0x20000000,
- WS_VISIBLE = 0x10000000,
- WS_DISABLED = 0x08000000,
- WS_CLIPSIBLINGS = 0x04000000,
- WS_CLIPCHILDREN = 0x02000000,
- WS_MAXIMIZE = 0x01000000,
- WS_CAPTION = 0x00C00000,
- WS_BORDER = 0x00800000,
- WS_DLGFRAME = 0x00400000,
- WS_VSCROLL = 0x00200000,
- WS_HSCROLL = 0x00100000,
- WS_SYSMENU = 0x00080000,
- WS_THICKFRAME = 0x00040000,
- WS_TABSTOP = 0x00010000,
- WS_MINIMIZEBOX = 0x00020000,
- WS_MAXIMIZEBOX = 0x00010000,
- WS_EX_DLGMODALFRAME = 0x00000001,
- WS_EX_MDICHILD = 0x00000040,
- WS_EX_TOOLWINDOW = 0x00000080,
- WS_EX_CLIENTEDGE = 0x00000200,
- WS_EX_CONTEXTHELP = 0x00000400,
- WS_EX_RIGHT = 0x00001000,
- WS_EX_LEFT = 0x00000000,
- WS_EX_RTLREADING = 0x00002000,
- WS_EX_LEFTSCROLLBAR = 0x00004000,
- WS_EX_CONTROLPARENT = 0x00010000,
- WS_EX_STATICEDGE = 0x00020000,
- WS_EX_APPWINDOW = 0x00040000,
- WS_EX_LAYERED = 0x00080000,
- WS_EX_TOPMOST = 0x00000008,
- WS_EX_LAYOUTRTL = 0x00400000,
- WS_EX_NOINHERITLAYOUT = 0x00100000,
- WPF_SETMINPOSITION = 0x0001,
- WM_CHOOSEFONT_GETLOGFONT = (0x0400+1);
+ public const int WH_JOURNALPLAYBACK = 1;
+ public const int WH_GETMESSAGE = 3;
+ public const int WH_MOUSE = 7;
+ public const int WSF_VISIBLE = 0x0001;
+
+ public const int WA_INACTIVE = 0;
+ public const int WA_ACTIVE = 1;
+ public const int WA_CLICKACTIVE = 2;
+
+ public const int WS_OVERLAPPED = 0x00000000;
+ public const int WS_POPUP = unchecked((int)0x80000000);
+ public const int WS_CHILD = 0x40000000;
+ public const int WS_MINIMIZE = 0x20000000;
+ public const int WS_VISIBLE = 0x10000000;
+ public const int WS_DISABLED = 0x08000000;
+ public const int WS_CLIPSIBLINGS = 0x04000000;
+ public const int WS_CLIPCHILDREN = 0x02000000;
+ public const int WS_MAXIMIZE = 0x01000000;
+ public const int WS_CAPTION = 0x00C00000;
+ public const int WS_BORDER = 0x00800000;
+ public const int WS_DLGFRAME = 0x00400000;
+ public const int WS_VSCROLL = 0x00200000;
+ public const int WS_HSCROLL = 0x00100000;
+ public const int WS_SYSMENU = 0x00080000;
+ public const int WS_THICKFRAME = 0x00040000;
+ public const int WS_TABSTOP = 0x00010000;
+ public const int WS_MINIMIZEBOX = 0x00020000;
+ public const int WS_MAXIMIZEBOX = 0x00010000;
+ public const int WS_EX_DLGMODALFRAME = 0x00000001;
+ public const int WS_EX_MDICHILD = 0x00000040;
+ public const int WS_EX_TOOLWINDOW = 0x00000080;
+ public const int WS_EX_CLIENTEDGE = 0x00000200;
+ public const int WS_EX_CONTEXTHELP = 0x00000400;
+ public const int WS_EX_RIGHT = 0x00001000;
+ public const int WS_EX_LEFT = 0x00000000;
+ public const int WS_EX_RTLREADING = 0x00002000;
+ public const int WS_EX_LEFTSCROLLBAR = 0x00004000;
+ public const int WS_EX_CONTROLPARENT = 0x00010000;
+ public const int WS_EX_STATICEDGE = 0x00020000;
+ public const int WS_EX_APPWINDOW = 0x00040000;
+ public const int WS_EX_LAYERED = 0x00080000;
+ public const int WS_EX_TOPMOST = 0x00000008;
+ public const int WS_EX_LAYOUTRTL = 0x00400000;
+ public const int WS_EX_NOINHERITLAYOUT = 0x00100000;
+ public const int WPF_SETMINPOSITION = 0x0001;
+
+ public const int WHEEL_DELTA = 120;
// wParam of report message WM_IME_NOTIFY (public\sdk\imm.h)
public const int
@@ -2188,7 +1938,7 @@ int Exec(
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public class FONTDESC {
- public int cbSizeOfStruct = Marshal.SizeOf(typeof(FONTDESC));
+ public int cbSizeOfStruct = Marshal.SizeOf();
public string lpstrName;
public long cySize;
public short sWeight;
@@ -2203,7 +1953,7 @@ public class FONTDESC {
///
[StructLayout(LayoutKind.Sequential)]
public class PICTDESCbmp {
- internal int cbSizeOfStruct = Marshal.SizeOf(typeof(PICTDESCbmp));
+ internal int cbSizeOfStruct = Marshal.SizeOf();
internal int picType = Ole.PICTYPE_BITMAP;
internal IntPtr hbitmap = IntPtr.Zero;
internal IntPtr hpalette = IntPtr.Zero;
@@ -2220,7 +1970,7 @@ public PICTDESCbmp(System.Drawing.Bitmap bitmap) {
///
[StructLayout(LayoutKind.Sequential)]
public class PICTDESCicon {
- internal int cbSizeOfStruct = Marshal.SizeOf(typeof(PICTDESCicon));
+ internal int cbSizeOfStruct = Marshal.SizeOf();
internal int picType = Ole.PICTYPE_ICON;
internal IntPtr hicon = IntPtr.Zero;
internal int unused1 = 0;
@@ -2236,7 +1986,7 @@ public PICTDESCicon(System.Drawing.Icon icon) {
///
[StructLayout(LayoutKind.Sequential)]
public class PICTDESCemf {
- internal int cbSizeOfStruct = Marshal.SizeOf(typeof(PICTDESCemf));
+ internal int cbSizeOfStruct = Marshal.SizeOf();
internal int picType = Ole.PICTYPE_ENHMETAFILE;
internal IntPtr hemf = IntPtr.Zero;
internal int unused1 = 0;
@@ -2278,7 +2028,7 @@ internal class SYSTEMTIMEARRAY {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class HH_AKLINK {
- internal int cbStruct=Marshal.SizeOf(typeof(HH_AKLINK));
+ internal int cbStruct=Marshal.SizeOf();
internal bool fReserved = false;
internal string pszKeywords = null;
internal string pszUrl = null;
@@ -2290,7 +2040,7 @@ public class HH_AKLINK {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class HH_POPUP {
- internal int cbStruct=Marshal.SizeOf(typeof(HH_POPUP));
+ internal int cbStruct=Marshal.SizeOf();
internal IntPtr hinst = IntPtr.Zero;
internal int idString = 0;
internal IntPtr pszText;
@@ -2306,7 +2056,7 @@ public class HH_POPUP {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class HH_FTS_QUERY {
- internal int cbStruct = Marshal.SizeOf(typeof(HH_FTS_QUERY));
+ internal int cbStruct = Marshal.SizeOf();
internal bool fUniCodeStrings = false;
[MarshalAs(UnmanagedType.LPStr)]
internal string pszSearchQuery = null;
@@ -2320,7 +2070,7 @@ public class HH_FTS_QUERY {
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto, Pack=4)]
public class MONITORINFOEX {
- internal int cbSize = Marshal.SizeOf(typeof(MONITORINFOEX));
+ internal int cbSize = Marshal.SizeOf();
internal RECT rcMonitor = new RECT();
internal RECT rcWork = new RECT();
internal int dwFlags = 0;
@@ -2330,7 +2080,7 @@ public class MONITORINFOEX {
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto, Pack=4)]
public class MONITORINFO {
- internal int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
+ internal int cbSize = Marshal.SizeOf();
internal RECT rcMonitor = new RECT();
internal RECT rcWork = new RECT();
internal int dwFlags = 0;
@@ -2511,7 +2261,7 @@ public class INITCOMMONCONTROLSEX {
[StructLayout(LayoutKind.Sequential)]
public class IMAGELISTDRAWPARAMS {
- public int cbSize = Marshal.SizeOf(typeof(IMAGELISTDRAWPARAMS));
+ public int cbSize = Marshal.SizeOf();
public IntPtr himl = IntPtr.Zero;
public int i = 0;
public IntPtr hdcDst = IntPtr.Zero;
@@ -2545,7 +2295,7 @@ public class IMAGEINFO {
[StructLayout(LayoutKind.Sequential)]
public class TRACKMOUSEEVENT {
- public int cbSize = Marshal.SizeOf(typeof(TRACKMOUSEEVENT));
+ public int cbSize = Marshal.SizeOf();
public int dwFlags;
public IntPtr hwndTrack;
public int dwHoverTime = 100; // Never set this to field ZERO, or to HOVER_DEFAULT, ever!
@@ -2645,7 +2395,7 @@ public class WNDCLASS_I {
[StructLayout(LayoutKind.Sequential)]
public class NONCLIENTMETRICS {
- public int cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS));
+ public int cbSize = Marshal.SizeOf();
public int iBorderWidth = 0;
public int iScrollWidth = 0;
public int iScrollHeight = 0;
@@ -2703,7 +2453,7 @@ public struct PAINTSTRUCT {
[StructLayout(LayoutKind.Sequential)]
public class SCROLLINFO {
- public int cbSize = Marshal.SizeOf(typeof(SCROLLINFO));
+ public int cbSize = Marshal.SizeOf();
public int fMask;
public int nMin;
public int nMax;
@@ -2717,7 +2467,7 @@ public SCROLLINFO() {
[StructLayout(LayoutKind.Sequential)]
public class TPMPARAMS {
- public int cbSize = Marshal.SizeOf(typeof(TPMPARAMS));
+ public int cbSize = Marshal.SizeOf();
// rcExclude was a by-value RECT structure
public int rcExclude_left;
public int rcExclude_top;
@@ -3035,7 +2785,7 @@ public static PICTDESC CreateIconPICTDESC(IntPtr hicon) {
[StructLayout(LayoutKind.Sequential)]
public sealed class tagFONTDESC {
- public int cbSizeofstruct = Marshal.SizeOf(typeof(tagFONTDESC));
+ public int cbSizeofstruct = Marshal.SizeOf();
[MarshalAs(UnmanagedType.LPWStr)]
public string lpstrName;
@@ -3061,7 +2811,7 @@ public sealed class tagFONTDESC {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class CHOOSECOLOR {
- public int lStructSize = Marshal.SizeOf(typeof(CHOOSECOLOR)); //ndirect.DllLib.sizeOf(this);
+ public int lStructSize = Marshal.SizeOf(); //ndirect.DllLib.sizeOf(this);
public IntPtr hwndOwner;
public IntPtr hInstance;
public int rgbResult;
@@ -3181,7 +2931,7 @@ public struct TEXTMETRIC
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class NOTIFYICONDATA {
- public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
+ public int cbSize = Marshal.SizeOf();
public IntPtr hWnd;
public int uID;
public int uFlags;
@@ -3202,7 +2952,7 @@ public class NOTIFYICONDATA {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class MENUITEMINFO_T
{
- public int cbSize = Marshal.SizeOf(typeof(MENUITEMINFO_T));
+ public int cbSize = Marshal.SizeOf();
public int fMask;
public int fType;
public int fState;
@@ -3221,7 +2971,7 @@ public class MENUITEMINFO_T
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class MENUITEMINFO_T_RW
{
- public int cbSize = Marshal.SizeOf(typeof(MENUITEMINFO_T_RW));
+ public int cbSize = Marshal.SizeOf();
public int fMask = 0;
public int fType = 0;
public int fState = 0;
@@ -3254,7 +3004,7 @@ public MSAAMENUINFO(string text) {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class OPENFILENAME_I
{
- public int lStructSize = Marshal.SizeOf(typeof(OPENFILENAME_I)); //ndirect.DllLib.sizeOf(this);
+ public int lStructSize = Marshal.SizeOf(); //ndirect.DllLib.sizeOf(this);
public IntPtr hwndOwner;
public IntPtr hInstance;
public string lpstrFilter; // use embedded nulls to separate filters
@@ -3262,9 +3012,9 @@ public class OPENFILENAME_I
public int nMaxCustFilter = 0;
public int nFilterIndex;
public IntPtr lpstrFile;
- public int nMaxFile = NativeMethods.MAX_PATH;
+ public int nMaxFile = Interop.Kernel32.MAX_PATH;
public IntPtr lpstrFileTitle = IntPtr.Zero;
- public int nMaxFileTitle = NativeMethods.MAX_PATH;
+ public int nMaxFileTitle = Interop.Kernel32.MAX_PATH;
public string lpstrInitialDir;
public string lpstrTitle;
public int Flags;
@@ -3281,7 +3031,7 @@ public class OPENFILENAME_I
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class CHOOSEFONT {
- public int lStructSize = Marshal.SizeOf(typeof(CHOOSEFONT)); // ndirect.DllLib.sizeOf(this);
+ public int lStructSize = Marshal.SizeOf(); // ndirect.DllLib.sizeOf(this);
public IntPtr hwndOwner;
public IntPtr hDC;
public IntPtr lpLogFont;
@@ -3480,7 +3230,7 @@ public sealed class tagOleMenuGroupWidths {
[StructLayout(LayoutKind.Sequential)]
[Serializable]
public class MSOCRINFOSTRUCT {
- public int cbSize = Marshal.SizeOf(typeof(MSOCRINFOSTRUCT)); // size of MSOCRINFO structure in bytes.
+ public int cbSize = Marshal.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
@@ -3640,7 +3390,7 @@ public sealed class tagLOGPALETTE
public sealed class tagCONTROLINFO
{
[MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/]
- public int cb = Marshal.SizeOf(typeof(tagCONTROLINFO));
+ public int cb = Marshal.SizeOf();
public IntPtr hAccel;
@@ -3819,11 +3569,11 @@ public object ToObject() {
return (val != IntPtr.Zero);
case (int)tagVT.VT_VARIANT:
- VARIANT varStruct = (VARIANT)UnsafeNativeMethods.PtrToStructure(val, typeof(VARIANT));
+ VARIANT varStruct = Marshal.PtrToStructure(val);
return varStruct.ToObject();
+
case (int)tagVT.VT_CLSID:
- //Debug.Fail("PtrToStructure will not work with System.Guid...");
- Guid guid =(Guid)UnsafeNativeMethods.PtrToStructure(val, typeof(Guid));
+ Guid guid = Marshal.PtrToStructure(val);
return guid;
case (int)tagVT.VT_FILETIME:
@@ -3834,9 +3584,6 @@ public object ToObject() {
throw new ArgumentException(string.Format(SR.COM2UnhandledVT, "VT_USERDEFINED"));
case (int)tagVT.VT_ARRAY:
- //gSAFEARRAY sa = (tagSAFEARRAY)Marshal.PtrToStructure(val), typeof(tagSAFEARRAY));
- //return GetArrayFromSafeArray(sa);
-
case (int)tagVT.VT_VOID:
case (int)tagVT.VT_PTR:
case (int)tagVT.VT_SAFEARRAY:
@@ -3853,7 +3600,6 @@ public object ToObject() {
case (int)tagVT.VT_BSTR_BLOB:
case (int)tagVT.VT_VECTOR:
case (int)tagVT.VT_BYREF:
- //case (int)tagVT.VT_RESERVED:
default:
int iVt = this.vt;
throw new ArgumentException(string.Format(SR.COM2UnhandledVT, iVt.ToString(CultureInfo.InvariantCulture)));
@@ -3869,7 +3615,7 @@ private static IntPtr GetRefInt(IntPtr value) {
public sealed class tagLICINFO
{
[MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cb)*/]
- public int cbLicInfo = Marshal.SizeOf(typeof(tagLICINFO));
+ public int cbLicInfo = Marshal.SizeOf();
public int fRuntimeAvailable = 0;
public int fLicVerified = 0;
@@ -4065,7 +3811,7 @@ One can query the reg info of the active (or tracking) component at any
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class TOOLINFO_T
{
- public int cbSize = Marshal.SizeOf(typeof(TOOLINFO_T));
+ public int cbSize = Marshal.SizeOf();
public int uFlags;
public IntPtr hwnd;
public IntPtr uId;
@@ -4078,7 +3824,7 @@ public class TOOLINFO_T
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class TOOLINFO_TOOLTIP
{
- public int cbSize = Marshal.SizeOf(typeof(TOOLINFO_TOOLTIP));
+ public int cbSize = Marshal.SizeOf();
public int uFlags;
public IntPtr hwnd;
public IntPtr uId;
@@ -4341,7 +4087,7 @@ public class MEASUREITEMSTRUCT {
[StructLayout(LayoutKind.Sequential)]
public class HELPINFO {
- public int cbSize = Marshal.SizeOf(typeof(HELPINFO));
+ public int cbSize = Marshal.SizeOf();
public int iContextType = 0;
public int iCtrlId = 0;
public IntPtr hItemHandle = IntPtr.Zero;
@@ -4504,7 +4250,7 @@ public struct NMCUSTOMDRAW {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class MCHITTESTINFO {
- public int cbSize = Marshal.SizeOf(typeof(MCHITTESTINFO));
+ public int cbSize = Marshal.SizeOf();
public int pt_x = 0;
public int pt_y = 0;
public int uHit = 0;
@@ -4695,7 +4441,7 @@ public class LVCOLUMN {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public class LVGROUP {
- public uint cbSize = (uint)Marshal.SizeOf(typeof(LVGROUP));
+ public uint cbSize = (uint)Marshal.SizeOf();
public uint mask;
public IntPtr pszHeader;
public int cchHeader;
@@ -4713,7 +4459,7 @@ public override string ToString() {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class LVINSERTMARK {
- public uint cbSize = (uint)Marshal.SizeOf(typeof(LVINSERTMARK));
+ public uint cbSize = (uint)Marshal.SizeOf();
public int dwFlags;
public int iItem;
public int dwReserved = 0;
@@ -4721,7 +4467,7 @@ public class LVINSERTMARK {
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class LVTILEVIEWINFO {
- public uint cbSize = (uint)Marshal.SizeOf(typeof(LVTILEVIEWINFO));
+ public uint cbSize = (uint)Marshal.SizeOf();
public int dwMask;
public int dwFlags;
public SIZE sizeTile;
@@ -4793,7 +4539,8 @@ public class NMHEADER {
public int iButton = 0;
public IntPtr pItem = IntPtr.Zero; // HDITEM*
}
-
+
+ [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
[StructLayout(LayoutKind.Sequential)]
public class MOUSEHOOKSTRUCT {
// pt was a by-value POINT structure
@@ -4867,7 +4614,7 @@ public class CHARRANGE
[StructLayout(LayoutKind.Sequential, Pack=4)]
public class CHARFORMATW
{
- public int cbSize = Marshal.SizeOf(typeof(CHARFORMATW));
+ public int cbSize = Marshal.SizeOf();
public int dwMask;
public int dwEffects;
public int yHeight;
@@ -4882,7 +4629,7 @@ public class CHARFORMATW
[StructLayout(LayoutKind.Sequential, Pack=4)]
public class CHARFORMATA
{
- public int cbSize = Marshal.SizeOf(typeof(CHARFORMATA));
+ public int cbSize = Marshal.SizeOf();
public int dwMask;
public int dwEffects;
public int yHeight;
@@ -4897,7 +4644,7 @@ public class CHARFORMATA
[StructLayout(LayoutKind.Sequential, Pack=4)]
public class CHARFORMAT2A
{
- public int cbSize = Marshal.SizeOf(typeof(CHARFORMAT2A));
+ public int cbSize = Marshal.SizeOf();
public int dwMask = 0;
public int dwEffects = 0;
public int yHeight = 0;
@@ -4943,7 +4690,7 @@ public class SELCHANGE {
[StructLayout(LayoutKind.Sequential)]
public class PARAFORMAT
{
- public int cbSize = Marshal.SizeOf(typeof(PARAFORMAT));
+ public int cbSize = Marshal.SizeOf();
public int dwMask;
public short wNumbering;
public short wReserved = 0;
@@ -5003,7 +4750,7 @@ public struct RGNDATAHEADER
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public class OCPFIPARAMS
{
- public int cbSizeOfStruct = Marshal.SizeOf(typeof(OCPFIPARAMS));
+ public int cbSizeOfStruct = Marshal.SizeOf();
public IntPtr hwndOwner;
public int x = 0;
public int y = 0;
@@ -5020,7 +4767,7 @@ public class OCPFIPARAMS
public class DOCHOSTUIINFO
{
[MarshalAs(UnmanagedType.U4)]
- public int cbSize = Marshal.SizeOf(typeof(DOCHOSTUIINFO));
+ public int cbSize = Marshal.SizeOf();
[MarshalAs(UnmanagedType.I4)]
public int dwFlags;
[MarshalAs(UnmanagedType.I4)]
@@ -5604,7 +5351,7 @@ public struct PALETTEENTRY {
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFO_FLAT {
- public int bmiHeader_biSize;// = Marshal.SizeOf(typeof(BITMAPINFOHEADER));
+ public int bmiHeader_biSize;// = Marshal.SizeOf();
public int bmiHeader_biWidth;
public int bmiHeader_biHeight;
public short bmiHeader_biPlanes;
@@ -5693,6 +5440,8 @@ public enum MONTCALENDAR_VIEW_MODE
public const int PS_GEOMETRIC = 0x00010000;
public const int PS_ENDCAP_SQUARE = 0x00000100;
+ public const int WS_EX_TRANSPARENT = 0x00000020;
+
public const int NULL_BRUSH = 5;
public const int MM_HIMETRIC = 3;
@@ -6009,6 +5758,76 @@ public UiaRect(System.Drawing.Rectangle r) {
// This value requires KB2533623 to be installed.
// Windows Server 2003 and Windows XP: This value is not supported.
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] ref RECT rect, int cPoints);
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] POINT pt, int cPoints);
+
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr WindowFromPoint(int x, int y);
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public extern static IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, [In, Out] TV_HITTESTINFO lParam);
+
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern short GetKeyState(int keyCode);
+ [DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "DeleteObject", CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ private static extern bool IntDeleteObject(IntPtr hObject);
+ public static bool DeleteObject(IntPtr hObject)
+ {
+ System.Internal.HandleCollector.Remove(hObject, CommonHandles.GDI);
+ return IntDeleteObject(hObject);
+ }
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern bool GetUpdateRect(IntPtr hwnd, [In, Out] ref RECT rc, bool fErase);
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern bool GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase);
+
+ [DllImport(ExternDll.Gdi32, ExactSpelling = true, EntryPoint = "CreateRectRgn", CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.Process)]
+ private static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
+ [ResourceExposure(ResourceScope.Process)]
+ [ResourceConsumption(ResourceScope.Process)]
+ public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2)
+ {
+ return System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), CommonHandles.GDI);
+ }
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr GetCursor();
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern bool GetCursorPos([In, Out] POINT pt);
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);
}
}
diff --git a/src/Common/src/SafeNativeMethods.cs b/src/Common/src/SafeNativeMethods.cs
index a1e3abda3eb..58f709262a5 100644
--- a/src/Common/src/SafeNativeMethods.cs
+++ b/src/Common/src/SafeNativeMethods.cs
@@ -62,20 +62,20 @@ public static IntPtr CreateCompatibleBitmap(HandleRef hDC, int width, int height
return System.Internal.HandleCollector.Add(IntCreateCompatibleBitmap(hDC, width, height), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool GetScrollInfo(HandleRef hWnd, int fnBar, [In, Out] NativeMethods.SCROLLINFO si);
- [DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool IsAccelerator(HandleRef hAccel, int cAccelEntries, [In] ref NativeMethods.MSG lpMsg, short[] lpwCmd);
- [DllImport(ExternDll.Comdlg32, SetLastError=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Comdlg32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern bool ChooseFont([In, Out] NativeMethods.CHOOSEFONT cf);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetBitmapBits(HandleRef hbmp, int cbBuffer, byte[] lpvBits);
- [DllImport(ExternDll.Comdlg32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Comdlg32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int CommDlgExtendedError();
[DllImport(ExternDll.Oleaut32, ExactSpelling=true, CharSet=CharSet.Unicode)]
@@ -130,33 +130,33 @@ public static extern bool Rectangle(
public static extern bool PatBlt(HandleRef hdc, int left, int top, int width, int height, int rop);
- [DllImport(ExternDll.Kernel32, EntryPoint="GetThreadLocale", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, EntryPoint="GetThreadLocale", CharSet=CharSet.Auto)]
public static extern int GetThreadLCID();
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetMessagePos();
- [DllImport(ExternDll.User32, SetLastError=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern int RegisterClipboardFormat(string format);
- [DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern int GetClipboardFormatName(int format, StringBuilder lpString, int cchMax);
- [DllImport(ExternDll.Comdlg32, SetLastError=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Comdlg32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern bool ChooseColor([In, Out] NativeMethods.CHOOSECOLOR cc);
- [DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern int RegisterWindowMessage(string msg);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="DeleteObject", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="DeleteObject", CharSet=CharSet.Auto)]
public static extern bool ExternalDeleteObject(HandleRef hObject);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="DeleteObject", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="DeleteObject", CharSet=CharSet.Auto)]
internal static extern bool IntDeleteObject(HandleRef hObject);
public static bool DeleteObject(HandleRef hObject) {
@@ -168,7 +168,7 @@ public static bool DeleteObject(HandleRef hObject) {
public static extern SafeNativeMethods.IFontDisp OleCreateIFontDispIndirect(NativeMethods.FONTDESC fd, ref Guid iid);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateSolidBrush", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateSolidBrush", CharSet=CharSet.Auto)]
private static extern IntPtr IntCreateSolidBrush(int crColor);
@@ -176,11 +176,11 @@ public static bool DeleteObject(HandleRef hObject) {
public static IntPtr CreateSolidBrush(int crColor) {
return System.Internal.HandleCollector.Add(IntCreateSolidBrush(crColor), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool SetWindowExtEx(HandleRef hDC, int x, int y, [In, Out] NativeMethods.SIZE size);
- [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto)]
public static extern int FormatMessage(int dwFlags, HandleRef lpSource, int dwMessageId,
int dwLanguageId, StringBuilder lpBuffer, int nSize, HandleRef arguments);
@@ -308,7 +308,7 @@ public static IntPtr ImageList_Read(UnsafeNativeMethods.IStream pstm) {
[DllImport(ExternDll.Comctl32)]
public static extern int ImageList_WriteEx(HandleRef himl, int dwFlags, UnsafeNativeMethods.IStream pstm);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool TrackPopupMenuEx(HandleRef hmenu, int fuFlags, int x, int y, HandleRef hwnd, NativeMethods.TPMPARAMS tpm);
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
@@ -341,20 +341,20 @@ public static IntPtr ImageList_Read(UnsafeNativeMethods.IStream pstm) {
[DllImport(ExternDll.User32, ExactSpelling = true)]
public static extern bool EnumDisplayMonitors(HandleRef hdc, NativeMethods.COMRECT rcClip, NativeMethods.MonitorEnumProc lpfnEnum, IntPtr dwData);
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateHalftonePalette", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateHalftonePalette", CharSet = CharSet.Auto)]
private static extern IntPtr /*HPALETTE*/ IntCreateHalftonePalette(HandleRef hdc);
public static IntPtr /*HPALETTE*/ CreateHalftonePalette(HandleRef hdc) {
return System.Internal.HandleCollector.Add(IntCreateHalftonePalette(hdc), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetPaletteEntries(HandleRef hpal, int iStartIndex, int nEntries, int[] lppe);
[DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
public static extern int GetTextMetricsW(HandleRef hDC, ref NativeMethods.TEXTMETRIC lptm);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateDIBSection", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateDIBSection", CharSet=CharSet.Auto)]
private static extern IntPtr IntCreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage, byte[] ppvBits, IntPtr hSection, int dwOffset);
@@ -363,7 +363,7 @@ public static IntPtr CreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage,
return System.Internal.HandleCollector.Add(IntCreateDIBSection(hdc, pbmi, iUsage, ppvBits, hSection, dwOffset), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBitmap", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBitmap", CharSet=CharSet.Auto)]
private static extern IntPtr /*HBITMAP*/ IntCreateBitmap(int nWidth, int nHeight, int nPlanes, int nBitsPerPixel, IntPtr lpvBits);
@@ -372,7 +372,7 @@ public static IntPtr CreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage,
return System.Internal.HandleCollector.Add(IntCreateBitmap(nWidth, nHeight, nPlanes, nBitsPerPixel, lpvBits), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBitmap", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBitmap", CharSet=CharSet.Auto)]
private static extern IntPtr /*HBITMAP*/ IntCreateBitmapShort(int nWidth, int nHeight, int nPlanes, int nBitsPerPixel, short[] lpvBits);
@@ -381,7 +381,7 @@ public static IntPtr CreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage,
return System.Internal.HandleCollector.Add(IntCreateBitmapShort(nWidth, nHeight, nPlanes, nBitsPerPixel, lpvBits), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBitmap", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBitmap", CharSet=CharSet.Auto)]
private static extern IntPtr /*HBITMAP*/ IntCreateBitmapByte(int nWidth, int nHeight, int nPlanes, int nBitsPerPixel, byte[] lpvBits);
@@ -389,7 +389,7 @@ public static IntPtr CreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage,
public static IntPtr /*HBITMAP*/ CreateBitmap(int nWidth, int nHeight, int nPlanes, int nBitsPerPixel, byte[] lpvBits) {
return System.Internal.HandleCollector.Add(IntCreateBitmapByte(nWidth, nHeight, nPlanes, nBitsPerPixel, lpvBits), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreatePatternBrush", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreatePatternBrush", CharSet=CharSet.Auto)]
private static extern IntPtr /*HBRUSH*/ IntCreatePatternBrush(HandleRef hbmp);
@@ -397,7 +397,7 @@ public static IntPtr CreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage,
public static IntPtr /*HBRUSH*/ CreatePatternBrush(HandleRef hbmp) {
return System.Internal.HandleCollector.Add(IntCreatePatternBrush(hbmp), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBrushIndirect", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateBrushIndirect", CharSet=CharSet.Auto)]
private static extern IntPtr IntCreateBrushIndirect(NativeMethods.LOGBRUSH lb);
@@ -405,7 +405,7 @@ public static IntPtr CreateDIBSection(HandleRef hdc, HandleRef pbmi, int iUsage,
public static IntPtr CreateBrushIndirect(NativeMethods.LOGBRUSH lb) {
return System.Internal.HandleCollector.Add(IntCreateBrushIndirect(lb), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreatePen", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreatePen", CharSet=CharSet.Auto)]
private static extern IntPtr IntCreatePen(int nStyle, int nWidth, int crColor);
@@ -415,26 +415,26 @@ public static IntPtr CreatePen(int nStyle, int nWidth, int crColor) {
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool SetViewportExtEx(HandleRef hDC, int x, int y, NativeMethods.SIZE size);
- [DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern IntPtr LoadCursor(HandleRef hInst, int iconId);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public extern static bool GetClipCursor([In, Out] ref NativeMethods.RECT lpRect);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetCursor();
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool GetIconInfo(HandleRef hIcon, [In, Out] NativeMethods.ICONINFO info);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int IntersectClipRect(HandleRef hDC, int x1, int y1, int x2, int y2);
- [DllImport(ExternDll.User32, ExactSpelling=true, EntryPoint="CopyImage", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, EntryPoint="CopyImage", CharSet=CharSet.Auto)]
private static extern IntPtr IntCopyImage(HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
public static IntPtr CopyImage(HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags) {
@@ -445,7 +445,7 @@ public static IntPtr CopyImageAsCursor(HandleRef hImage, int uType, int cxDesire
}
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool AdjustWindowRectEx(ref NativeMethods.RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
@@ -454,28 +454,33 @@ public static IntPtr CopyImageAsCursor(HandleRef hImage, int uType, int cxDesire
public static extern bool AdjustWindowRectExForDpi(ref NativeMethods.RECT lpRect, int dwStyle, bool bMenu, int dwExStyle, uint dpi);
- [DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int DoDragDrop(IComDataObject dataObject, UnsafeNativeMethods.IOleDropSource dropSource, int allowedEffects, int[] finalEffect);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetSysColorBrush(int nIndex);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool EnableWindow(HandleRef hWnd, bool enable);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool GetClientRect(HandleRef hWnd, [In, Out] ref NativeMethods.RECT rect);
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetDoubleClickTime();
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetUpdateRgn(HandleRef hwnd, HandleRef hrgn, bool fErase);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool ValidateRect(HandleRef hWnd, [In, Out] ref NativeMethods.RECT rect);
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern bool ValidateRect(IntPtr hwnd, IntPtr prect);
+
//
// WARNING: Don't uncomment this code unless you absolutelly need it. Use instead Marshal.GetLastWin32Error
// and mark your PInvoke [DllImport(..., SetLastError=true)]
@@ -486,36 +491,36 @@ public static IntPtr CopyImageAsCursor(HandleRef hImage, int uType, int cxDesire
// definition for GetLastError and calling it. The common language runtime can make internal calls to APIs that
// overwrite the operating system maintained GetLastError.
//
- //[DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ //[DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
//public extern static int GetLastError();
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int FillRect(HandleRef hdc, [In] ref NativeMethods.RECT rect, HandleRef hbrush);
- [DllImport(ExternDll.Gdi32,ExactSpelling=true,CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32,ExactSpelling=true,CharSet=CharSet.Auto)]
public static extern int /*COLORREF*/ GetTextColor(HandleRef hDC);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int GetBkColor(HandleRef hDC);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int /*COLORREF*/ SetTextColor(HandleRef hDC, int crColor);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int SetBkColor(HandleRef hDC, int clr);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr /* HPALETTE */SelectPalette(HandleRef hdc, HandleRef hpal, int bForceBackground);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool SetViewportOrgEx(HandleRef hDC, int x, int y, [In, Out] NativeMethods.POINT point);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateRectRgn", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, EntryPoint="CreateRectRgn", CharSet=CharSet.Auto)]
private static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
@@ -523,60 +528,64 @@ public static IntPtr CopyImageAsCursor(HandleRef hImage, int uType, int cxDesire
public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2) {
return System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), NativeMethods.CommonHandles.GDI);
}
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int CombineRgn(HandleRef hRgn, HandleRef hRgn1, HandleRef hRgn2, int nCombineMode);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int RealizePalette(HandleRef hDC);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool LPtoDP(HandleRef hDC, [In, Out] ref NativeMethods.RECT lpRect, int nCount);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool SetWindowOrgEx(HandleRef hDC, int x, int y, [In, Out] NativeMethods.POINT point);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool GetViewportOrgEx(HandleRef hDC, [In, Out] NativeMethods.POINT point);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int SetMapMode(HandleRef hDC, int nMapMode);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool IsWindowEnabled(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool IsWindowVisible(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool ReleaseCapture();
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetCurrentThreadId();
- [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
+ [DllImport(ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool EnumWindows(EnumThreadWindowsCallback callback, IntPtr extraData);
internal delegate bool EnumThreadWindowsCallback(IntPtr hWnd, IntPtr lParam);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int GetWindowThreadProcessId(HandleRef hWnd, out int lpdwProcessId);
[return:MarshalAs(UnmanagedType.Bool)]
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool GetExitCodeThread(HandleRef hWnd, out int lpdwExitCode);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool ShowWindow(HandleRef hWnd, int nCmdShow);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter,
int x, int y, int cx, int cy, int flags);
- [DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
+ int x, int y, int cx, int cy, int flags);
+
+ [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern int GetWindowTextLength(HandleRef hWnd);
// this is a wrapper that comctl exposes for the NT function since it doesn't exist natively on 95.
@@ -587,114 +596,121 @@ public static bool TrackMouseEvent(NativeMethods.TRACKMOUSEEVENT tme) {
// only on NT - not on 95 - comctl32 has a wrapper for 95 and NT.
return _TrackMouseEvent(tme);
}
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool RedrawWindow(HandleRef hwnd, ref NativeMethods.RECT rcUpdate, HandleRef hrgnUpdate, int flags);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool RedrawWindow(HandleRef hwnd, NativeMethods.COMRECT rcUpdate, HandleRef hrgnUpdate, int flags);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern bool RedrawWindow(IntPtr hwnd, NativeMethods.COMRECT rcUpdate, IntPtr hrgnUpdate, int flags);
+
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool InvalidateRect(HandleRef hWnd, ref NativeMethods.RECT rect, bool erase);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool InvalidateRect(HandleRef hWnd, NativeMethods.COMRECT rect, bool erase);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool InvalidateRgn(HandleRef hWnd, HandleRef hrgn, bool erase);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool UpdateWindow(HandleRef hWnd);
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetCurrentProcessId();
- [DllImport(ExternDll.User32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int ScrollWindowEx(HandleRef hWnd, int nXAmount, int nYAmount, NativeMethods.COMRECT rectScrollRegion, ref NativeMethods.RECT rectClip, HandleRef hrgnUpdate, ref NativeMethods.RECT prcUpdate, int flags);
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetThreadLocale();
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool MessageBeep(int type);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool DrawMenuBar(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public extern static bool IsChild(HandleRef parent, HandleRef child);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr SetTimer(HandleRef hWnd, int nIDEvent, int uElapse, IntPtr lpTimerFunc);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool KillTimer(HandleRef hwnd, int idEvent);
- [DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto),
+ [DllImport(ExternDll.User32, CharSet=CharSet.Auto),
SuppressMessage("Microsoft.Usage", "CA2205:UseManagedEquivalentsOfWin32Api")]
public static extern int MessageBox(HandleRef hWnd, string text, string caption, int type);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr SelectObject(HandleRef hDC, HandleRef hObject);
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetTickCount();
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool ScrollWindow(HandleRef hWnd, int nXAmount, int nYAmount, ref NativeMethods.RECT rectScrollRegion, ref NativeMethods.RECT rectClip);
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetCurrentProcess();
- [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetCurrentThread();
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = CharSet.Auto)]
public extern static bool SetThreadLocale(int Locale);
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern bool IsWindowUnicode(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool DrawEdge(HandleRef hDC, ref NativeMethods.RECT rect, int edge, int flags);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool DrawFrameControl(HandleRef hDC, ref NativeMethods.RECT rect, int type, int state);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetClipRgn(HandleRef hDC, HandleRef hRgn);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetRgnBox(HandleRef hRegion, ref NativeMethods.RECT clipRect);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int SelectClipRgn(HandleRef hDC, HandleRef hRgn);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int SetROP2(HandleRef hDC, int nDrawMode);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool DrawIcon(HandleRef hDC, int x, int y, HandleRef hIcon);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool DrawIconEx(HandleRef hDC, int x, int y, HandleRef hIcon, int width, int height, int iStepIfAniCursor, HandleRef hBrushFlickerFree, int diFlags);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int SetBkMode(HandleRef hDC, int nBkMode);
- [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, SetLastError=true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool BitBlt(HandleRef hDC, int x, int y, int nWidth, int nHeight,
HandleRef hSrcDC, int xSrc, int ySrc, int dwRop);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.Gdi32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern bool BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
+
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool ShowCaret(HandleRef hWnd);
- [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
+ [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern bool HideCaret(HandleRef hWnd);
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
@@ -775,11 +791,22 @@ public static extern bool BitBlt(HandleRef hDC, int x, int y, int nWidth, int nH
[DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
public static extern int GetThemeString(HandleRef hTheme, int iPartId, int iStateId, int iPropId, StringBuilder pszBuff, int cchMaxBuffChars);
+
[DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
-
public static extern int GetThemeDocumentationProperty([MarshalAs(UnmanagedType.LPWStr)] string pszThemeName, [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyName, StringBuilder pszValueBuff, int cchMaxValChars);
- [DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
-
+
+ public static class VisualStyleDocProperty
+ {
+ public const string DisplayName = "DisplayName";
+ public const string Company = "Company";
+ public const string Author = "Author";
+ public const string Copyright = "Copyright";
+ public const string Url = "Url";
+ public const string Version = "Version";
+ public const string Description = "Description";
+ }
+
+ [DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
public static extern int GetThemeTextExtent(HandleRef hTheme, HandleRef hdc, int iPartId, int iStateId, [MarshalAs(UnmanagedType.LPWStr)] string pszText, int iCharCount, int dwTextFlags, [In] NativeMethods.COMRECT pBoundingRect, [Out] NativeMethods.COMRECT pExtentRect);
[DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
@@ -790,13 +817,19 @@ public static extern bool BitBlt(HandleRef hDC, int x, int y, int nWidth, int nH
[DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
public static extern bool IsThemeBackgroundPartiallyTransparent(HandleRef hTheme, int iPartId, int iStateId);
+
[DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
-
public static extern bool GetThemeSysBool(HandleRef hTheme, int iBoolId);
- [DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
-
+
+ [DllImport(ExternDll.Uxtheme, CharSet=CharSet.Auto)]
public static extern int GetThemeSysInt(HandleRef hTheme, int iIntId, ref int piValue);
+ public static class VisualStyleSystemProperty
+ {
+ public const int SupportsFlatMenus = 1001;
+ public const int MinimumColorDepth = 1301;
+ }
+
[DllImportAttribute(ExternDll.User32)]
public static extern IntPtr OpenInputDesktop(int dwFlags, [MarshalAs(UnmanagedType.Bool)] bool fInherit, int dwDesiredAccess);
@@ -853,6 +886,12 @@ public static extern bool BitBlt(HandleRef hDC, int x, int y, int nWidth, int nH
[DllImport(ExternDll.Kernel32, SetLastError = true)]
public static extern IntPtr OpenProcess(uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
+ [DllImport(ExternDll.Gdi32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern bool RoundRect(HandleRef hDC, int left, int top, int right, int bottom, int width, int height);
+
+ [DllImport(ExternDll.Uxtheme, CharSet = CharSet.Auto)]
+ public extern static int SetWindowTheme(IntPtr hWnd, string subAppName, string subIdList);
+
internal const int PROCESS_QUERY_INFORMATION = 0x0400;
internal const int PROCESS_VM_READ = 0x0010;
@@ -880,7 +919,7 @@ public static int ColorToCOLORREF(Color color) {
return (int)color.R | ((int)color.G << 8) | ((int)color.B << 16);
}
- [ComImport(), Guid("BEF6E003-A874-101A-8BBA-00AA00300CAB"), System.Runtime.InteropServices.InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch)]
+ [ComImport(), Guid("BEF6E003-A874-101A-8BBA-00AA00300CAB"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IFontDisp {
string Name {get; set;}
diff --git a/src/Common/src/UnsafeNativeMethods.cs b/src/Common/src/UnsafeNativeMethods.cs
index 47d82801884..a0e9df13134 100644
--- a/src/Common/src/UnsafeNativeMethods.cs
+++ b/src/Common/src/UnsafeNativeMethods.cs
@@ -92,8 +92,8 @@ internal static class UnsafeNativeMethods {
public static extern int ReadClassStg(HandleRef pStg, [In, Out] ref Guid pclsid);
- [DllImport(ExternDll.Ole32, SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = true)]
- internal extern static void CoTaskMemFree(IntPtr pv);
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern int GetMessageTime();
[DllImport(ExternDll.User32)]
@@ -194,19 +194,9 @@ internal static bool IsVista
public static extern int OleSaveToStream(IPersistStream pPersistStream, IStream pStream);
- [DllImport(ExternDll.Ole32)]
-
- public static extern int CoGetMalloc(int dwReserved, out IMalloc pMalloc);
-
- /* Commenting this out until someone actually needs to use it again...
- [DllImport(ExternDll.Ole32)]
- public static extern int OleSetMenuDescriptor(IntPtr hOleMenu, IntPtr hWndFrame, IntPtr hWndActiveObject, IOleInPlaceFrame frame, IOleInPlaceActiveObject activeObject);
- */
-
- /* Commenting this out until someone actually needs to use it again...
- [DllImport(ExternDll.Kernel32)]
- public static extern bool IsBadReadPtr(HandleRef ptr, int size);
- */
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [ResourceExposure(ResourceScope.Process)]
+ public static extern int GetWindowThreadProcessId(HandleRef hWnd, out int lpdwProcessId);
[DllImport(ExternDll.Comdlg32, SetLastError=true, CharSet=CharSet.Auto)]
@@ -288,7 +278,7 @@ public static int DragQueryFileLongPath(HandleRef hDrop, int iFile, StringBuilde
// passing null for buffer will return actual number of charectors in the file name.
// So, one extra call would be suffice to avoid while loop in case of long path.
int capacity = DragQueryFile(hDrop, iFile, null, 0);
- if (capacity < NativeMethods.MAX_UNICODESTRING_LEN)
+ if (capacity < Interop.Kernel32.MAX_UNICODESTRING_LEN)
{
lpszFile.EnsureCapacity(capacity);
resultValue = DragQueryFile(hDrop, iFile, lpszFile, capacity);
@@ -435,17 +425,17 @@ public static IntPtr DuplicateHandle(HandleRef processSource, HandleRef handleSo
public static extern int GetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
public static StringBuilder GetModuleFileNameLongPath(HandleRef hModule)
{
- StringBuilder buffer = new StringBuilder(NativeMethods.MAX_PATH);
+ StringBuilder buffer = new StringBuilder(Interop.Kernel32.MAX_PATH);
int noOfTimes = 1;
int length = 0;
// Iterating by allocating chunk of memory each time we find the length is not sufficient.
// Performance should not be an issue for current MAX_PATH length due to this change.
while (((length = GetModuleFileName(hModule, buffer, buffer.Capacity)) == buffer.Capacity)
&& Marshal.GetLastWin32Error() == NativeMethods.ERROR_INSUFFICIENT_BUFFER
- && buffer.Capacity < NativeMethods.MAX_UNICODESTRING_LEN)
+ && buffer.Capacity < Interop.Kernel32.MAX_UNICODESTRING_LEN)
{
noOfTimes += 2; // Increasing buffer size by 520 in each iteration.
- int capacity = noOfTimes * NativeMethods.MAX_PATH < NativeMethods.MAX_UNICODESTRING_LEN ? noOfTimes * NativeMethods.MAX_PATH : NativeMethods.MAX_UNICODESTRING_LEN;
+ int capacity = noOfTimes * Interop.Kernel32.MAX_PATH < Interop.Kernel32.MAX_UNICODESTRING_LEN ? noOfTimes * Interop.Kernel32.MAX_PATH : Interop.Kernel32.MAX_UNICODESTRING_LEN;
buffer.EnsureCapacity(capacity);
}
buffer.Length = length;
@@ -581,21 +571,21 @@ public static IntPtr GetDCEx(HandleRef hWnd, HandleRef hrgnClip, int flags) {
public static extern int GetObject(HandleRef hObject, int nSize, [In, Out] NativeMethods.LOGPEN lp);
public static int GetObject(HandleRef hObject, NativeMethods.LOGPEN lp) {
- return GetObject(hObject, Marshal.SizeOf(typeof(NativeMethods.LOGPEN)), lp);
+ return GetObject(hObject, Marshal.SizeOf(), lp);
}
[DllImport(ExternDll.Gdi32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern int GetObject(HandleRef hObject, int nSize, [In, Out] NativeMethods.LOGBRUSH lb);
public static int GetObject(HandleRef hObject, NativeMethods.LOGBRUSH lb) {
- return GetObject(hObject, Marshal.SizeOf(typeof(NativeMethods.LOGBRUSH)), lb);
+ return GetObject(hObject, Marshal.SizeOf(), lb);
}
[DllImport(ExternDll.Gdi32, SetLastError=true, CharSet=CharSet.Auto)]
public static extern int GetObject(HandleRef hObject, int nSize, [In, Out] NativeMethods.LOGFONT lf);
public static int GetObject(HandleRef hObject, NativeMethods.LOGFONT lp) {
- return GetObject(hObject, Marshal.SizeOf(typeof(NativeMethods.LOGFONT)), lp);
+ return GetObject(hObject, Marshal.SizeOf(), lp);
}
//HPALETTE
@@ -828,7 +818,12 @@ public static int SetWindowRgn(HandleRef hwnd, HandleRef hrgn, bool fRedraw) {
[DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, NativeMethods.LVBKIMAGE lParam);
-
+
+ [DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable")]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr SendMessage(IntPtr hwnd, int msg, bool wparam, int lparam);
+
[DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern int SendMessage(HandleRef hWnd, int msg, int wParam, ref NativeMethods.LVHITTESTINFO lParam);
@@ -993,7 +988,11 @@ public static int SetWindowRgn(HandleRef hwnd, HandleRef hrgn, bool fRedraw) {
public static extern IntPtr GetWindow(HandleRef hWnd, int uCmd);
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
-
+
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);
+ [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+
public static extern IntPtr GetDlgItem(HandleRef hWnd, int nIDDlgItem);
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto)]
@@ -1008,17 +1007,7 @@ public static int SetWindowRgn(HandleRef hwnd, HandleRef hrgn, bool fRedraw) {
public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hWnd, int msg,
IntPtr wParam, IntPtr lParam);
-
-/*
- [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
- public static extern IntPtr GetProp(HandleRef hWnd, int atom);
- [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
- public static extern IntPtr GetProp(HandleRef hWnd, string name);
- [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
- public static extern IntPtr RemoveProp(HandleRef hWnd, short atom);
- [DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
- public static extern IntPtr RemoveProp(HandleRef hWnd, string propName);
- */
+
[DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern short GlobalDeleteAtom(short atom);
@@ -1033,10 +1022,7 @@ public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hWnd, int msg,
[DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern bool GetClassInfo(HandleRef hInst, string lpszClass, IntPtr h);
-/*
- [DllImport(ExternDll.Shell32, CharSet=CharSet.Auto)]
- public static extern int SHGetFolderPath(HandleRef hwndOwner, int nFolder, HandleRef hToken, int dwFlags, StringBuilder lpszPath);
-*/
+
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int GetSystemMetrics(int nIndex);
@@ -1046,6 +1032,9 @@ public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hWnd, int msg,
public static extern int GetSystemMetricsForDpi(int nIndex, uint dpi);
+ [DllImport(ExternDll.Gdi32, CharSet = CharSet.Auto)]
+ public static extern bool GetTextMetrics(HandleRef hdc, NativeMethods.TEXTMETRIC tm);
+
///
/// Tries to get system metrics for the dpi. dpi is ignored if "GetSystemMetricsForDpi" is not available on the OS that this application is running.
///
@@ -1135,6 +1124,10 @@ public static bool TrySystemParametersInfoForDpi(int nAction, int nParam, [In, O
[DllImport(ExternDll.Ole32, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern int RevokeDragDrop(HandleRef hwnd);
+
+ [DllImport(ExternDll.Ole32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern int RevokeDragDrop(IntPtr hwnd);
[DllImport(ExternDll.User32, CharSet=CharSet.Auto)]
public static extern bool PeekMessage([In, Out] ref NativeMethods.MSG msg, HandleRef hwnd, int msgMin, int msgMax, int remove);
@@ -1161,6 +1154,11 @@ public static bool TrySystemParametersInfoForDpi(int nAction, int nParam, [In, O
[DllImport(ExternDll.Oleacc, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr LresultFromObject(ref Guid refiid, IntPtr wParam, HandleRef pAcc);
+
+ [DllImport(ExternDll.Oleacc, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.Process)]
+ public static extern IntPtr LresultFromObject(ref Guid refiid, IntPtr wParam, IntPtr pAcc);
+
[DllImport(ExternDll.Oleacc, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
public static extern int CreateStdAccessibleObject(HandleRef hWnd, int objID, ref Guid refiid, [In, Out, MarshalAs(UnmanagedType.Interface)] ref object pAcc);
@@ -1185,7 +1183,11 @@ public static bool TrySystemParametersInfoForDpi(int nAction, int nParam, [In, O
public static IntPtr BeginPaint(HandleRef hWnd, [In, Out, MarshalAs(UnmanagedType.LPStruct)] ref NativeMethods.PAINTSTRUCT lpPaint) {
return System.Internal.HandleCollector.Add(IntBeginPaint(hWnd, ref lpPaint), NativeMethods.CommonHandles.HDC);
}
-
+
+ [DllImport(ExternDll.User32, ExactSpelling = true, EntryPoint = "BeginPaint", CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr BeginPaint(IntPtr hWnd, [In, Out] ref NativeMethods.PAINTSTRUCT lpPaint);
+
[DllImport(ExternDll.User32, ExactSpelling=true, EntryPoint="EndPaint", CharSet=CharSet.Auto)]
private static extern bool IntEndPaint(HandleRef hWnd, ref NativeMethods.PAINTSTRUCT lpPaint);
@@ -1194,6 +1196,10 @@ public static bool EndPaint(HandleRef hWnd, [In, MarshalAs(UnmanagedType.LPStruc
return IntEndPaint(hWnd, ref lpPaint);
}
+ [DllImport(ExternDll.User32, ExactSpelling = true, EntryPoint = "EndPaint", CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern bool EndPaint(IntPtr hWnd, ref NativeMethods.PAINTSTRUCT lpPaint);
+
[DllImport(ExternDll.User32, ExactSpelling=true, EntryPoint="GetDC", CharSet=CharSet.Auto)]
private static extern IntPtr IntGetDC(HandleRef hWnd);
@@ -1582,13 +1588,13 @@ public unsafe static NativeMethods.RECT[] GetRectsFromRegion(IntPtr hRgn) {
regionRects = new NativeMethods.RECT[pRgnDataHeader->nCount];
Debug.Assert(regionDataSize == pRgnDataHeader->cbSizeOfStruct + pRgnDataHeader->nCount * pRgnDataHeader->nRgnSize);
- Debug.Assert(Marshal.SizeOf(typeof(NativeMethods.RECT)) == pRgnDataHeader->nRgnSize || pRgnDataHeader->nRgnSize == 0);
+ Debug.Assert(Marshal.SizeOf() == pRgnDataHeader->nRgnSize || pRgnDataHeader->nRgnSize == 0);
// use the header size as the offset, and cast each rect in.
int rectStart = pRgnDataHeader->cbSizeOfStruct;
for (int i = 0; i < pRgnDataHeader->nCount; i++) {
// use some fancy pointer math to just copy the rect bits directly into the array.
- regionRects[i] = *((NativeMethods.RECT*)((byte*)pBytes + rectStart + (Marshal.SizeOf(typeof(NativeMethods.RECT)) * i)));
+ regionRects[i] = *((NativeMethods.RECT*)((byte*)pBytes + rectStart + (Marshal.SizeOf() * i)));
}
}
}
@@ -7177,7 +7183,7 @@ int GetHelpContext(
public sealed class tagQACONTAINER
{
[MarshalAs(UnmanagedType.U4)]
- public int cbSize = Marshal.SizeOf(typeof(tagQACONTAINER));
+ public int cbSize = Marshal.SizeOf();
public UnsafeNativeMethods.IOleClientSite pClientSite;
@@ -7229,7 +7235,7 @@ public sealed class tagQACONTAINER
public sealed class tagQACONTROL
{
[MarshalAs(UnmanagedType.U4)/*leftover(offset=0, cbSize)*/]
- public int cbSize = Marshal.SizeOf(typeof(tagQACONTROL));
+ public int cbSize = Marshal.SizeOf();
[MarshalAs(UnmanagedType.U4)/*leftover(offset=4, dwMiscStatus)*/]
public int dwMiscStatus = 0;
@@ -7284,272 +7290,69 @@ public interface ILegacyIAccessibleProvider {
string DefaultAction { get; }
}
- [ComImport(), Guid("0000000A-0000-0000-C000-000000000046"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- public interface ILockBytes {
-
-
- void ReadAt(
- [In, MarshalAs(UnmanagedType.U8)]
- long ulOffset,
- [Out]
- IntPtr pv,
- [In, MarshalAs(UnmanagedType.U4)]
- int cb,
- [Out, MarshalAs(UnmanagedType.LPArray)]
- int[] pcbRead);
-
-
- void WriteAt(
- [In, MarshalAs(UnmanagedType.U8)]
- long ulOffset,
-
- IntPtr pv,
- [In, MarshalAs(UnmanagedType.U4)]
- int cb,
- [Out, MarshalAs(UnmanagedType.LPArray)]
- int[] pcbWritten);
-
-
- void Flush();
-
-
- void SetSize(
- [In, MarshalAs(UnmanagedType.U8)]
- long cb);
-
-
- void LockRegion(
- [In, MarshalAs(UnmanagedType.U8)]
- long libOffset,
- [In, MarshalAs(UnmanagedType.U8)]
- long cb,
- [In, MarshalAs(UnmanagedType.U4)]
- int dwLockType);
-
-
- void UnlockRegion(
- [In, MarshalAs(UnmanagedType.U8)]
- long libOffset,
- [In, MarshalAs(UnmanagedType.U8)]
- long cb,
- [In, MarshalAs(UnmanagedType.U4)]
- int dwLockType);
-
-
- void Stat(
- [Out]
- NativeMethods.STATSTG pstatstg,
- [In, MarshalAs(UnmanagedType.U4)]
- int grfStatFlag);
-
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public class OFNOTIFY
- {
- // hdr was a by-value NMHDR structure
- public IntPtr hdr_hwndFrom = IntPtr.Zero;
- public IntPtr hdr_idFrom = IntPtr.Zero;
- public int hdr_code = 0;
-
- public IntPtr lpOFN = IntPtr.Zero;
- public IntPtr pszFile = IntPtr.Zero;
- }
-
- internal static bool IsComObject(object o)
- {
- return Marshal.IsComObject(o);
- }
-
- internal static int ReleaseComObject(object objToRelease)
- {
- return Marshal.ReleaseComObject(objToRelease);
- }
-
- public static object PtrToStructure(IntPtr lparam, Type cls) {
- return Marshal.PtrToStructure(lparam, cls);
- }
-
- public static void PtrToStructure(IntPtr lparam, object data) {
- Marshal.PtrToStructure(lparam, data);
- }
-
- internal static int SizeOf(Type t)
- {
- return Marshal.SizeOf(t);
- }
-
- internal static void ThrowExceptionForHR(int errorCode)
+ [ComImport]
+ [Guid("0000000A-0000-0000-C000-000000000046")]
+ [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface ILockBytes
{
- Marshal.ThrowExceptionForHR(errorCode);
+ void ReadAt(
+ [In, MarshalAs(UnmanagedType.U8)] long ulOffset,
+ [Out] IntPtr pv,
+ [In, MarshalAs(UnmanagedType.U4)] int cb,
+ [Out, MarshalAs(UnmanagedType.LPArray)] int[] pcbRead
+ );
+
+ void WriteAt(
+ [In, MarshalAs(UnmanagedType.U8)] long ulOffset,
+ IntPtr pv,
+ [In, MarshalAs(UnmanagedType.U4)] int cb,
+ [Out, MarshalAs(UnmanagedType.LPArray)] int[] pcbWritten
+ );
+
+ void Flush();
+
+ void SetSize([In, MarshalAs(UnmanagedType.U8)] long cb);
+
+ void LockRegion(
+ [In, MarshalAs(UnmanagedType.U8)] long libOffset,
+ [In, MarshalAs(UnmanagedType.U8)] long cb,
+ [In, MarshalAs(UnmanagedType.U4)] int dwLockType
+ );
+
+ void UnlockRegion(
+ [In, MarshalAs(UnmanagedType.U8)] long libOffset,
+ [In, MarshalAs(UnmanagedType.U8)] long cb,
+ [In, MarshalAs(UnmanagedType.U4)] int dwLockType
+ );
+
+ void Stat(
+ [Out] NativeMethods.STATSTG pstatstg,
+ [In, MarshalAs(UnmanagedType.U4)] int grfStatFlag
+ );
}
-
- public delegate int BrowseCallbackProc(
- IntPtr hwnd,
- int msg,
- IntPtr lParam,
- IntPtr lpData);
-
- [Flags]
- public enum BrowseInfos
+ [StructLayout(LayoutKind.Sequential)]
+ public class OFNOTIFY
{
- NewDialogStyle = 0x0040, // Use the new dialog layout with the ability to resize
- HideNewFolderButton = 0x0200 // Don't display the 'New Folder' button
- }
+ // hdr was a by-value NMHDR structure
+ public IntPtr hdr_hwndFrom = IntPtr.Zero;
+ public IntPtr hdr_idFrom = IntPtr.Zero;
+ public int hdr_code = 0;
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
- public class BROWSEINFO
- {
- [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- public IntPtr hwndOwner; //HWND hwndOwner; // HWND of the owner for the dialog
- [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- public IntPtr pidlRoot; //LPCITEMIDLIST pidlRoot; // Root ITEMIDLIST
-
- // For interop purposes, send over a buffer of MAX_PATH size.
- [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- public IntPtr pszDisplayName; //LPWSTR pszDisplayName; // Return display name of item selected.
-
- public string lpszTitle; //LPCWSTR lpszTitle; // text to go in the banner over the tree.
- public int ulFlags; //UINT ulFlags; // Flags that control the return stuff
- public BrowseCallbackProc lpfn; //BFFCALLBACK lpfn; // Call back pointer
- [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- public IntPtr lParam; //LPARAM lParam; // extra info that's passed back in callbacks
- public int iImage; //int iImage; // output var: where to return the Image index.
+ public IntPtr lpOFN = IntPtr.Zero;
+ public IntPtr pszFile = IntPtr.Zero;
}
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
internal class Shell32
{
- [DllImport(ExternDll.Shell32)]
-
- public static extern int SHGetSpecialFolderLocation(IntPtr hwnd, int csidl, ref IntPtr ppidl);
- //SHSTDAPI SHGetSpecialFolderLocation(HWND hwnd, int csidl, LPITEMIDLIST *ppidl);
-
- [DllImport(ExternDll.Shell32, CharSet = CharSet.Auto)]
-
- private static extern bool SHGetPathFromIDListEx(IntPtr pidl, IntPtr pszPath, int cchPath, int flags);
- //SHSTDAPI_(BOOL) SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath);
-
- public static bool SHGetPathFromIDListLongPath(IntPtr pidl, ref IntPtr pszPath)
- {
- int noOfTimes = 1;
- int length = NativeMethods.MAX_PATH;
- bool result = false;
-
- // SHGetPathFromIDListEx returns false in case of insufficient buffer.
- // This method does not distinguish between insufficient memory and an error. Until we get a proper solution,
- // this logic would work. In the worst case scenario, loop exits when length reaches unicode string length.
- while ((result = SHGetPathFromIDListEx(pidl, pszPath, length, 0)) == false
- && length < NativeMethods.MAX_UNICODESTRING_LEN)
- {
- string path = Marshal.PtrToStringAuto(pszPath);
-
- if (path.Length != 0 && path.Length < length)
- break;
-
- noOfTimes += 2; //520 chars capacity increase in each iteration.
- length = noOfTimes * length >= NativeMethods.MAX_UNICODESTRING_LEN
- ? NativeMethods.MAX_UNICODESTRING_LEN : noOfTimes * length;
- pszPath = Marshal.ReAllocHGlobal(pszPath, (IntPtr)((length + 1) * sizeof(char)));
- }
-
- return result;
- }
-
- [DllImport(ExternDll.Shell32, CharSet=CharSet.Auto)]
-
- public static extern IntPtr SHBrowseForFolder([In] BROWSEINFO lpbi);
- //SHSTDAPI_(LPITEMIDLIST) SHBrowseForFolderW(LPBROWSEINFOW lpbi);
-
- [DllImport(ExternDll.Shell32)]
-
- public static extern int SHGetMalloc([Out, MarshalAs(UnmanagedType.LPArray)] UnsafeNativeMethods.IMalloc[] ppMalloc);
- //SHSTDAPI SHGetMalloc(LPMALLOC * ppMalloc);
-
- [SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist")]
- [DllImport(ExternDll.Shell32, PreserveSig = true)]
-
- private static extern int SHGetKnownFolderPath(ref Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);
-
- public static int SHGetFolderPathEx(ref Guid rfid, uint dwFlags, IntPtr hToken, StringBuilder pszPath)
- {
- if (IsVista)
- {
- IntPtr path = IntPtr.Zero;
- int result = -1;
- if ((result = SHGetKnownFolderPath(ref rfid, dwFlags, hToken, out path)) == NativeMethods.S_OK)
- {
- pszPath.Append(Marshal.PtrToStringAuto(path));
- CoTaskMemFree(path);
- }
- return result;
- }
- throw new NotSupportedException();
- }
-
[DllImport(ExternDll.Shell32, PreserveSig = true)]
-
public static extern int SHCreateShellItem(IntPtr pidlParent, IntPtr psfParent, IntPtr pidl, out FileDialogNative.IShellItem ppsi);
[DllImport(ExternDll.Shell32, PreserveSig = true)]
-
public static extern int SHILCreateFromPath([MarshalAs(UnmanagedType.LPWStr)]string pszPath, out IntPtr ppIdl, ref uint rgflnOut);
}
- [
- ComImport(),
- Guid("00000002-0000-0000-c000-000000000046"),
- System.Runtime.InteropServices.InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
- public interface IMalloc
- {
- [PreserveSig]
- IntPtr Alloc(int cb);
-
- [PreserveSig]
- IntPtr Realloc(IntPtr pv, int cb);
-
- [PreserveSig]
- void Free(IntPtr pv);
-
- [PreserveSig]
- int GetSize(IntPtr pv);
-
- [PreserveSig]
- int DidAlloc(IntPtr pv);
-
- [PreserveSig]
- void HeapMinimize();
- }
-
- [
- ComImport,
- Guid("00000126-0000-0000-C000-000000000046"),
- InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)
- ]
- public interface IRunnableObject
- {
- void GetRunningClass(out Guid guid);
-
- [PreserveSig]
- int Run(IntPtr lpBindContext);
- bool IsRunning();
- void LockRunning(bool fLock, bool fLastUnlockCloses);
- void SetContainedObject(bool fContained);
- }
-
- [ComVisible(true), ComImport(), Guid("B722BCC7-4E68-101B-A2BC-00AA00404770"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IOleDocumentSite
- {
-
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int ActivateMe(
- [In, MarshalAs(UnmanagedType.Interface)]
- IOleDocumentView pViewToActivate);
-
- }
-
[ComVisible(true), Guid("B722BCC6-4E68-101B-A2BC-00AA00404770"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDocumentView
{
@@ -8039,7 +7842,7 @@ public static bool CreateActivationContext(string dllPath, int nativeResourceMan
enableThemingActivationContext = new ACTCTX();
- enableThemingActivationContext.cbSize = Marshal.SizeOf(typeof(ACTCTX));
+ enableThemingActivationContext.cbSize = Marshal.SizeOf();
enableThemingActivationContext.lpSource = dllPath;
enableThemingActivationContext.lpResourceName = (IntPtr)nativeResourceManifestID;
enableThemingActivationContext.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
@@ -8325,16 +8128,10 @@ public interface IRawElementProviderHwndOverride : IRawElementProviderSimple {
IRawElementProviderSimple GetOverrideProviderForHwnd(IntPtr hwnd);
}
- ///
- /// Critical:Elevates to Unmanaged code permission
- ///
[ComImport()]
[Guid("6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IServiceProvider {
- ///
- /// Critical elevates via a SUC.
- ///
[PreserveSig]
int QueryService(ref Guid service, ref Guid riid, out IntPtr ppvObj);
}
diff --git a/src/Common/tests/CommonTestHelper.cs b/src/Common/tests/CommonTestHelper.cs
index d864defb9d4..869e3106b53 100644
--- a/src/Common/tests/CommonTestHelper.cs
+++ b/src/Common/tests/CommonTestHelper.cs
@@ -4,7 +4,9 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.Design.Serialization;
using System.Drawing;
+using System.Drawing.Text;
using System.Linq;
using System.Windows.Forms;
using Xunit;
@@ -166,6 +168,14 @@ public static TheoryData GetNullOrEmptyStringTheoryData()
return data;
}
+ public static TheoryData GetCharTheoryData()
+ {
+ var data = new TheoryData();
+ data.Add('\0');
+ data.Add('a');
+ return data;
+ }
+
public static TheoryData GetIntPtrTheoryData()
{
var data = new TheoryData();
@@ -192,6 +202,22 @@ public static TheoryData GetColorWithEmptyTheoryData()
return data;
}
+ public static TheoryData GetImageTheoryData()
+ {
+ var data = new TheoryData();
+ data.Add(new Bitmap(10, 10));
+ data.Add(null);
+ return data;
+ }
+
+ public static TheoryData GetFontTheoryData()
+ {
+ var data = new TheoryData();
+ data.Add(SystemFonts.MenuFont);
+ data.Add(null);
+ return data;
+ }
+
public static TheoryData GetTypeWithNullTheoryData()
{
var data = new TheoryData();
@@ -209,12 +235,49 @@ public static TheoryData GetRightToLeftTheoryData()
return data;
}
- public static TheoryData GetSizeTheoryData()
+ public static TheoryData GetPointTheoryData() => GetPointTheoryData(TestIncludeType.All);
+
+ public static TheoryData GetPointTheoryData(TestIncludeType includeType)
+ {
+ var data = new TheoryData();
+ if (!includeType.HasFlag(TestIncludeType.NoPositives))
+ {
+ data.Add(new Point());
+ data.Add(new Point(10));
+ data.Add(new Point(1, 2));
+ }
+ if (!includeType.HasFlag(TestIncludeType.NoNegatives))
+ {
+ data.Add(new Point(int.MaxValue, int.MinValue));
+ data.Add(new Point(-1, -2));
+ }
+ return data;
+ }
+
+ public static TheoryData GetSizeTheoryData() => GetSizeTheoryData(TestIncludeType.All);
+
+ public static TheoryData GetSizeTheoryData(TestIncludeType includeType)
+ {
+ var data = new TheoryData();
+ if (!includeType.HasFlag(TestIncludeType.NoPositives))
+ {
+ data.Add(new Size());
+ data.Add(new Size(new Point(1,1)));
+ data.Add(new Size(1, 2));
+ }
+ if (!includeType.HasFlag(TestIncludeType.NoNegatives))
+ {
+ data.Add(new Size(-1, 1));
+ data.Add(new Size(1, -1));
+ }
+ return data;
+ }
+
+ public static TheoryData GetPositiveSizeTheoryData()
{
var data = new TheoryData();
data.Add(new Size());
data.Add(new Size(1, 2));
- data.Add(new Size(-1, -2));
return data;
}
@@ -251,13 +314,29 @@ public static TheoryData GetConvertFromTheoryData()
{
var data = new TheoryData();
data.Add(typeof(bool), false);
- data.Add(typeof(System.ComponentModel.Design.Serialization.InstanceDescriptor), true);
+ data.Add(typeof(InstanceDescriptor), true);
data.Add(typeof(int), false);
data.Add(typeof(double), false);
data.Add(null, false);
return data;
}
+ public static TheoryData GetCursorTheoryData()
+ {
+ var data = new TheoryData();
+ data.Add(null);
+ data.Add(new Cursor((IntPtr)1));
+ return data;
+ }
+
#endregion
}
+
+ [Flags]
+ public enum TestIncludeType
+ {
+ All,
+ NoPositives,
+ NoNegatives
+ }
}
diff --git a/src/System.Windows.Forms.Design.Editors/src/Misc/DpiHelper.cs b/src/System.Windows.Forms.Design.Editors/src/Misc/DpiHelper.cs
index cbbf420dae9..8b16375a57c 100644
--- a/src/System.Windows.Forms.Design.Editors/src/Misc/DpiHelper.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/Misc/DpiHelper.cs
@@ -7,14 +7,11 @@
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
-#if WINFORMS_NAMESPACE
+#if DRAWING_DESIGN_NAMESPACE
using System.Windows.Forms.Internal;
using CAPS = System.Windows.Forms.NativeMethods;
#elif DRAWING_NAMESPACE
using CAPS = System.Drawing.SafeNativeMethods;
-#elif DRAWINGDESIGN_NAMESPACE
-using System.Drawing.Design;
-using CAPS = System.Drawing.Design.NativeMethods;
#else
using System.Windows.Forms.Design;
using CAPS = System.Windows.Forms.Design.NativeMethods;
@@ -85,7 +82,7 @@ private static void Initialize()
if (enableHighDpi)
{
-#if WINFORMS_NAMESPACE
+#if DRAWING_DESIGN_NAMESPACE
try
{
if (!DpiHelper.SetWinformsApplicationDpiAwareness())
@@ -557,7 +554,7 @@ public static void ScaleBitmapLogicalToDevice(ref Bitmap logicalBitmap, int devi
// This method is used only in System.Design, thus excluding the rest.
// This is particularly important for System.Drawing, which should not depend
// on System.Windows.Forms assembly, where "Button" type is defined.
-#if (!DRAWING_NAMESPACE && !DRAWINGDESIGN_NAMESPACE && !WINFORMS_NAMESPACE)
+#if (!DRAWING_NAMESPACE && !DRAWING_DESIGN_NAMESPACE)
///
/// Create a new button bitmap scaled for the device units.
/// Note: original image might be disposed.
diff --git a/src/System.Windows.Forms.Design.Editors/src/Misc/NativeMethods.cs b/src/System.Windows.Forms.Design.Editors/src/Misc/NativeMethods.cs
index 8546f505ae5..960058d95e3 100644
--- a/src/System.Windows.Forms.Design.Editors/src/Misc/NativeMethods.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/Misc/NativeMethods.cs
@@ -47,36 +47,27 @@ public class TEXTMETRIC
// Investigate removing this if the duplicate code in OleDragDropHandler.cs is removed
public const int HOLLOW_BRUSH = 5;
- public const int WM_USER = 0x0400,
- WM_CLOSE = 0x0010,
- WM_GETDLGCODE = 0x0087,
- WM_MOUSEMOVE = 0x0200,
- WM_NOTIFY = 0x004E,
- DLGC_WANTALLKEYS = 0x0004,
- NM_CLICK = 0 - 0 - 2,
- WM_REFLECT = WM_USER + 0x1C00,
- BM_SETIMAGE = 0x00F7,
- IMAGE_ICON = 1,
- WM_DESTROY = 0x0002,
- BS_ICON = 0x00000040,
- EM_SETMARGINS = 0x00D3,
- EC_LEFTMARGIN = 0x0001,
- EC_RIGHTMARGIN = 0x0002,
- IDOK = 1,
- WM_INITDIALOG = 0x0110;
+ public const int DLGC_WANTALLKEYS = 0x0004;
+ public const int NM_CLICK = 0 - 0 - 2;
+ public const int BM_SETIMAGE = 0x00F7;
+ public const int IMAGE_ICON = 1;
+ public const int BS_ICON = 0x00000040;
+ public const int EC_LEFTMARGIN = 0x0001;
+ public const int EC_RIGHTMARGIN = 0x0002;
+ public const int IDOK = 1;
+
public const int VK_PROCESSKEY = 0xE5;
- public const int STGM_READ = 0x00000000,
- STGM_WRITE = 0x00000001,
- STGM_READWRITE = 0x00000002,
- STGM_SHARE_EXCLUSIVE = 0x00000010,
- STGM_CREATE = 0x00001000,
- STGM_TRANSACTED = 0x00010000,
- STGM_CONVERT = 0x00020000,
- WM_COMMAND = 0x0111,
- CC_FULLOPEN = 0x00000002,
- CC_ENABLETEMPLATEHANDLE = 0x00000040,
- STGM_DELETEONRELEASE = 0x04000000;
+ public const int STGM_READ = 0x00000000;
+ public const int STGM_WRITE = 0x00000001;
+ public const int STGM_READWRITE = 0x00000002;
+ public const int STGM_SHARE_EXCLUSIVE = 0x00000010;
+ public const int STGM_CREATE = 0x00001000;
+ public const int STGM_TRANSACTED = 0x00010000;
+ public const int STGM_CONVERT = 0x00020000;
+ public const int CC_FULLOPEN = 0x00000002;
+ public const int CC_ENABLETEMPLATEHANDLE = 0x00000040;
+ public const int STGM_DELETEONRELEASE = 0x04000000;
public const int RECO_PASTE = 0x00000000; // paste from clipboard
public const int RECO_DROP = 0x00000001; // drop
@@ -208,7 +199,7 @@ public enum TabControlHitTest
[StructLayout(LayoutKind.Sequential)]
public class TRACKMOUSEEVENT
{
- public readonly int cbSize = Marshal.SizeOf(typeof(TRACKMOUSEEVENT));
+ public readonly int cbSize = Marshal.SizeOf();
public readonly int dwFlags;
public readonly int dwHoverTime = 0;
public readonly IntPtr hwndTrack;
@@ -253,9 +244,6 @@ public const int
PM_NOREMOVE = 0x0000,
PM_REMOVE = 0x0001;
- public const int
- WM_CHAR = 0x0102;
-
[SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
[StructLayout(LayoutKind.Sequential)]
public struct MOUSEHOOKSTRUCT
@@ -764,19 +752,6 @@ void OnShowWindow(
void RequestNewObjectLayout();
}
- [ComVisible(true)]
- [ComImport]
- [Guid("B722BCC7-4E68-101B-A2BC-00AA00404770")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IOleDocumentSite
- {
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int ActivateMe(
- [In] [MarshalAs(UnmanagedType.Interface)]
- IOleDocumentView pViewToActivate);
- }
-
[ComVisible(true)]
[ComImport]
[Guid("B722BCC6-4E68-101B-A2BC-00AA00404770")]
@@ -3608,294 +3583,223 @@ void SetNodeValue(
public static readonly int WM_MOUSEENTER = Util.RegisterWindowMessage("WinFormsMouseEnter");
public static readonly int HDN_ENDTRACK = HDN_ENDTRACKW;
- public const int
- DT_CALCRECT = 0x00000400,
- WM_CAPTURECHANGED = 0x0215,
- WM_PARENTNOTIFY = 0x0210,
- WM_CREATE = 0x0001,
- WM_SETREDRAW = 0x000B,
- WM_NCACTIVATE = 0x0086,
- WM_HSCROLL = 0x0114,
- WM_VSCROLL = 0x0115,
- WM_SHOWWINDOW = 0x0018,
- WM_WINDOWPOSCHANGING = 0x0046,
- WM_WINDOWPOSCHANGED = 0x0047,
- WS_DISABLED = 0x08000000,
- WS_CLIPSIBLINGS = 0x04000000,
- WS_CLIPCHILDREN = 0x02000000,
- WS_EX_TOOLWINDOW = 0x00000080,
- WS_POPUP = unchecked((int)0x80000000),
- WS_BORDER = 0x00800000,
- CS_DROPSHADOW = 0x00020000,
- CS_DBLCLKS = 0x0008,
- NOTSRCCOPY = 0x00330008,
- SRCCOPY = 0x00CC0020,
- LVM_SETCOLUMNWIDTH = 0x1000 + 30,
- LVM_GETHEADER = 0x1000 + 31,
- LVM_CREATEDRAGIMAGE = 0x1000 + 33,
- LVM_GETVIEWRECT = 0x1000 + 34,
- LVM_GETTEXTCOLOR = 0x1000 + 35,
- LVM_SETTEXTCOLOR = 0x1000 + 36,
- LVM_GETTEXTBKCOLOR = 0x1000 + 37,
- LVM_SETTEXTBKCOLOR = 0x1000 + 38,
- LVM_GETTOPINDEX = 0x1000 + 39,
- LVM_GETCOUNTPERPAGE = 0x1000 + 40,
- LVM_GETORIGIN = 0x1000 + 41,
- LVM_UPDATE = 0x1000 + 42,
- LVM_SETITEMSTATE = 0x1000 + 43,
- LVM_GETITEMSTATE = 0x1000 + 44,
- LVM_GETITEMTEXTA = 0x1000 + 45,
- LVM_GETITEMTEXTW = 0x1000 + 115,
- LVM_SETITEMTEXTA = 0x1000 + 46,
- LVM_SETITEMTEXTW = 0x1000 + 116,
- LVSICF_NOINVALIDATEALL = 0x00000001,
- LVSICF_NOSCROLL = 0x00000002,
- LVM_SETITEMCOUNT = 0x1000 + 47,
- LVM_SORTITEMS = 0x1000 + 48,
- LVM_SETITEMPOSITION32 = 0x1000 + 49,
- LVM_GETSELECTEDCOUNT = 0x1000 + 50,
- LVM_GETITEMSPACING = 0x1000 + 51,
- LVM_GETISEARCHSTRINGA = 0x1000 + 52,
- LVM_GETISEARCHSTRINGW = 0x1000 + 117,
- LVM_SETICONSPACING = 0x1000 + 53,
- LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54,
- LVM_GETEXTENDEDLISTVIEWSTYLE = 0x1000 + 55,
- LVS_EX_GRIDLINES = 0x00000001,
- HDM_HITTEST = 0x1200 + 6,
- HDM_GETITEMRECT = 0x1200 + 7,
- HDM_SETIMAGELIST = 0x1200 + 8,
- HDM_GETIMAGELIST = 0x1200 + 9,
- HDM_ORDERTOINDEX = 0x1200 + 15,
- HDM_CREATEDRAGIMAGE = 0x1200 + 16,
- HDM_GETORDERARRAY = 0x1200 + 17,
- HDM_SETORDERARRAY = 0x1200 + 18,
- HDM_SETHOTDIVIDER = 0x1200 + 19,
- HDN_ITEMCHANGINGA = 0 - 300 - 0,
- HDN_ITEMCHANGINGW = 0 - 300 - 20,
- HDN_ITEMCHANGEDA = 0 - 300 - 1,
- HDN_ITEMCHANGEDW = 0 - 300 - 21,
- HDN_ITEMCLICKA = 0 - 300 - 2,
- HDN_ITEMCLICKW = 0 - 300 - 22,
- HDN_ITEMDBLCLICKA = 0 - 300 - 3,
- HDN_ITEMDBLCLICKW = 0 - 300 - 23,
- HDN_DIVIDERDBLCLICKA = 0 - 300 - 5,
- HDN_DIVIDERDBLCLICKW = 0 - 300 - 25,
- HDN_BEGINTRACKA = 0 - 300 - 6,
- HDN_BEGINTRACKW = 0 - 300 - 26,
- HDN_ENDTRACKA = 0 - 300 - 7,
- HDN_ENDTRACKW = 0 - 300 - 27,
- HDN_TRACKA = 0 - 300 - 8,
- HDN_TRACKW = 0 - 300 - 28,
- HDN_GETDISPINFOA = 0 - 300 - 9,
- HDN_GETDISPINFOW = 0 - 300 - 29,
- HDN_BEGINDRAG = 0 - 300 - 10,
- HDN_ENDDRAG = 0 - 300 - 11,
- HC_ACTION = 0,
- HIST_BACK = 0,
- HHT_ONHEADER = 0x0002,
- HHT_ONDIVIDER = 0x0004,
- HHT_ONDIVOPEN = 0x0008,
- HHT_ABOVE = 0x0100,
- HHT_BELOW = 0x0200,
- HHT_TORIGHT = 0x0400,
- HHT_TOLEFT = 0x0800,
- HWND_TOP = 0,
- HWND_BOTTOM = 1,
- HWND_TOPMOST = -1,
- HWND_NOTOPMOST = -2,
- CWP_SKIPINVISIBLE = 0x0001,
- RDW_FRAME = 0x0400,
- WM_KILLFOCUS = 0x0008,
- WM_STYLECHANGED = 0x007D,
- TVM_GETITEMRECT = 0x1100 + 4,
- TVM_GETCOUNT = 0x1100 + 5,
- TVM_GETINDENT = 0x1100 + 6,
- TVM_SETINDENT = 0x1100 + 7,
- TVM_GETIMAGELIST = 0x1100 + 8,
- TVSIL_NORMAL = 0,
- TVSIL_STATE = 2,
- TVM_SETIMAGELIST = 0x1100 + 9,
- TVM_GETNEXTITEM = 0x1100 + 10,
- TVGN_ROOT = 0x0000,
- TV_FIRST = 0x1100,
- TVM_SETEXTENDEDSTYLE = TV_FIRST + 44,
- TVM_GETEXTENDEDSTYLE = TV_FIRST + 45,
- TVS_EX_FADEINOUTEXPANDOS = 0x0040,
- TVS_EX_DOUBLEBUFFER = 0x0004,
- LVS_EX_DOUBLEBUFFER = 0x00010000,
- TVHT_ONITEMICON = 0x0002,
- TVHT_ONITEMLABEL = 0x0004,
- TVHT_ONITEMINDENT = 0x0008,
- TVHT_ONITEMBUTTON = 0x0010,
- TVHT_ONITEMRIGHT = 0x0020,
- TVHT_ONITEMSTATEICON = 0x0040,
- TVHT_ABOVE = 0x0100,
- TVHT_BELOW = 0x0200,
- TVHT_TORIGHT = 0x0400,
- TVHT_TOLEFT = 0x0800,
- GW_HWNDFIRST = 0,
- GW_HWNDLAST = 1,
- GW_HWNDNEXT = 2,
- GW_HWNDPREV = 3,
- GW_OWNER = 4,
- GW_CHILD = 5,
- GW_MAX = 5,
- GWL_HWNDPARENT = -8,
- SB_HORZ = 0,
- SB_VERT = 1,
- SB_CTL = 2,
- SB_BOTH = 3,
- SB_LINEUP = 0,
- SB_LINELEFT = 0,
- SB_LINEDOWN = 1,
- SB_LINERIGHT = 1,
- SB_PAGEUP = 2,
- SB_PAGELEFT = 2,
- SB_PAGEDOWN = 3,
- SB_PAGERIGHT = 3,
- SB_THUMBPOSITION = 4,
- SB_THUMBTRACK = 5,
- SB_TOP = 6,
- SB_LEFT = 6,
- SB_BOTTOM = 7,
- SB_RIGHT = 7,
- SB_ENDSCROLL = 8,
- MK_LBUTTON = 0x0001,
- TVM_HITTEST = 0x1100 + 17,
- MK_RBUTTON = 0x0002,
- MK_SHIFT = 0x0004,
- MK_CONTROL = 0x0008,
- MK_MBUTTON = 0x0010,
- MK_XBUTTON1 = 0x0020,
- MK_XBUTTON2 = 0x0040,
- LB_ADDSTRING = 0x0180,
- LB_INSERTSTRING = 0x0181,
- LB_DELETESTRING = 0x0182,
- LB_SELITEMRANGEEX = 0x0183,
- LB_RESETCONTENT = 0x0184,
- LB_SETSEL = 0x0185,
- LB_SETCURSEL = 0x0186,
- LB_GETSEL = 0x0187,
- LB_GETCURSEL = 0x0188,
- LB_GETTEXT = 0x0189,
- LB_GETTEXTLEN = 0x018A,
- LB_GETCOUNT = 0x018B,
- LB_SELECTSTRING = 0x018C,
- LB_DIR = 0x018D,
- LB_GETTOPINDEX = 0x018E,
- LB_FINDSTRING = 0x018F,
- LB_GETSELCOUNT = 0x0190,
- LB_GETSELITEMS = 0x0191,
- LB_SETTABSTOPS = 0x0192,
- LB_GETHORIZONTALEXTENT = 0x0193,
- LB_SETHORIZONTALEXTENT = 0x0194,
- LB_SETCOLUMNWIDTH = 0x0195,
- LB_ADDFILE = 0x0196,
- LB_SETTOPINDEX = 0x0197,
- LB_GETITEMRECT = 0x0198,
- LB_GETITEMDATA = 0x0199,
- LB_SETITEMDATA = 0x019A,
- LB_SELITEMRANGE = 0x019B,
- LB_SETANCHORINDEX = 0x019C,
- LB_GETANCHORINDEX = 0x019D,
- LB_SETCARETINDEX = 0x019E,
- LB_GETCARETINDEX = 0x019F,
- LB_SETITEMHEIGHT = 0x01A0,
- LB_GETITEMHEIGHT = 0x01A1,
- LB_FINDSTRINGEXACT = 0x01A2,
- LB_SETLOCALE = 0x01A5,
- LB_GETLOCALE = 0x01A6,
- LB_SETCOUNT = 0x01A7,
- LB_INITSTORAGE = 0x01A8,
- LB_ITEMFROMPOINT = 0x01A9,
- LB_MSGMAX = 0x01B0,
- HTHSCROLL = 6,
- HTVSCROLL = 7,
- HTERROR = -2,
- HTTRANSPARENT = -1,
- HTNOWHERE = 0,
- HTCLIENT = 1,
- HTCAPTION = 2,
- HTSYSMENU = 3,
- HTGROWBOX = 4,
- HTSIZE = 4,
- PRF_NONCLIENT = 0x00000002,
- PRF_CLIENT = 0x00000004,
- PRF_ERASEBKGND = 0x00000008,
- PRF_CHILDREN = 0x00000010,
- SWP_NOSIZE = 0x0001,
- SWP_NOMOVE = 0x0002,
- SWP_NOZORDER = 0x0004,
- SWP_NOREDRAW = 0x0008,
- SWP_NOACTIVATE = 0x0010,
- SWP_FRAMECHANGED = 0x0020,
- SWP_SHOWWINDOW = 0x0040,
- SWP_HIDEWINDOW = 0x0080,
- SWP_NOCOPYBITS = 0x0100,
- SWP_NOOWNERZORDER = 0x0200,
- SWP_NOSENDCHANGING = 0x0400,
- SWP_DRAWFRAME = 0x0020,
- SWP_NOREPOSITION = 0x0200,
- SWP_DEFERERASE = 0x2000,
- SWP_ASYNCWINDOWPOS = 0x4000,
- WA_INACTIVE = 0,
- WA_ACTIVE = 1,
- WH_MOUSE = 7,
- WM_IME_STARTCOMPOSITION = 0x010D,
- WM_IME_ENDCOMPOSITION = 0x10E,
- WM_IME_COMPOSITION = 0x010F,
- WM_ACTIVATE = 0x0006,
- WM_NCMOUSEMOVE = 0x00A0,
- WM_NCLBUTTONDOWN = 0x00A1,
- WM_NCLBUTTONUP = 0x00A2,
- WM_NCLBUTTONDBLCLK = 0x00A3,
- WM_NCRBUTTONDOWN = 0x00A4,
- WM_NCRBUTTONUP = 0x00A5,
- WM_NCRBUTTONDBLCLK = 0x00A6,
- WM_NCMBUTTONDOWN = 0x00A7,
- WM_NCMBUTTONUP = 0x00A8,
- WM_NCMBUTTONDBLCLK = 0x00A9,
- WM_NCXBUTTONDOWN = 0x00AB,
- WM_NCXBUTTONUP = 0x00AC,
- WM_NCXBUTTONDBLCLK = 0x00AD,
- WM_MOUSEHOVER = 0x02A1,
- WM_MOUSELEAVE = 0x02A3,
- WM_MOUSEFIRST = 0x0200,
- WM_MOUSEACTIVATE = 0x0021,
- WM_LBUTTONDOWN = 0x0201,
- WM_LBUTTONUP = 0x0202,
- WM_LBUTTONDBLCLK = 0x0203,
- WM_RBUTTONDOWN = 0x0204,
- WM_RBUTTONUP = 0x0205,
- WM_RBUTTONDBLCLK = 0x0206,
- WM_MBUTTONDOWN = 0x0207,
- WM_MBUTTONUP = 0x0208,
- WM_MBUTTONDBLCLK = 0x0209,
- WM_NCMOUSEHOVER = 0x02A0,
- WM_NCMOUSELEAVE = 0x02A2,
- WM_MOUSEWHEEL = 0x020A,
- WM_MOUSELAST = 0x020A,
- WM_NCHITTEST = 0x0084,
- WM_SETCURSOR = 0x0020,
- WM_GETOBJECT = 0x003D,
- WM_CANCELMODE = 0x001F,
- WM_SETFOCUS = 0x0007,
- WM_KEYFIRST = 0x0100,
- WM_KEYDOWN = 0x0100,
- WM_KEYUP = 0x0101,
- WM_DEADCHAR = 0x0103,
- WM_SYSKEYDOWN = 0x0104,
- WM_SYSKEYUP = 0x0105,
- WM_SYSCHAR = 0x0106,
- WM_SYSDEADCHAR = 0x0107,
- WM_KEYLAST = 0x0108,
- WM_CONTEXTMENU = 0x007B,
- WM_PAINT = 0x000F,
- WM_PRINTCLIENT = 0x0318,
- WM_NCPAINT = 0x0085,
- WM_SIZE = 0x0005,
- WM_TIMER = 0x0113,
- WM_PRINT = 0x0317;
+ public const int DT_CALCRECT = 0x00000400;
+ public const int WS_DISABLED = 0x08000000;
+ public const int WS_CLIPSIBLINGS = 0x04000000;
+ public const int WS_CLIPCHILDREN = 0x02000000;
+ public const int WS_EX_TOOLWINDOW = 0x00000080;
+ public const int WS_POPUP = unchecked((int)0x80000000);
+ public const int WS_BORDER = 0x00800000;
+ public const int CS_DROPSHADOW = 0x00020000;
+ public const int CS_DBLCLKS = 0x0008;
+ public const int NOTSRCCOPY = 0x00330008;
+ public const int SRCCOPY = 0x00CC0020;
+ public const int LVM_SETCOLUMNWIDTH = 0x1000 + 30;
+ public const int LVM_GETHEADER = 0x1000 + 31;
+ public const int LVM_CREATEDRAGIMAGE = 0x1000 + 33;
+ public const int LVM_GETVIEWRECT = 0x1000 + 34;
+ public const int LVM_GETTEXTCOLOR = 0x1000 + 35;
+ public const int LVM_SETTEXTCOLOR = 0x1000 + 36;
+ public const int LVM_GETTEXTBKCOLOR = 0x1000 + 37;
+ public const int LVM_SETTEXTBKCOLOR = 0x1000 + 38;
+ public const int LVM_GETTOPINDEX = 0x1000 + 39;
+ public const int LVM_GETCOUNTPERPAGE = 0x1000 + 40;
+ public const int LVM_GETORIGIN = 0x1000 + 41;
+ public const int LVM_UPDATE = 0x1000 + 42;
+ public const int LVM_SETITEMSTATE = 0x1000 + 43;
+ public const int LVM_GETITEMSTATE = 0x1000 + 44;
+ public const int LVM_GETITEMTEXTA = 0x1000 + 45;
+ public const int LVM_GETITEMTEXTW = 0x1000 + 115;
+ public const int LVM_SETITEMTEXTA = 0x1000 + 46;
+ public const int LVM_SETITEMTEXTW = 0x1000 + 116;
+ public const int LVSICF_NOINVALIDATEALL = 0x00000001;
+ public const int LVSICF_NOSCROLL = 0x00000002;
+ public const int LVM_SETITEMCOUNT = 0x1000 + 47;
+ public const int LVM_SORTITEMS = 0x1000 + 48;
+ public const int LVM_SETITEMPOSITION32 = 0x1000 + 49;
+ public const int LVM_GETSELECTEDCOUNT = 0x1000 + 50;
+ public const int LVM_GETITEMSPACING = 0x1000 + 51;
+ public const int LVM_GETISEARCHSTRINGA = 0x1000 + 52;
+ public const int LVM_GETISEARCHSTRINGW = 0x1000 + 117;
+ public const int LVM_SETICONSPACING = 0x1000 + 53;
+ public const int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54;
+ public const int LVM_GETEXTENDEDLISTVIEWSTYLE = 0x1000 + 55;
+ public const int LVS_EX_GRIDLINES = 0x00000001;
+ public const int HDM_HITTEST = 0x1200 + 6;
+ public const int HDM_GETITEMRECT = 0x1200 + 7;
+ public const int HDM_SETIMAGELIST = 0x1200 + 8;
+ public const int HDM_GETIMAGELIST = 0x1200 + 9;
+ public const int HDM_ORDERTOINDEX = 0x1200 + 15;
+ public const int HDM_CREATEDRAGIMAGE = 0x1200 + 16;
+ public const int HDM_GETORDERARRAY = 0x1200 + 17;
+ public const int HDM_SETORDERARRAY = 0x1200 + 18;
+ public const int HDM_SETHOTDIVIDER = 0x1200 + 19;
+ public const int HDN_ITEMCHANGINGA = 0 - 300 - 0;
+ public const int HDN_ITEMCHANGINGW = 0 - 300 - 20;
+ public const int HDN_ITEMCHANGEDA = 0 - 300 - 1;
+ public const int HDN_ITEMCHANGEDW = 0 - 300 - 21;
+ public const int HDN_ITEMCLICKA = 0 - 300 - 2;
+ public const int HDN_ITEMCLICKW = 0 - 300 - 22;
+ public const int HDN_ITEMDBLCLICKA = 0 - 300 - 3;
+ public const int HDN_ITEMDBLCLICKW = 0 - 300 - 23;
+ public const int HDN_DIVIDERDBLCLICKA = 0 - 300 - 5;
+ public const int HDN_DIVIDERDBLCLICKW = 0 - 300 - 25;
+ public const int HDN_BEGINTRACKA = 0 - 300 - 6;
+ public const int HDN_BEGINTRACKW = 0 - 300 - 26;
+ public const int HDN_ENDTRACKA = 0 - 300 - 7;
+ public const int HDN_ENDTRACKW = 0 - 300 - 27;
+ public const int HDN_TRACKA = 0 - 300 - 8;
+ public const int HDN_TRACKW = 0 - 300 - 28;
+ public const int HDN_GETDISPINFOA = 0 - 300 - 9;
+ public const int HDN_GETDISPINFOW = 0 - 300 - 29;
+ public const int HDN_BEGINDRAG = 0 - 300 - 10;
+ public const int HDN_ENDDRAG = 0 - 300 - 11;
+ public const int HC_ACTION = 0;
+ public const int HIST_BACK = 0;
+ public const int HHT_ONHEADER = 0x0002;
+ public const int HHT_ONDIVIDER = 0x0004;
+ public const int HHT_ONDIVOPEN = 0x0008;
+ public const int HHT_ABOVE = 0x0100;
+ public const int HHT_BELOW = 0x0200;
+ public const int HHT_TORIGHT = 0x0400;
+ public const int HHT_TOLEFT = 0x0800;
+ public const int HWND_TOP = 0;
+ public const int HWND_BOTTOM = 1;
+ public const int HWND_TOPMOST = -1;
+ public const int HWND_NOTOPMOST = -2;
+ public const int CWP_SKIPINVISIBLE = 0x0001;
+ public const int RDW_FRAME = 0x0400;
+ public const int TVM_GETITEMRECT = 0x1100 + 4;
+ public const int TVM_GETCOUNT = 0x1100 + 5;
+ public const int TVM_GETINDENT = 0x1100 + 6;
+ public const int TVM_SETINDENT = 0x1100 + 7;
+ public const int TVM_GETIMAGELIST = 0x1100 + 8;
+ public const int TVSIL_NORMAL = 0;
+ public const int TVSIL_STATE = 2;
+ public const int TVM_SETIMAGELIST = 0x1100 + 9;
+ public const int TVM_GETNEXTITEM = 0x1100 + 10;
+ public const int TVGN_ROOT = 0x0000;
+ public const int TV_FIRST = 0x1100;
+ public const int TVM_SETEXTENDEDSTYLE = TV_FIRST + 44;
+ public const int TVM_GETEXTENDEDSTYLE = TV_FIRST + 45;
+ public const int TVS_EX_FADEINOUTEXPANDOS = 0x0040;
+ public const int TVS_EX_DOUBLEBUFFER = 0x0004;
+ public const int LVS_EX_DOUBLEBUFFER = 0x00010000;
+ public const int TVHT_ONITEMICON = 0x0002;
+ public const int TVHT_ONITEMLABEL = 0x0004;
+ public const int TVHT_ONITEMINDENT = 0x0008;
+ public const int TVHT_ONITEMBUTTON = 0x0010;
+ public const int TVHT_ONITEMRIGHT = 0x0020;
+ public const int TVHT_ONITEMSTATEICON = 0x0040;
+ public const int TVHT_ABOVE = 0x0100;
+ public const int TVHT_BELOW = 0x0200;
+ public const int TVHT_TORIGHT = 0x0400;
+ public const int TVHT_TOLEFT = 0x0800;
+ public const int GW_HWNDFIRST = 0;
+ public const int GW_HWNDLAST = 1;
+ public const int GW_HWNDNEXT = 2;
+ public const int GW_HWNDPREV = 3;
+ public const int GW_OWNER = 4;
+ public const int GW_CHILD = 5;
+ public const int GW_MAX = 5;
+ public const int GWL_HWNDPARENT = -8;
+ public const int SB_HORZ = 0;
+ public const int SB_VERT = 1;
+ public const int SB_CTL = 2;
+ public const int SB_BOTH = 3;
+ public const int SB_LINEUP = 0;
+ public const int SB_LINELEFT = 0;
+ public const int SB_LINEDOWN = 1;
+ public const int SB_LINERIGHT = 1;
+ public const int SB_PAGEUP = 2;
+ public const int SB_PAGELEFT = 2;
+ public const int SB_PAGEDOWN = 3;
+ public const int SB_PAGERIGHT = 3;
+ public const int SB_THUMBPOSITION = 4;
+ public const int SB_THUMBTRACK = 5;
+ public const int SB_TOP = 6;
+ public const int SB_LEFT = 6;
+ public const int SB_BOTTOM = 7;
+ public const int SB_RIGHT = 7;
+ public const int SB_ENDSCROLL = 8;
+ public const int MK_LBUTTON = 0x0001;
+ public const int TVM_HITTEST = 0x1100 + 17;
+ public const int MK_RBUTTON = 0x0002;
+ public const int MK_SHIFT = 0x0004;
+ public const int MK_CONTROL = 0x0008;
+ public const int MK_MBUTTON = 0x0010;
+ public const int MK_XBUTTON1 = 0x0020;
+ public const int MK_XBUTTON2 = 0x0040;
+ public const int LB_ADDSTRING = 0x0180;
+ public const int LB_INSERTSTRING = 0x0181;
+ public const int LB_DELETESTRING = 0x0182;
+ public const int LB_SELITEMRANGEEX = 0x0183;
+ public const int LB_RESETCONTENT = 0x0184;
+ public const int LB_SETSEL = 0x0185;
+ public const int LB_SETCURSEL = 0x0186;
+ public const int LB_GETSEL = 0x0187;
+ public const int LB_GETCURSEL = 0x0188;
+ public const int LB_GETTEXT = 0x0189;
+ public const int LB_GETTEXTLEN = 0x018A;
+ public const int LB_GETCOUNT = 0x018B;
+ public const int LB_SELECTSTRING = 0x018C;
+ public const int LB_DIR = 0x018D;
+ public const int LB_GETTOPINDEX = 0x018E;
+ public const int LB_FINDSTRING = 0x018F;
+ public const int LB_GETSELCOUNT = 0x0190;
+ public const int LB_GETSELITEMS = 0x0191;
+ public const int LB_SETTABSTOPS = 0x0192;
+ public const int LB_GETHORIZONTALEXTENT = 0x0193;
+ public const int LB_SETHORIZONTALEXTENT = 0x0194;
+ public const int LB_SETCOLUMNWIDTH = 0x0195;
+ public const int LB_ADDFILE = 0x0196;
+ public const int LB_SETTOPINDEX = 0x0197;
+ public const int LB_GETITEMRECT = 0x0198;
+ public const int LB_GETITEMDATA = 0x0199;
+ public const int LB_SETITEMDATA = 0x019A;
+ public const int LB_SELITEMRANGE = 0x019B;
+ public const int LB_SETANCHORINDEX = 0x019C;
+ public const int LB_GETANCHORINDEX = 0x019D;
+ public const int LB_SETCARETINDEX = 0x019E;
+ public const int LB_GETCARETINDEX = 0x019F;
+ public const int LB_SETITEMHEIGHT = 0x01A0;
+ public const int LB_GETITEMHEIGHT = 0x01A1;
+ public const int LB_FINDSTRINGEXACT = 0x01A2;
+ public const int LB_SETLOCALE = 0x01A5;
+ public const int LB_GETLOCALE = 0x01A6;
+ public const int LB_SETCOUNT = 0x01A7;
+ public const int LB_INITSTORAGE = 0x01A8;
+ public const int LB_ITEMFROMPOINT = 0x01A9;
+ public const int LB_MSGMAX = 0x01B0;
+ public const int HTHSCROLL = 6;
+ public const int HTVSCROLL = 7;
+ public const int HTERROR = -2;
+ public const int HTTRANSPARENT = -1;
+ public const int HTNOWHERE = 0;
+ public const int HTCLIENT = 1;
+ public const int HTCAPTION = 2;
+ public const int HTSYSMENU = 3;
+ public const int HTGROWBOX = 4;
+ public const int HTSIZE = 4;
+ public const int PRF_NONCLIENT = 0x00000002;
+ public const int PRF_CLIENT = 0x00000004;
+ public const int PRF_ERASEBKGND = 0x00000008;
+ public const int PRF_CHILDREN = 0x00000010;
+ public const int SWP_NOSIZE = 0x0001;
+ public const int SWP_NOMOVE = 0x0002;
+ public const int SWP_NOZORDER = 0x0004;
+ public const int SWP_NOREDRAW = 0x0008;
+ public const int SWP_NOACTIVATE = 0x0010;
+ public const int SWP_FRAMECHANGED = 0x0020;
+ public const int SWP_SHOWWINDOW = 0x0040;
+ public const int SWP_HIDEWINDOW = 0x0080;
+ public const int SWP_NOCOPYBITS = 0x0100;
+ public const int SWP_NOOWNERZORDER = 0x0200;
+ public const int SWP_NOSENDCHANGING = 0x0400;
+ public const int SWP_DRAWFRAME = 0x0020;
+ public const int SWP_NOREPOSITION = 0x0200;
+ public const int SWP_DEFERERASE = 0x2000;
+ public const int SWP_ASYNCWINDOWPOS = 0x4000;
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern IntPtr GetCursor();
@@ -4404,8 +4308,7 @@ public static extern string QueryPathOfRegTypeLib(ref Guid guid, short majorVers
public const int MWMO_INPUTAVAILABLE = 0x0004; // don't use MWMO_WAITALL, see ddb#176342
public const int GWL_EXSTYLE = -20,
- GWL_STYLE = -16,
- WS_EX_LAYOUTRTL = 0x00400000;
+ GWL_STYLE = -16;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class LOGFONT
@@ -4537,7 +4440,7 @@ public sealed class CommonHandles
[StructLayout(LayoutKind.Sequential)]
public class NONCLIENTMETRICS
{
- public int cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS));
+ public int cbSize = Marshal.SizeOf();
public int iBorderWidth = 0;
public int iScrollWidth = 0;
public int iScrollHeight = 0;
@@ -4567,5 +4470,7 @@ public class NONCLIENTMETRICS
//SendMessage(IntPtr, int, bool, IntPtr), SendMessage(IntPtr, int, IntPtr, ListViewCompareCallback),
//SendMessageW, SendMessageA, ValidateRect(IntPtr, ref RECT), ValidateRgn(IntPtr, IntPtr)
//COMRECT.FromXYWH, RECT.FromXYWH
+
+ public const int MAX_PATH = 260;
}
}
diff --git a/src/System.Windows.Forms.Design.Editors/src/Misc/UnsafeNativeMethods.cs b/src/System.Windows.Forms.Design.Editors/src/Misc/UnsafeNativeMethods.cs
index 35be9d218dc..6a460e95af4 100644
--- a/src/System.Windows.Forms.Design.Editors/src/Misc/UnsafeNativeMethods.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/Misc/UnsafeNativeMethods.cs
@@ -158,102 +158,6 @@ public static IntPtr SetWindowLong(HandleRef hWnd, int nIndex, HandleRef dwNewLo
[DllImport(ExternDll.Ole32, PreserveSig = false)]
public static extern IStorage StgCreateDocfileOnILockBytes(ILockBytes iLockBytes, int grfMode, int reserved);
- [Flags]
- public enum BrowseInfos
- {
- // Browsing for directory.
- ReturnOnlyFSDirs = 0x0001, // For finding a folder to start document searching
- DontGoBelowDomain = 0x0002, // For starting the Find Computer
- StatusText = 0x0004, // Top of the dialog has 2 lines of text for BROWSEINFO.lpszTitle and one line if
-
- // this flag is set. Passing the message BFFM_SETSTATUSTEXTA to the hwnd can set the
- // rest of the text. This is not used with USENEWUI and BROWSEINFO.lpszTitle gets
- // all three lines of text.
- ReturnFSAncestors = 0x0008,
- EditBox = 0x0010, // Add an editbox to the dialog
- Validate = 0x0020, // insist on valid result (or CANCEL)
-
- NewDialogStyle = 0x0040, // Use the new dialog layout with the ability to resize
- // Caller needs to call OleInitialize() before using this API
-
- UseNewUI = NewDialogStyle | EditBox,
-
- AllowUrls = 0x0080, // Allow URLs to be displayed or entered. (Requires USENEWUI)
-
- BrowseForComputer = 0x1000, // Browsing for Computers.
- BrowseForPrinter = 0x2000, // Browsing for Printers
- BrowseForEverything = 0x4000, // Browsing for Everything
- ShowShares = 0x8000 // sharable resources displayed (remote shares, requires USENEWUI)
- }
-
- [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
- [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- public class BROWSEINFO
- {
- public IntPtr hwndOwner; //HWND hwndOwner; // HWND of the owner for the dialog
-
- public int
- iImage; //int iImage; // output var: where to return the Image index.
-
- public IntPtr
- lParam; //LPARAM lParam; // extra info that's passed back in callbacks
-
- public IntPtr lpfn; //BFFCALLBACK lpfn; // Call back pointer
-
- public string lpszTitle; //LPCWSTR lpszTitle; // text to go in the banner over the tree.
- public IntPtr pidlRoot; //LPCITEMIDLIST pidlRoot; // Root ITEMIDLIST
-
- // For interop purposes, send over a buffer of MAX_PATH size.
- public IntPtr pszDisplayName; //LPWSTR pszDisplayName; // Return display name of item selected.
- public int ulFlags; //UINT ulFlags; // Flags that control the return stuff
- }
-
- public class Shell32
- {
- [DllImport(ExternDll.Shell32)]
- public static extern int SHGetSpecialFolderLocation(IntPtr hwnd, int csidl, ref IntPtr ppidl);
- //SHSTDAPI SHGetSpecialFolderLocation(HWND hwnd, int csidl, LPITEMIDLIST *ppidl);
-
- [DllImport(ExternDll.Shell32, CharSet = CharSet.Auto)]
- public static extern bool SHGetPathFromIDList(IntPtr pidl, IntPtr pszPath);
- //SHSTDAPI_(BOOL) SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath);
-
- [DllImport(ExternDll.Shell32, CharSet = CharSet.Auto)]
- public static extern IntPtr SHBrowseForFolder([In] BROWSEINFO lpbi);
- //SHSTDAPI_(LPITEMIDLIST) SHBrowseForFolderW(LPBROWSEINFOW lpbi);
-
- [DllImport(ExternDll.Shell32)]
- public static extern int SHGetMalloc([Out] [MarshalAs(UnmanagedType.LPArray)]
- IMalloc[] ppMalloc);
-
- //SHSTDAPI SHGetMalloc(LPMALLOC * ppMalloc);
- }
-
- [ComImport]
- [Guid("00000002-0000-0000-c000-000000000046")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IMalloc
- {
- [PreserveSig]
- IntPtr Alloc(int cb);
-
- [PreserveSig]
- IntPtr Realloc(IntPtr pv, int cb);
-
- [PreserveSig]
- void Free(IntPtr pv);
-
- [PreserveSig]
- int GetSize(IntPtr pv);
-
- [PreserveSig]
- int DidAlloc(IntPtr pv);
-
- [PreserveSig]
- void HeapMinimize();
- }
-
[SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
diff --git a/src/System.Windows.Forms.Design.Editors/src/System.Windows.Forms.Design.Editors.csproj b/src/System.Windows.Forms.Design.Editors/src/System.Windows.Forms.Design.Editors.csproj
index b88f35ba5d7..faf835a797f 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System.Windows.Forms.Design.Editors.csproj
+++ b/src/System.Windows.Forms.Design.Editors/src/System.Windows.Forms.Design.Editors.csproj
@@ -6,6 +6,7 @@
true
true
true
+ true
@@ -29,6 +30,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/CollectionEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/CollectionEditor.cs
index 223e5692663..33ded7c7d34 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/CollectionEditor.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/CollectionEditor.cs
@@ -2310,7 +2310,7 @@ protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
- case NativeMethods.WM_KEYDOWN:
+ case Interop.WindowMessages.WM_KEYDOWN:
_lastKeyDown = m;
// the first thing the ime does on a key it cares about is send a VK_PROCESSKEY, so we use that to sling focus to the grid.
@@ -2330,12 +2330,12 @@ protected override void WndProc(ref Message m)
if (PropertyGrid.Focused || PropertyGrid.ContainsFocus)
{
// recreate the keystroke to the newly activated window
- NativeMethods.SendMessage(UnsafeNativeMethods.GetFocus(), NativeMethods.WM_KEYDOWN, _lastKeyDown.WParam, _lastKeyDown.LParam);
+ NativeMethods.SendMessage(UnsafeNativeMethods.GetFocus(), Interop.WindowMessages.WM_KEYDOWN, _lastKeyDown.WParam, _lastKeyDown.LParam);
}
}
break;
- case NativeMethods.WM_CHAR:
+ case Interop.WindowMessages.WM_CHAR:
if ((Control.ModifierKeys & (Keys.Control | Keys.Alt)) != 0)
{
@@ -2357,8 +2357,8 @@ protected override void WndProc(ref Message m)
if (PropertyGrid.Focused || PropertyGrid.ContainsFocus)
{
IntPtr hWnd = UnsafeNativeMethods.GetFocus();
- NativeMethods.SendMessage(hWnd, NativeMethods.WM_KEYDOWN, _lastKeyDown.WParam, _lastKeyDown.LParam);
- NativeMethods.SendMessage(hWnd, NativeMethods.WM_CHAR, m.WParam, m.LParam);
+ NativeMethods.SendMessage(hWnd, Interop.WindowMessages.WM_KEYDOWN, _lastKeyDown.WParam, _lastKeyDown.LParam);
+ NativeMethods.SendMessage(hWnd, Interop.WindowMessages.WM_CHAR, m.WParam, m.LParam);
return;
}
break;
diff --git a/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/ObjectSelectorEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/ObjectSelectorEditor.cs
index 1f16aa9beb9..d2809cb5cfd 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/ObjectSelectorEditor.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/System/ComponentModel/Design/ObjectSelectorEditor.cs
@@ -79,7 +79,7 @@ public static void ApplyTreeViewThemeStyles(TreeView treeView)
{
if (treeView == null)
{
- throw new ArgumentNullException("treeView");
+ throw new ArgumentNullException(nameof(treeView));
}
treeView.HotTracking = true;
@@ -314,17 +314,17 @@ protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
- case NativeMethods.WM_GETDLGCODE:
+ case Interop.WindowMessages.WM_GETDLGCODE:
m.Result = (IntPtr)((long)m.Result | NativeMethods.DLGC_WANTALLKEYS);
return;
- case NativeMethods.WM_MOUSEMOVE:
+ case Interop.WindowMessages.WM_MOUSEMOVE:
if (clickSeen)
{
clickSeen = false;
}
break;
- case NativeMethods.WM_REFLECT + NativeMethods.WM_NOTIFY:
- NativeMethods.NMTREEVIEW nmtv = (NativeMethods.NMTREEVIEW)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NMTREEVIEW));
+ case Interop.WindowMessages.WM_REFLECT + Interop.WindowMessages.WM_NOTIFY:
+ NativeMethods.NMTREEVIEW nmtv = Marshal.PtrToStructure(m.LParam);
if (nmtv.nmhdr.code == NativeMethods.NM_CLICK)
{
clickSeen = true;
diff --git a/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/ColorEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/ColorEditor.cs
index 669e7d7cdf9..da63b372f60 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/ColorEditor.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/ColorEditor.cs
@@ -1113,13 +1113,13 @@ protected override IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr l
{
switch (msg)
{
- case NativeMethods.WM_INITDIALOG:
- NativeMethods.SendDlgItemMessage(hwnd, COLOR_HUE, NativeMethods.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
- NativeMethods.SendDlgItemMessage(hwnd, COLOR_SAT, NativeMethods.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
- NativeMethods.SendDlgItemMessage(hwnd, COLOR_LUM, NativeMethods.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
- NativeMethods.SendDlgItemMessage(hwnd, COLOR_RED, NativeMethods.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
- NativeMethods.SendDlgItemMessage(hwnd, COLOR_GREEN, NativeMethods.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
- NativeMethods.SendDlgItemMessage(hwnd, COLOR_BLUE, NativeMethods.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
+ case Interop.WindowMessages.WM_INITDIALOG:
+ NativeMethods.SendDlgItemMessage(hwnd, COLOR_HUE, Interop.EditMessages.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
+ NativeMethods.SendDlgItemMessage(hwnd, COLOR_SAT, Interop.EditMessages.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
+ NativeMethods.SendDlgItemMessage(hwnd, COLOR_LUM, Interop.EditMessages.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
+ NativeMethods.SendDlgItemMessage(hwnd, COLOR_RED, Interop.EditMessages.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
+ NativeMethods.SendDlgItemMessage(hwnd, COLOR_GREEN, Interop.EditMessages.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
+ NativeMethods.SendDlgItemMessage(hwnd, COLOR_BLUE, Interop.EditMessages.EM_SETMARGINS, (IntPtr)(NativeMethods.EC_LEFTMARGIN | NativeMethods.EC_RIGHTMARGIN), IntPtr.Zero);
IntPtr hwndCtl = NativeMethods.GetDlgItem(hwnd, COLOR_MIX);
NativeMethods.EnableWindow(hwndCtl, false);
NativeMethods.SetWindowPos(hwndCtl, IntPtr.Zero, 0, 0, 0, 0, NativeMethods.SWP_HIDEWINDOW);
@@ -1128,7 +1128,7 @@ protected override IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr l
NativeMethods.SetWindowPos(hwndCtl, IntPtr.Zero, 0, 0, 0, 0, NativeMethods.SWP_HIDEWINDOW);
this.Color = Color.Empty;
break;
- case NativeMethods.WM_COMMAND:
+ case Interop.WindowMessages.WM_COMMAND:
switch (NativeMethods.Util.LOWORD(unchecked((int)(long)wParam)))
{
case COLOR_ADD:
@@ -1141,7 +1141,7 @@ protected override IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr l
blue = (byte)NativeMethods.GetDlgItemInt(hwnd, COLOR_BLUE, err, false);
Debug.Assert(!err[0], "Couldn't find dialog member COLOR_BLUE");
this.Color = Color.FromArgb(red, green, blue);
- NativeMethods.PostMessage(hwnd, NativeMethods.WM_COMMAND, (IntPtr)NativeMethods.Util.MAKELONG(NativeMethods.IDOK, 0), NativeMethods.GetDlgItem(hwnd, NativeMethods.IDOK));
+ NativeMethods.PostMessage(hwnd, Interop.WindowMessages.WM_COMMAND, (IntPtr)NativeMethods.Util.MAKELONG(NativeMethods.IDOK, 0), NativeMethods.GetDlgItem(hwnd, NativeMethods.IDOK));
break;
}
break;
diff --git a/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/FontEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/FontEditor.cs
index 1556e9aa5dd..434f0a683c6 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/FontEditor.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/System/Drawing/Design/FontEditor.cs
@@ -11,53 +11,42 @@
namespace System.Drawing.Design
{
///
- /// Provides a font editor that
- /// is used to visually select and configure a Font
- /// object.
+ /// Provides a font editor that is used to visually select and configure a Font object.
///
[CLSCompliant(false)]
public class FontEditor : UITypeEditor
{
- private FontDialog fontDialog;
- private object value;
+ private FontDialog _fontDialog;
///
- /// Edits the given object value using the editor style provided by
- /// GetEditorStyle. A service provider is provided so that any
- /// required editing services can be obtained.
+ /// Edits the given object value using the editor style provided by GetEditorStyle.
+ /// A service provider is provided so that any required editing services can be obtained.
///
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
- this.value = value;
-
- Debug.Assert(provider != null, "No service provider; we cannot edit the value");
if (provider != null)
{
- IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
-
- Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
- if (edSvc != null)
+ if (provider.GetService(typeof(IWindowsFormsEditorService)) is IWindowsFormsEditorService edSvc)
{
- if (fontDialog == null)
+ if (_fontDialog == null)
{
- fontDialog = new FontDialog();
- fontDialog.ShowApply = false;
- fontDialog.ShowColor = false;
- fontDialog.AllowVerticalFonts = false;
+ _fontDialog = new FontDialog();
+ _fontDialog.ShowApply = false;
+ _fontDialog.ShowColor = false;
+ _fontDialog.AllowVerticalFonts = false;
}
- Font fontvalue = value as Font;
- if (fontvalue != null)
+ if (value is Font fontValue)
{
- fontDialog.Font = fontvalue;
+ _fontDialog.Font = fontValue;
}
IntPtr hwndFocus = UnsafeNativeMethods.GetFocus();
try
{
- if (fontDialog.ShowDialog() == DialogResult.OK)
+ if (_fontDialog.ShowDialog() == DialogResult.OK)
{
- this.value = fontDialog.Font;
+ return _fontDialog.Font;
}
}
finally
@@ -70,16 +59,11 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
}
}
- // Now pull out the updated value, if there was one.
- value = this.value;
- this.value = null;
-
return value;
}
///
- /// Retrieves the editing style of the Edit method. If the method
- /// is not supported, this will return None.
+ /// Retrieves the editing style of the Edit method.false
///
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
@@ -87,4 +71,3 @@ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext contex
}
}
}
-
diff --git a/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FileNameEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FileNameEditor.cs
index ba9202bf67c..e6e75c10d09 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FileNameEditor.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FileNameEditor.cs
@@ -2,49 +2,45 @@
// 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.ComponentModel;
-using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing.Design;
namespace System.Windows.Forms.Design
{
/// >
- /// Provides an
- /// editor for filenames.
+ /// Provides an editor for filenames.
///
[CLSCompliant(false)]
public class FileNameEditor : UITypeEditor
{
- private OpenFileDialog openFileDialog;
+ private OpenFileDialog _openFileDialog;
///
- /// Edits the given object value using the editor style provided by
- /// GetEditorStyle. A service provider is provided so that any
- /// required editing services can be obtained.
+ /// Edits the given object value using the editor style provided by GetEditorStyle.
+ /// A service provider is provided so that any required editing services can be obtained.
///
- [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
- Debug.Assert(provider != null, "No service provider; we cannot edit the value");
if (provider != null)
{
- IWindowsFormsEditorService edSvc =
- (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
-
- Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
- if (edSvc != null)
+ if (provider.GetService(typeof(IWindowsFormsEditorService)) is IWindowsFormsEditorService edSvc)
{
- if (openFileDialog == null)
+ if (_openFileDialog == null)
{
- openFileDialog = new OpenFileDialog();
- InitializeDialog(openFileDialog);
+ _openFileDialog = new OpenFileDialog();
+ InitializeDialog(_openFileDialog);
}
- if (value is string) openFileDialog.FileName = (string)value;
+ if (value is string stringValue)
+ {
+ _openFileDialog.FileName = stringValue;
+ }
- if (openFileDialog.ShowDialog() == DialogResult.OK) value = openFileDialog.FileName;
+ if (_openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ return _openFileDialog.FileName;
+ }
}
}
@@ -52,24 +48,26 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
}
/// >
- /// Gets the editing style of the Edit method. If the method
- /// is not supported, this will return None.
+ /// Gets the editing style of the Edit method.
///
- [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
- // everything in this assembly is full trust.
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
///
- /// Initializes the open file dialog when it is created. This gives you
- /// an opportunity to configure the dialog as you please. The default
- /// implementation provides a generic file filter and title.
+ /// Initializes the open file dialog when it is created. This gives you an opportunity to
+ /// configure the dialog as you please. The default implementation provides a generic file
+ /// filter and title.
///
[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
protected virtual void InitializeDialog(OpenFileDialog openFileDialog)
{
+ if (openFileDialog == null)
+ {
+ throw new ArgumentNullException(nameof(openFileDialog));
+ }
+
openFileDialog.Filter = SR.GenericFileFilter;
openFileDialog.Title = SR.GenericOpenFile;
}
diff --git a/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FolderNameEditor.cs b/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FolderNameEditor.cs
index 536ddeef48e..0604d42fe56 100644
--- a/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FolderNameEditor.cs
+++ b/src/System.Windows.Forms.Design.Editors/src/System/Windows/Forms/Design/FolderNameEditor.cs
@@ -2,51 +2,49 @@
// 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.Buffers;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Drawing.Design;
using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
namespace System.Windows.Forms.Design
{
/// >
- /// Provides an editor
- /// for choosing a folder from the filesystem.
+ /// Provides an editor for choosing a folder from the filesystem.
///
[CLSCompliant(false)]
public class FolderNameEditor : UITypeEditor
{
- private FolderBrowser folderBrowser;
+ private FolderBrowser _folderBrowser;
- [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
- if (folderBrowser == null)
+ if (_folderBrowser == null)
{
- folderBrowser = new FolderBrowser();
- InitializeDialog(folderBrowser);
+ _folderBrowser = new FolderBrowser();
+ InitializeDialog(_folderBrowser);
}
- if (folderBrowser.ShowDialog() != DialogResult.OK) return value;
+ if (_folderBrowser.ShowDialog() == DialogResult.OK)
+ {
+ return _folderBrowser.DirectoryPath;
+ }
- return folderBrowser.DirectoryPath;
+ return value;
}
///
- /// Retrieves the editing style of the Edit method. If the method
- /// is not supported, this will return None.
- ///
- [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
- // everything in this assembly is full trust.
+ /// Retrieves the editing style of the Edit method.
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
///
- /// Initializes the folder browser dialog when it is created. This gives you
- /// an opportunity to configure the dialog as you please. The default
- /// implementation provides a generic folder browser.
+ /// Initializes the folder browser dialog when it is created. This gives you an opportunity
+ /// to configure the dialog as you please. The default implementation provides a generic folder browser.
///
protected virtual void InitializeDialog(FolderBrowser folderBrowser)
{
@@ -54,128 +52,100 @@ protected virtual void InitializeDialog(FolderBrowser folderBrowser)
protected sealed class FolderBrowser : Component
{
- private static readonly int MAX_PATH = 260;
-
// Description text to show.
- private string descriptionText = string.Empty;
-
- // Folder picked by the user.
- private readonly UnsafeNativeMethods.BrowseInfos privateOptions =
- UnsafeNativeMethods.BrowseInfos.NewDialogStyle;
+ private string _descriptionText = string.Empty;
///
- /// The styles the folder browser will use when browsing
- /// folders. This should be a combination of flags from
- /// the FolderBrowserStyles enum.
+ /// The styles the folder browser will use when browsing
+ /// folders. This should be a combination of flags from
+ /// the FolderBrowserStyles enum.
///
public FolderBrowserStyles Style { get; set; } = FolderBrowserStyles.RestrictToFilesystem;
///
- /// Gets the directory path of the folder the user picked.
+ /// Gets the directory path of the folder the user picked.
///
public string DirectoryPath { get; private set; } = string.Empty;
///
- /// Gets/sets the start location of the root node.
+ /// Gets/sets the start location of the root node.
///
public FolderBrowserFolder StartLocation { get; set; } = FolderBrowserFolder.Desktop;
/// >
- /// Gets or sets a description to show above the folders. Here you can provide instructions for
- /// selecting a folder.
+ /// Gets or sets a description to show above the folders. Here you can provide instructions for
+ /// selecting a folder.
///
public string Description
{
- get => descriptionText;
- set => descriptionText = value == null ? string.Empty : value;
- }
-
- ///
- /// Helper function that returns the IMalloc interface used by the shell.
- ///
- private static UnsafeNativeMethods.IMalloc GetSHMalloc()
- {
- UnsafeNativeMethods.IMalloc[] malloc = new UnsafeNativeMethods.IMalloc[1];
-
- UnsafeNativeMethods.Shell32.SHGetMalloc(malloc);
-
- return malloc[0];
+ get => _descriptionText;
+ set => _descriptionText = value ?? string.Empty;
}
///
- /// Shows the folder browser dialog.
+ /// Shows the folder browser dialog.
///
- public DialogResult ShowDialog()
- {
- return ShowDialog(null);
- }
+ public DialogResult ShowDialog() => ShowDialog(null);
///
- /// Shows the folder browser dialog with the specified owner.
+ /// Shows the folder browser dialog with the specified owner.
///
- public DialogResult ShowDialog(IWin32Window owner)
+ public unsafe DialogResult ShowDialog(IWin32Window owner)
{
- IntPtr pidlRoot = IntPtr.Zero;
-
// Get/find an owner HWND for this dialog
- IntPtr hWndOwner;
-
- if (owner != null)
- hWndOwner = owner.Handle;
- else
- hWndOwner = UnsafeNativeMethods.GetActiveWindow();
+ IntPtr hWndOwner = owner == null ? owner.Handle : UnsafeNativeMethods.GetActiveWindow();
// Get the IDL for the specific startLocation
- UnsafeNativeMethods.Shell32.SHGetSpecialFolderLocation(hWndOwner, (int)StartLocation, ref pidlRoot);
-
- if (pidlRoot == IntPtr.Zero) return DialogResult.Cancel;
-
- int mergedOptions = (int)Style | (int)privateOptions;
-
- if ((mergedOptions & (int)UnsafeNativeMethods.BrowseInfos.NewDialogStyle) != 0)
- Application.OleRequired();
-
- IntPtr pidlRet = IntPtr.Zero;
-
- try
+ CoTaskMemSafeHandle listHandle;
+ Interop.Shell32.SHGetSpecialFolderLocation(hWndOwner, (int)StartLocation, out listHandle);
+ if (listHandle.IsInvalid)
{
- // Construct a BROWSEINFO
- UnsafeNativeMethods.BROWSEINFO bi = new UnsafeNativeMethods.BROWSEINFO();
-
- IntPtr buffer = Marshal.AllocHGlobal(MAX_PATH);
-
- bi.pidlRoot = pidlRoot;
- bi.hwndOwner = hWndOwner;
- bi.pszDisplayName = buffer;
- bi.lpszTitle = descriptionText;
- bi.ulFlags = mergedOptions;
- bi.lpfn = IntPtr.Zero;
- bi.lParam = IntPtr.Zero;
- bi.iImage = 0;
-
- // And show the dialog
- pidlRet = UnsafeNativeMethods.Shell32.SHBrowseForFolder(bi);
-
- if (pidlRet == IntPtr.Zero) return DialogResult.Cancel;
-
- // Then retrieve the path from the IDList
- UnsafeNativeMethods.Shell32.SHGetPathFromIDList(pidlRet, buffer);
-
- // Convert to a string
- DirectoryPath = Marshal.PtrToStringAuto(buffer);
-
- // Then free all the stuff we've allocated or the SH API gave us
- Marshal.FreeHGlobal(buffer);
+ return DialogResult.Cancel;
}
- finally
- {
- UnsafeNativeMethods.IMalloc malloc = GetSHMalloc();
- malloc.Free(pidlRoot);
- if (pidlRet != IntPtr.Zero) malloc.Free(pidlRet);
+ using (listHandle)
+ {
+ uint mergedOptions = (uint)Style | Interop.Shell32.BrowseInfoFlags.BIF_NEWDIALOGSTYLE;
+ if ((mergedOptions & (int)Interop.Shell32.BrowseInfoFlags.BIF_NEWDIALOGSTYLE) != 0)
+ {
+ Application.OleRequired();
+ }
+
+ char[] displayName = ArrayPool.Shared.Rent(Interop.Kernel32.MAX_PATH + 1);
+ try
+ {
+ fixed (char *pDisplayName = displayName)
+ {
+ var bi = new Interop.Shell32.BROWSEINFO();
+ bi.pidlRoot = listHandle;
+ bi.hwndOwner = hWndOwner;
+ bi.pszDisplayName = pDisplayName;
+ bi.lpszTitle = _descriptionText;
+ bi.ulFlags = mergedOptions;
+ bi.lpfn = null;
+ bi.lParam = IntPtr.Zero;
+ bi.iImage = 0;
+
+ // Show the dialog.
+ using (CoTaskMemSafeHandle browseHandle = Interop.Shell32.SHBrowseForFolderW(ref bi))
+ {
+ if (browseHandle.IsInvalid)
+ {
+ return DialogResult.Cancel;
+ }
+
+ // Retrieve the path from the IDList.
+ Interop.Shell32.SHGetPathFromIDListLongPath(browseHandle.DangerousGetHandle(), out string selectedPath);
+ DirectoryPath = selectedPath;
+ return DialogResult.OK;
+ }
+ }
+ }
+ finally
+ {
+ ArrayPool.Shared.Return(displayName);
+ }
}
-
- return DialogResult.OK;
}
}
@@ -209,19 +179,19 @@ protected enum FolderBrowserFolder
[Flags]
protected enum FolderBrowserStyles
{
- BrowseForComputer = UnsafeNativeMethods.BrowseInfos.BrowseForComputer,
+ BrowseForComputer = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_BROWSEFORCOMPUTER),
- BrowseForEverything = UnsafeNativeMethods.BrowseInfos.BrowseForEverything,
+ BrowseForEverything = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_BROWSEFOREVERYTHING),
- BrowseForPrinter = UnsafeNativeMethods.BrowseInfos.BrowseForPrinter,
+ BrowseForPrinter = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_BROWSEFORPRINTER),
- RestrictToDomain = UnsafeNativeMethods.BrowseInfos.DontGoBelowDomain,
+ RestrictToDomain = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_DONTGOBELOWDOMAIN),
- RestrictToFilesystem = UnsafeNativeMethods.BrowseInfos.ReturnOnlyFSDirs,
+ RestrictToFilesystem = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_RETURNONLYFSDIRS),
- RestrictToSubfolders = UnsafeNativeMethods.BrowseInfos.ReturnFSAncestors,
+ RestrictToSubfolders = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_RETURNFSANCESTORS),
- ShowTextBox = UnsafeNativeMethods.BrowseInfos.EditBox
+ ShowTextBox = unchecked((int)Interop.Shell32.BrowseInfoFlags.BIF_EDITBOX)
}
}
}
diff --git a/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System.Windows.Forms.Design.Editors.Tests.csproj b/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System.Windows.Forms.Design.Editors.Tests.csproj
index 1a2ad4a14fe..8ace057cbed 100644
--- a/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System.Windows.Forms.Design.Editors.Tests.csproj
+++ b/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System.Windows.Forms.Design.Editors.Tests.csproj
@@ -13,6 +13,8 @@
+
+
diff --git a/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs b/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs
new file mode 100644
index 00000000000..c2df2d47220
--- /dev/null
+++ b/src/System.Windows.Forms.Design.Editors/tests/UnitTests/System/Drawing/Design/FontEditorTests.cs
@@ -0,0 +1,47 @@
+// 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.Collections.Generic;
+using System.Windows.Forms.Design;
+using Moq;
+using Xunit;
+
+namespace System.Drawing.Design.Tests
+{
+ public class FontEditorTests
+ {
+ public static IEnumerable