Solved

Changing the font size of Message Box

Posted on 1998-09-23
9
291 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
[X]
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
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 50 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

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!

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

628 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