Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing the font size of Message Box

Posted on 1998-09-23
9
Medium Priority
?
367 Views
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.
0
Comment
Question by:cdickerson
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 8

Expert Comment

by:Answers2000
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).
0
 

Author Comment

by:cdickerson
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.
0
 
LVL 8

Expert Comment

by:Answers2000
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 ?
0
Industry Leaders: 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!

 

Author Comment

by:cdickerson
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.
0
 
LVL 3

Expert Comment

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

Expert Comment

by:mikeblas
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

0
 

Author Comment

by:cdickerson
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.
0
 
LVL 11

Accepted Solution

by:
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

0
 

Author Comment

by:cdickerson
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).
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

927 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