Is there a way to change the font on a VB messagebox? If so, how?
Printable View
Is there a way to change the font on a VB messagebox? If so, how?
The font in a messagebox is defined in the windows display settings. The only way to change them, is to change them system wide. If you like another font for your application only, you have to create your own messagebox form.
he is right
you could read what the windows settings are and store them.
change the setting.
show the message box
after the user clicks one of the buttons
reset the system.
more work then the message box was intended for IMO
right click on your desktop and select properties.
it is under appearance/message box.
some people would not like you to change this though.
people with disabilities set these for specific reasons, I would not make the assumption that everyone has 20/20 vision.
Why not build your own message box?
Create a form with a label set to the font required, and display it with the required buttons.
I have built such a form, with all the messages I require in a resource file, including formatting details for width, height, font, colour, buttons, htmlhelp refs etc (these are in a CSV type format).
All I do is pass the resource ref no to a function, parse the data, which loads the form modally, displays the required buttons and form properties, and sends back the usual vbYes, vbNo, etc constants when the buttons are clicked.
I have also done the same with a TXText control, with the data in a database. This allows messages to include tables pictures and fully formatted text.
Sorry, though, I cannot send you the source as it is owned by my company!
If you decide to make your own Message Box, use vbModal to keep the form on top and disable all other forms behind it.
Code:msgfrm.Show vbModal
From a completely different thread, I wrote a C++ DLL to 'hook' into the windows MessageBox function. I'm sure I could set the font on that one as well. At the moment all it does is have a custom position. There is source and an example here: http://www.parksie.uklinux.net/customwin.zip
I'm writing a kiosk GUI program in VB6.
I had to create my own MessageBox, since the lay-out is very simple of the MsgBox() command.
I used a Form with no borders, created my GUI on it and set it on top of the screen, disabling the owner Form.
The calling procedure "MyMsgBox()" executes a loop combined with the DoEvents statement and checks continuously for a variable's status. It's very simple, considers some attention to the DoEvents statement and is purely written in VB! You can even play a .AVI in your MsgBox!