Determine the font of the messageboxes

ankurdk
ankurdk used Ask the Experts™
on
Hi All,

I have a very basic Windows based .net application in which I have used messageboxes.  How can I determine/know the font of the messageboxes ?

OS used : Windows Server 2008 r2
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
do you have the source code? if so open the solution in Visual Studio. click on the control and look at its properties.
AndyAinscowFreelance programmer / Consultant

Commented:
That should be a system setting for a standard message box.  You can look at the font settings to determine which it is.
Fernando SotoRetired
Distinguished Expert 2017

Commented:
Hi ankurdk;

The MessageBox only has a few properties that are available to be set or gotten but the Font is not one of them. So in answer to your question you can't. If you need that functionality you will need to create your own dialog box.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Senior Software Engineer
Commented:
Hi,

As far as I am aware the default MessageBox will use the system font and size.

There is a static class SystemFonts that might be of help

Namespace:
    System.Windows

Assembly:
    PresentationFramework.dll

Contains properties that expose the system resources that concern fonts.

There is also one that exposes the MessageFontSize

SystemFonts.MessageFontSize

Hope this helps,

Thanks,

Darren
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Hi ankurdk,

If you used MessageBox.Show method and did not have your own custom message boxes or (any other mechanism to override default system behavior) - your messagebox would use the fonts defined by the system.

Regards,
Chinmay.
Don VonderBurgPresident/CEO

Commented:
The standard MessageBox has limited settings. I wrote my own MessageBox routine and use that in all cases. I have more control that way.

Author

Commented:
Thanks All for your insights.  As precisely put by @Darren, there is a property SystemFonts.MessageBoxFont which does give the name of the font (in this case it is Tahoma) using the following VB.NET code :

Messagebox.Show(SystemFonts.MessageBoxFont.ToString)

So, technically, is this the system font. If so, can we change it ?
AndyAinscowFreelance programmer / Consultant

Commented:
As it is a system setting I would strongly recommend you do NOT change it.

Author

Commented:
Again, I thank all for their prompt valuable inputs.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial