C
C#2y ago
alcatel

❔ Message box using small Segoe UI/skinny/classic theme for OK button

I am making a simple C# program with MessageBox.Show. When I run it I get a message box with the text in small Segoe UI, it's skinny, and it uses classic theme for OK button. How can I get a message box that's normal sized, long, and uses the user theme for the OK button like in the 2nd screenshot?
10 Replies
reflectronic
reflectronic2y ago
you need to add an application manifest that declares a dependency on Common Controls v6 something like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"
/>
</dependentAssembly>
</dependency>
</assembly>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"
/>
</dependentAssembly>
</dependency>
</assembly>
you can add an app manifest to your program from VS and paste that in
alcatel
alcatel2y ago
:0 thank u but this only fixes the classic theme part not the small segoe ui/length
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
alcatel
alcatel17mo ago
Not resolved :(
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
alcatel
alcatel17mo ago
no lol
reflectronic
reflectronic17mo ago
that is the best you can do with MessageBox
reflectronic
reflectronic17mo ago
as an alternative, you can use Task Dialog, which has a slightly different appearance
Task Dialog
MessageBox
reflectronic
reflectronic17mo ago
if you are using .NET 5 or later it comes with windows forms:
TaskDialog.ShowDialog(new()
{
Caption = "shell:games",
Text = "Windows cannot find 'shell:games'. Make sure you typed the name correctly, and then try again.",
Buttons = { TaskDialogButton.OK },
Icon = TaskDialogIcon.Error,
AllowCancel = true
});
TaskDialog.ShowDialog(new()
{
Caption = "shell:games",
Text = "Windows cannot find 'shell:games'. Make sure you typed the name correctly, and then try again.",
Buttons = { TaskDialogButton.OK },
Icon = TaskDialogIcon.Error,
AllowCancel = true
});
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.