Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Changing the font size of Message Box

Posted on 1998-09-23
Medium Priority
Last Modified: 2013-12-03
I'm working on a large VB app. Is there an API call that will allow me to change the font size (as I can in Control Panel) of the message box used by MsgBox()?

I cannot implement a form in place of MsgBox() for the following reasons:

- This is an MDI application.
- I sometimes need to show 2 msgboxes in sequence.
- I need them both to be system modal

If I need to create a custom dialog box resource, can someone provide sample code for the necessary window procedure?

Thanks very much.
Question by:cdickerson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1

Expert Comment

ID: 1414706
Windows does the formatting. (MsgBox corresponds to the MessageBox API call)

If you change the font, you change it for all messages boxes not just the ones in your app.  This is a very unfriendly way for you app to behave, so I wouldn't recommend it (basically you can change the system settings to do this).

A good work round is to create a form and use that instead of the built-in Message box.
1. Pass the form the title & text you want.
2. Put these in text fields
3. Pass the icon you want to the form, but this in a picture box.
4. Pass the buttons you want (you can also add the capability to use other text than windows allows, which is a good reason for doing this in itself)

Some MS apps do this too.

Finally you may also want to do this, as you can do thinks like add your own scroll bar for really long messages with a form (which you can't do with the standard message box).

Author Comment

ID: 1414707
In my message I explained why I *can't* use a form.

I cannot make more than one form in a MDI app modal. If 2 error messages pop up in sequence, only 1 will be modal, while the other goes into the background, waiting for input.

I understand changing the setting affects everything, which is why I'd intended to undo the change immediately after the call to MsgBox.

Expert Comment

ID: 1414708
Sorry I don't understand why you can't simply display the second form after the first one has finished - could you explain why this doesn't work for you ?
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks


Author Comment

ID: 1414709
Perhaps I can and just know how. One form is fired off by an error routine, another is fired off by an event. That sort of thing happens all over the app, and there's really no way of getting around it in the timeframe we have.

Expert Comment

ID: 1414710
if that is happening, how is the MessageBox dealing with that?
LVL 11

Expert Comment

ID: 1414711
Like most VB programmers, you're facing a limitation of the development environment and you need to find a workaround.

You can create a DLL in C or C++ that will hook creation of message boxes your app posts. You can have that hook change the font used by the controls and text in the message box.

Or, you can investigate more carefully managing modality in your application. If you need to pop up a second error message, then your first window isn't truly modal anyway--you're still doing processing!  You can avoid the focus and input problems you describe by disabling the windows that are going into the background. Just set their "enabled" properties to FALSE.

B ekiM


Author Comment

ID: 1414712
I realize I can write a DLL, which is why I asked for sample code for the window procedure.

I also know this is a bad design to begin with, but we really don't have the timeframe to change it. This is a conversion project (from an OS/2 language), and the delivery date did not take into account that a line-for-line conversion might not be acceptable (typical!).

We're pretty close to a workaround.
LVL 11

Accepted Solution

mikeblas earned 100 total points
ID: 1414713
Uh, I guess you didn't read my answer all the way, or at least didn't understand it.

I'm suggesting that you write a DLL with a hook--which won't require a window procedure. You suggesting that you'd create a custom dialog box, which would need a window procedure.

Your window procedure would do next to nothing:

BOOL CALLBACK MyDialogProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
   BOOL bRet = FALSE;
   switch (uMessage)
      case WM_INITDIALOG:
         bRet = TRUE;

   return bRet;

and that's that.  If you need something more specific, you have to indicate which controls you'll have on the box and what you'll want those controls to do for you at runtime.

B ekiM


Author Comment

ID: 1414714
I think the latter of your first statement is true.

What would the hook look like? (Remember I mentioned I have no experience with MFC).

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question