Solved

Changing the font size of Message Box

Posted on 1998-09-23
9
247 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Query performance - SQL Server 20 73
Visual Studio Debugging 3 109
C#: need to import an entire CSV file 4 44
Problem to adjust sheet 1 81
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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now