├── .gitattributes ├── .gitignore ├── AutoClosingMessageBox.Core.sln ├── AutoClosingMessageBox.NET.Win.sln ├── AutoClosingMessageBox.NET.Wpf.sln ├── AutoClosingMessageBox.NET8.Win.sln ├── AutoClosingMessageBox.NET8.Wpf.sln ├── AutoClosingMessageBox.Net3.5.sln ├── AutoClosingMessageBox.Net5.Win.sln ├── AutoClosingMessageBox.Net5.Wpf.sln ├── AutoClosingMessageBox.sln ├── AutoClosingMessageBox ├── AutoClosingMessageBox.Core.csproj ├── AutoClosingMessageBox.NET.Win.csproj ├── AutoClosingMessageBox.NET.Wpf.csproj ├── AutoClosingMessageBox.NET8.Win.csproj ├── AutoClosingMessageBox.NET8.Wpf.csproj ├── AutoClosingMessageBox.Net3.5.csproj ├── AutoClosingMessageBox.Net5.Win.csproj ├── AutoClosingMessageBox.Net5.Wpf.csproj ├── AutoClosingMessageBox.cs ├── AutoClosingMessageBox.csproj ├── AutoClosingMessageBox.nuspec ├── Properties │ └── AssemblyInfo.cs └── Utils │ ├── Extensions.cs │ └── Win32Api.cs ├── LICENSE.TXT └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Bb]in.NET/ 23 | [Bb]in.NetFW/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # DNX 46 | project.lock.json 47 | artifacts/ 48 | 49 | *_i.c 50 | *_p.c 51 | *_i.h 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.tmp_proj 66 | *.log 67 | *.vspscc 68 | *.vssscc 69 | .builds 70 | *.pidb 71 | *.svclog 72 | *.scc 73 | 74 | # Chutzpah Test files 75 | _Chutzpah* 76 | 77 | # Visual C++ cache files 78 | ipch/ 79 | *.aps 80 | *.ncb 81 | *.opendb 82 | *.opensdf 83 | *.sdf 84 | *.cachefile 85 | *.VC.db 86 | *.VC.VC.opendb 87 | 88 | # Visual Studio profiler 89 | *.psess 90 | *.vsp 91 | *.vspx 92 | *.sap 93 | 94 | # TFS 2012 Local Workspace 95 | $tf/ 96 | 97 | # Guidance Automation Toolkit 98 | *.gpState 99 | 100 | # ReSharper is a .NET coding add-in 101 | _ReSharper*/ 102 | *.[Rr]e[Ss]harper 103 | *.DotSettings.user 104 | 105 | # JustCode is a .NET coding add-in 106 | .JustCode 107 | 108 | # TeamCity is a build add-in 109 | _TeamCity* 110 | 111 | # DotCover is a Code Coverage Tool 112 | *.dotCover 113 | 114 | # NCrunch 115 | _NCrunch_* 116 | .*crunch*.local.xml 117 | nCrunchTemp_* 118 | 119 | # MightyMoose 120 | *.mm.* 121 | AutoTest.Net/ 122 | 123 | # Web workbench (sass) 124 | .sass-cache/ 125 | 126 | # Installshield output folder 127 | [Ee]xpress/ 128 | 129 | # DocProject is a documentation generator add-in 130 | DocProject/buildhelp/ 131 | DocProject/Help/*.HxT 132 | DocProject/Help/*.HxC 133 | DocProject/Help/*.hhc 134 | DocProject/Help/*.hhk 135 | DocProject/Help/*.hhp 136 | DocProject/Help/Html2 137 | DocProject/Help/html 138 | 139 | # Click-Once directory 140 | publish/ 141 | 142 | # Publish Web Output 143 | *.[Pp]ublish.xml 144 | *.azurePubxml 145 | # TODO: Comment the next line if you want to checkin your web deploy settings 146 | # but database connection strings (with potential passwords) will be unencrypted 147 | *.pubxml 148 | *.publishproj 149 | 150 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 151 | # checkin your Azure Web App publish settings, but sensitive information contained 152 | # in these scripts will be unencrypted 153 | PublishScripts/ 154 | 155 | # NuGet Packages 156 | *.nupkg 157 | # The packages folder can be ignored because of Package Restore 158 | **/packages/* 159 | # except build/, which is used as an MSBuild target. 160 | !**/packages/build/ 161 | # Uncomment if necessary however generally it will be regenerated when needed 162 | #!**/packages/repositories.config 163 | # NuGet v3's project.json files produces more ignoreable files 164 | *.nuget.props 165 | *.nuget.targets 166 | 167 | # Microsoft Azure Build Output 168 | csx/ 169 | *.build.csdef 170 | 171 | # Microsoft Azure Emulator 172 | ecf/ 173 | rcf/ 174 | 175 | # Windows Store app package directories and files 176 | AppPackages/ 177 | BundleArtifacts/ 178 | Package.StoreAssociation.xml 179 | _pkginfo.txt 180 | 181 | # Visual Studio cache files 182 | # files ending in .cache can be ignored 183 | *.[Cc]ache 184 | # but keep track of directories ending in .cache 185 | !*.[Cc]ache/ 186 | 187 | # Others 188 | ClientBin/ 189 | ~$* 190 | *~ 191 | *.dbmdl 192 | *.dbproj.schemaview 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # ========================= 257 | # Operating System Files 258 | # ========================= 259 | 260 | # OSX 261 | # ========================= 262 | 263 | .DS_Store 264 | .AppleDouble 265 | .LSOverride 266 | 267 | # Thumbnails 268 | ._* 269 | 270 | # Files that might appear in the root of a volume 271 | .DocumentRevisions-V100 272 | .fseventsd 273 | .Spotlight-V100 274 | .TemporaryItems 275 | .Trashes 276 | .VolumeIcon.icns 277 | 278 | # Directories potentially created on remote AFP share 279 | .AppleDB 280 | .AppleDesktop 281 | Network Trash Folder 282 | Temporary Items 283 | .apdisk 284 | 285 | # Windows 286 | # ========================= 287 | 288 | # Windows image file caches 289 | Thumbs.db 290 | ehthumbs.db 291 | 292 | # Folder config file 293 | Desktop.ini 294 | 295 | # Recycle Bin used on file shares 296 | $RECYCLE.BIN/ 297 | 298 | # Windows Installer files 299 | *.cab 300 | *.msi 301 | *.msm 302 | *.msp 303 | 304 | # Windows shortcuts 305 | *.lnk 306 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.Core.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.30320.27 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoClosingMessageBox", "AutoClosingMessageBox\AutoClosingMessageBox.Core.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.NET.Win.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoClosingMessageBox.NET.Win", "AutoClosingMessageBox\AutoClosingMessageBox.NET.Win.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6CED15D7-24CB-4854-9EC1-F85B35B48798} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.NET.Wpf.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoClosingMessageBox.NET.Wpf", "AutoClosingMessageBox\AutoClosingMessageBox.NET.Wpf.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9A95E601-EAA5-4504-98FB-17E6790387E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.NET8.Win.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoClosingMessageBox.NET8.Win", "AutoClosingMessageBox\AutoClosingMessageBox.NET8.Win.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6CED15D7-24CB-4854-9EC1-F85B35B48798} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.NET8.Wpf.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32929.385 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoClosingMessageBox.NET8.Wpf", "AutoClosingMessageBox\AutoClosingMessageBox.NET8.Wpf.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9A95E601-EAA5-4504-98FB-17E6790387E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.Net3.5.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoClosingMessageBox", "AutoClosingMessageBox\AutoClosingMessageBox.Net3.5.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.Net5.Win.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.30320.27 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoClosingMessageBox", "AutoClosingMessageBox\AutoClosingMessageBox.Net5.Win.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.Net5.Wpf.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.30320.27 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoClosingMessageBox", "AutoClosingMessageBox\AutoClosingMessageBox.Net5.Wpf.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Release|Any CPU = Release|Any CPU 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /AutoClosingMessageBox.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoClosingMessageBox", "AutoClosingMessageBox\AutoClosingMessageBox.csproj", "{1F7E2591-09F3-4351-BEC3-69EC26689BED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7E2591-09F3-4351-BEC3-69EC26689BED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | netcoreapp3.1 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.NET.Win.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | net472;net6.0-windows 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | True 18 | The MessageBox which automatically closes after the specific timeout. 19 | Dmitry Garavsky 20 | The MessageBox which automatically closes after the specific timeout. 21 | Dmitry Garavsky, ©2022 22 | https://github.com/DmitryGaravsky/AutoClosingMessageBox 23 | README.md 24 | https://github.com/DmitryGaravsky/AutoClosingMessageBox 25 | Messagebox;AutoClose;Auto-Closing 26 | 1.0.0.5 27 | 1.0.0.5 28 | LICENSE.TXT 29 | ..\bin 30 | 1.0.0.5 31 | 32 | v1.0.0.5: 33 | - multitarget nuget package for .NET6/.Net 4.7.2 34 | 35 | 36 | 37 | 38 | ..\bin.NetFW\ 39 | 40 | 41 | ..\bin.NET\ 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | True 53 | \ 54 | 55 | 56 | True 57 | \ 58 | 59 | 60 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.NET.Wpf.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | net6.0-windows 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | 18 | 19 | TRACE;WPF 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.NET8.Win.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | net472;net8.0-windows 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | True 18 | The MessageBox which automatically closes after the specific timeout. 19 | Dmitry Garavsky 20 | The MessageBox which automatically closes after the specific timeout. 21 | Dmitry Garavsky, ©2024 22 | https://github.com/DmitryGaravsky/AutoClosingMessageBox 23 | README.md 24 | https://github.com/DmitryGaravsky/AutoClosingMessageBox 25 | Messagebox;AutoClose;Auto-Closing 26 | 1.0.0.6 27 | 1.0.0.6 28 | LICENSE.TXT 29 | ..\bin 30 | 1.0.0.6 31 | v1.0.0.6: 32 | - multitarget nuget package for .NET8(LTS)/.NET Framework 4.7.2 33 | - small fix of countdown feature 34 | 35 | 36 | 37 | ..\bin.NetFW\ 38 | 39 | 40 | ..\bin.NET\ 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | True 52 | \ 53 | 54 | 55 | True 56 | \ 57 | 58 | 59 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.NET8.Wpf.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | net472;net8.0-windows 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | 18 | 19 | 20 | TRACE;WPF 21 | 22 | 23 | ..\bin.NetFW\ 24 | 25 | 26 | ..\bin.NET\ 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.Net3.5.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 8 | Library 9 | Properties 10 | AutoClosingMessageBox 11 | AutoClosingMessageBox 12 | v3.5 13 | 512 14 | Client 15 | 16 | 17 | true 18 | full 19 | false 20 | ..\bin\ 21 | TRACE;DEBUG;NET35 22 | prompt 23 | 4 24 | false 25 | true 26 | 27 | 28 | pdbonly 29 | true 30 | ..\bin\ 31 | TRACE;NET35 32 | prompt 33 | 4 34 | false 35 | true 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 58 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.Net5.Win.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | net5.0-windows 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.Net5.Wpf.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 4 | False 5 | Library 6 | net5.0-windows 7 | true 8 | 9 | AutoClosingMessageBox 10 | AutoClosingMessageBox 11 | 12 | false 13 | False 14 | False 15 | 4 16 | true 17 | 18 | 19 | TRACE;WPF 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.cs: -------------------------------------------------------------------------------- 1 | #if WPF 2 | namespace System.Windows.Controls { 3 | using System.Windows.Controls.Extensions; 4 | using BUTTONS = System.Windows.MessageBoxButton; 5 | using OWNER = System.Windows.Window; 6 | using RESULT = System.Windows.MessageBoxResult; 7 | #else 8 | namespace System.Windows.Forms { 9 | using System.Windows.Forms.Extensions; 10 | using BUTTONS = System.Windows.Forms.MessageBoxButtons; 11 | using OWNER = System.Windows.Forms.IWin32Window; 12 | using RESULT = System.Windows.Forms.DialogResult; 13 | #endif 14 | using System.Threading; 15 | using TIMER = System.Threading.Timer; 16 | 17 | public class AutoClosingMessageBox { 18 | readonly string caption; 19 | readonly RESULT result; 20 | AutoClosingMessageBox(string caption, int timeout, Func showMethod, 21 | BUTTONS buttons = BUTTONS.OK, RESULT defaultResult = RESULT.None, bool showCountDown = false) { 22 | this.caption = caption ?? string.Empty; 23 | this.result = buttons.ToDialogResult(defaultResult); 24 | if(!showCountDown) { 25 | var timerStrategy = new DelayedCloseUpStrategy(caption, result.ToDialogButtonId(buttons)); 26 | using(new TIMER(OnTimerElapsed, timerStrategy, timeout, Timeout.Infinite)) 27 | this.result = showMethod(this.caption, buttons); 28 | } 29 | else { 30 | var timerStrategy = new CountDownStrategy(caption, result.ToDialogButtonId(buttons), timeout); 31 | using(new TIMER(OnCountDownTimer, timerStrategy, 50, 250)) 32 | this.result = showMethod(this.caption, buttons); 33 | } 34 | } 35 | static void OnTimerElapsed(object state) { 36 | ((DelayedCloseUpStrategy)state).Proceed(); 37 | } 38 | static void OnCountDownTimer(object state) { 39 | ((CountDownStrategy)state).Proceed(); 40 | } 41 | #region Strategies 42 | sealed class DelayedCloseUpStrategy { 43 | readonly string caption; 44 | readonly int dlgButtonId; 45 | public DelayedCloseUpStrategy(string caption, int dlgButtonId) { 46 | this.caption = caption; 47 | this.dlgButtonId = dlgButtonId; 48 | } 49 | public void Proceed() { 50 | IntPtr hWndMsgBox = Utils.Win32Api.FindMessageBox(caption); 51 | Utils.Win32Api.SendCommandToDlgButton(hWndMsgBox, dlgButtonId); 52 | } 53 | } 54 | sealed class CountDownStrategy { 55 | readonly string caption; 56 | readonly int dlgButtonId; 57 | readonly System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); 58 | IntPtr hWndMsgBox; 59 | string dlgButtonInitialText; 60 | TimeSpan timeout; 61 | public CountDownStrategy(string caption, int dlgButtonId, int timeout) { 62 | this.caption = caption; 63 | this.dlgButtonId = dlgButtonId; 64 | this.timeout = TimeSpan.FromMilliseconds(timeout); 65 | stopwatch.Start(); 66 | } 67 | int lastRemainingSeconds = -1; 68 | public void Proceed() { 69 | TimeSpan remaining = timeout - stopwatch.Elapsed; 70 | if(hWndMsgBox == IntPtr.Zero) { 71 | hWndMsgBox = Utils.Win32Api.FindMessageBox(caption); 72 | dlgButtonInitialText = Utils.Win32Api.GetDlgButtonText(hWndMsgBox, dlgButtonId); 73 | } 74 | if(remaining.TotalMilliseconds < 0) { 75 | stopwatch.Stop(); 76 | Utils.Win32Api.SendCommandToDlgButton(hWndMsgBox, dlgButtonId); 77 | return; 78 | } 79 | int remainingSeconds = (int)Math.Round(remaining.TotalSeconds); 80 | if(lastRemainingSeconds != remainingSeconds) { 81 | Utils.Win32Api.SetDlgButtonText(hWndMsgBox, dlgButtonId, $"{dlgButtonInitialText}({remainingSeconds})"); 82 | lastRemainingSeconds = remainingSeconds; 83 | } 84 | } 85 | } 86 | #endregion Strategies 87 | #region Show API 88 | public static RESULT Show(string text, 89 | string caption = null, int timeout = 1000, 90 | BUTTONS buttons = BUTTONS.OK, RESULT defaultResult = RESULT.None, bool showCountDown = false) { 91 | return new AutoClosingMessageBox(caption, timeout, 92 | (capt, btns) => MessageBox.Show(text, capt, btns), 93 | buttons, defaultResult, showCountDown 94 | ).result; 95 | } 96 | public static RESULT Show(OWNER owner, string text, 97 | string caption = null, int timeout = 1000, 98 | BUTTONS buttons = BUTTONS.OK, RESULT defaultResult = RESULT.None, bool showCountDown = false) { 99 | return new AutoClosingMessageBox(caption, timeout, 100 | (capt, btns) => MessageBox.Show(owner, text, capt, btns), 101 | buttons, defaultResult, showCountDown 102 | ).result; 103 | } 104 | #endregion 105 | #region Factory 106 | public interface IAutoClosingMessageBox { 107 | RESULT Show( 108 | int timeout = 1000, 109 | BUTTONS buttons = BUTTONS.OK, 110 | RESULT defaultResult = RESULT.None 111 | ); 112 | } 113 | public static IAutoClosingMessageBox Factory( 114 | Func showMethod, string caption = null, bool showCountDown = false) { 115 | if(showMethod == null) 116 | throw new ArgumentNullException("showMethod"); 117 | return new Impl(showMethod, caption, showCountDown); 118 | } 119 | #endregion 120 | #region IAutoClosingMessageBox 121 | sealed class Impl : IAutoClosingMessageBox { 122 | readonly Func getResult; 123 | internal Impl( 124 | Func showMethod, string caption, bool showCountDown) { 125 | this.getResult = (timeout, buttons, defaultResult) => 126 | new AutoClosingMessageBox(caption, timeout, showMethod, buttons, defaultResult, showCountDown).result; 127 | } 128 | RESULT IAutoClosingMessageBox.Show( 129 | int timeout, BUTTONS buttons, RESULT defaultResult) { 130 | return getResult(timeout, buttons, defaultResult); 131 | } 132 | } 133 | #endregion 134 | } 135 | } -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1F7E2591-09F3-4351-BEC3-69EC26689BED} 8 | Library 9 | Properties 10 | AutoClosingMessageBox 11 | AutoClosingMessageBox 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | ..\bin\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | true 27 | 28 | 29 | pdbonly 30 | true 31 | ..\bin\ 32 | TRACE 33 | prompt 34 | 4 35 | false 36 | true 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/AutoClosingMessageBox.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $title$ 7 | $author$ 8 | $author$ 9 | https://github.com/DmitryGaravsky/AutoClosingMessageBox 10 | false 11 | $description$ 12 | The MessageBox which automatically closes after the specific timeout. 13 | messagebox autoclose auto-closing 14 | 15 | -------------------------------------------------------------------------------- /AutoClosingMessageBox/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyVersion("1.0.0.6")] 7 | [assembly: CLSCompliant(true)] 8 | [assembly: AssemblyTitle("AutoClosingMessageBox")] 9 | [assembly: AssemblyDescription("MessageBox with auto-closing functionality")] 10 | [assembly: AssemblyCompany("Dmitry Garavsky(https://github.com/DmitryGaravsky)")] 11 | #if WPF 12 | [assembly: AssemblyProduct("Microsoft® .NET Framework Extension for WPF")] 13 | #else 14 | [assembly: AssemblyProduct("Microsoft® .NET Framework Extension for Windows Forms")] 15 | #endif 16 | [assembly: AssemblyCopyright("Dmitry Garavsky, ©2024")] 17 | [assembly: AssemblyFileVersion("1.0.0.6")] 18 | [assembly: StringFreezing] 19 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /AutoClosingMessageBox/Utils/Extensions.cs: -------------------------------------------------------------------------------- 1 | #if WPF 2 | namespace System.Windows.Controls.Extensions { 3 | using BUTTONS = System.Windows.MessageBoxButton; 4 | using RESULT = System.Windows.MessageBoxResult; 5 | #else 6 | namespace System.Windows.Forms.Extensions { 7 | using BUTTONS = System.Windows.Forms.MessageBoxButtons; 8 | using RESULT = System.Windows.Forms.DialogResult; 9 | #endif 10 | static class MessageBoxButtonsExtension { 11 | public static RESULT ToDialogResult(this BUTTONS buttons, RESULT defaultResult) { 12 | switch(buttons) { 13 | case BUTTONS.OK: 14 | return RESULT.OK; 15 | case BUTTONS.OKCancel: 16 | if(defaultResult == RESULT.Cancel) 17 | break; 18 | return RESULT.OK; 19 | case BUTTONS.YesNo: 20 | if(defaultResult == RESULT.No) 21 | break; 22 | return RESULT.Yes; 23 | case BUTTONS.YesNoCancel: 24 | if(defaultResult == RESULT.No) 25 | break; 26 | if(defaultResult == RESULT.Cancel) 27 | break; 28 | return RESULT.Yes; 29 | #if !WPF 30 | case BUTTONS.RetryCancel: 31 | if(defaultResult == RESULT.Retry) 32 | break; 33 | return RESULT.Cancel; 34 | case BUTTONS.AbortRetryIgnore: 35 | if(defaultResult == RESULT.Abort) 36 | break; 37 | if(defaultResult == RESULT.Retry) 38 | break; 39 | return RESULT.Ignore; 40 | #endif 41 | } 42 | return defaultResult; 43 | } 44 | public static int ToDialogButtonId(this RESULT result, BUTTONS buttons) { 45 | if(buttons == BUTTONS.OK) 46 | return 2; // Exceptional case 47 | return (int)result; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /AutoClosingMessageBox/Utils/Win32Api.cs: -------------------------------------------------------------------------------- 1 | namespace Utils { 2 | using System; 3 | using System.Runtime.InteropServices; 4 | using System.Security; 5 | using System.Text; 6 | 7 | [SecuritySafeCritical] 8 | static class Win32Api { 9 | public static IntPtr FindMessageBox(string caption) { 10 | const string lpClassName_MessageBox = "#32770"; 11 | return UnsafeNativeMethods.FindWindow(lpClassName_MessageBox, caption); 12 | } 13 | public static void SendCommandToDlgButton(IntPtr hWnd, int dlgButtonId) { 14 | if(hWnd == IntPtr.Zero) 15 | return; 16 | UnsafeNativeMethods.EnumChildWindows(hWnd, (handle, param) => { 17 | int ctrlId = UnsafeNativeMethods.GetDlgCtrlID(handle); 18 | if(ctrlId == dlgButtonId) { 19 | const uint WM_COMMAND = 0x0111; 20 | UnsafeNativeMethods.PostMessage(hWnd, WM_COMMAND, new IntPtr(ctrlId), handle); 21 | } 22 | return ctrlId != dlgButtonId; 23 | }, IntPtr.Zero); 24 | } 25 | public static string GetDlgButtonText(IntPtr hWnd, int dlgButtonId) { 26 | if(hWnd == IntPtr.Zero) 27 | return string.Empty; 28 | StringBuilder sb = new StringBuilder(128); 29 | int count = (int)UnsafeNativeMethods.GetDlgItemText(hWnd, dlgButtonId, sb, sb.Capacity); 30 | return sb.ToString(0, Math.Max(0, Math.Min(sb.Length, count))); 31 | } 32 | public static bool SetDlgButtonText(IntPtr hWnd, int dlgButtonId, string text) { 33 | if(hWnd == IntPtr.Zero) 34 | return false; 35 | return UnsafeNativeMethods.SetDlgItemText(hWnd, dlgButtonId, text); 36 | } 37 | #region SecurityCritical 38 | static class UnsafeNativeMethods { 39 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 40 | internal static extern IntPtr FindWindow( 41 | [In, Optional] string lpClassName, 42 | [In, Optional] string lpWindowName 43 | ); 44 | [DllImport("user32.dll")] 45 | [return: MarshalAs(UnmanagedType.Bool)] 46 | internal static extern bool EnumChildWindows( 47 | [In, Optional] IntPtr hWndParent, 48 | [In] EnumChildProc lpEnumFunc, 49 | [In] IntPtr lParam 50 | ); 51 | [return: MarshalAs(UnmanagedType.Bool)] 52 | internal delegate bool EnumChildProc( 53 | [In] IntPtr hWnd, 54 | [In] IntPtr lParam 55 | ); 56 | [DllImport("user32.dll")] 57 | internal static extern int GetDlgCtrlID( 58 | [In] IntPtr hDlg 59 | ); 60 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 61 | internal static extern uint GetDlgItemText( 62 | [In] IntPtr hDlg, 63 | [In] int nIDDlgItem, 64 | [Out] StringBuilder lpString, 65 | [In] int nMaxCount 66 | ); 67 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 68 | [return: MarshalAs(UnmanagedType.Bool)] 69 | internal static extern bool SetDlgItemText( 70 | [In] IntPtr hDlg, 71 | [In] int nIDDlgItem, 72 | [In] string lpString 73 | ); 74 | [DllImport("user32.dll", SetLastError = true)] 75 | [return: MarshalAs(UnmanagedType.Bool)] 76 | internal static extern bool PostMessage( 77 | [In] IntPtr hWnd, 78 | [In] uint Msg, 79 | [In] IntPtr wParam, 80 | [In] IntPtr lParam 81 | ); 82 | } 83 | #endregion SecurityCritical 84 | } 85 | } -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Dmitry Garavsky 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoClosingMessageBox 2 | 3 | The MessageBox which automatically closes after the specific timeout. 4 | 5 | Nuget Version 6 | StackOverflow Answer 7 | 8 | ## Usage 9 | 10 | Use the `AutoClosingMessageBox.Show` method either as follows: 11 | 12 | ``` 13 | // Fire and forget - it about to be closed after default timeout(1000ms) 14 | AutoClosingMessageBox.Show("Hello, World!"); 15 | ``` 16 | 17 | or follows: 18 | 19 | ``` 20 | // Wait for some result or make the default decision 21 | var result = AutoClosingMessageBox.Show( 22 | text: "To be or not to be?", 23 | caption: "The question", 24 | timeout: 2500, 25 | buttons: MessageBoxButtons.YesNo, 26 | defaultResult: DialogResult.Yes); 27 | if(result == DialogResult.Yes) { 28 | // to be 29 | } 30 | else { 31 | // or not 32 | } 33 | ``` 34 | 35 | You can also use the `AutoClosingMessageBox.Factory` method to get full control on MessageBox showing (for example, use icons): 36 | 37 | ``` 38 | var toBeOrNotToBeQuestion = AutoClosingMessageBox.Factory( 39 | showMethod: (caption, buttons) => 40 | MessageBox.Show(this, "To be or not to be?", caption, buttons, MessageBoxIcon.Question), 41 | caption: "The question" 42 | ); 43 | if(DialogResult.Yes == toBeOrNotToBeQuestion.Show( 44 | timeout: 2500, 45 | buttons: MessageBoxButtons.YesNo, 46 | defaultResult: DialogResult.Yes)) { 47 | // to be 48 | } 49 | else { 50 | // or not 51 | } 52 | 53 | ``` 54 | 55 | Since v1.0.0.3 you can also use the CountDown feature: 56 | 57 | ``` 58 | AutoClosingMessageBox.Show("Hello, World!", timeout: 5000, showCountDown: true); 59 | ``` 60 | 61 | or in Factory-manner: 62 | 63 | ``` 64 | var messageBoxWithQuestionIcon = AutoClosingMessageBox.Factory( 65 | showMethod: (caption, buttons) => 66 | MessageBox.Show(this, "To be or not to be?", caption, buttons, MessageBoxIcon.Question), 67 | caption: "The question", 68 | showCountDown: true // CountDown feature activation 69 | ); 70 | messageBoxWithQuestionIcon.Show(); 71 | ``` 72 | 73 | ## NuGet 74 | 75 | To install [AutoClosingMessageBox](https://www.nuget.org/packages/AutoClosingMessageBox), run the following command in the Package Manager Console: 76 | 77 | Install-Package AutoClosingMessageBox 78 | 79 | 80 | ## License 81 | 82 | The AutoClosingMessageBox library is licensed under the [MIT](https://github.com/DmitryGaravsky/AutoClosingMessageBox/blob/master/LICENSE.TXT) license. 83 | --------------------------------------------------------------------------------