Link to home
Start Free TrialLog in
Avatar of gurukg102498
gurukg102498

asked on

AfxMessageBox

Hi,

I have a CString called HELLO.
CString say temp = HELLO.
I want to make this string to APPEAR As a BOLD and ITALIC STRING in the AfxMessageBox?

How can I do this?

Syntax is: AfxMessageBox(temp);


Thanks
Avatar of jhattingh
jhattingh

You can't do that.

If you're going to do it a lot in future, write a class that will allow this. Otherwise, I'm afraind you're going to have to implement a simple dialog box that appears to be exactly the same as the system dlg box, with extended functionality, using possibly a rich edit control.

Regards,

Jason
Avatar of gurukg102498

ASKER

Hi Jason
Could you be more elaborate on this.I know there is no direct way to do that.But how will I implement this.Pls let me know.


Yes i agree with Jason, in order change the font (bold/italic) of the original MessageBox you'd have to subclass it or write your own.
ASKER CERTIFIED SOLUTION
Avatar of jhattingh
jhattingh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Meir Rivkin
what u wanna do is derive from CDialog and make your own message box class.

add data member CFont m_fontSpecial.

and in OnInitDialog() add the following:
     LOGFONT lfNew;

ZeroMemory (&lfNew, sizeof(LOGFONT));
lfNew.lfHeight = 18;

lfNew.lfItalic = TRUE;
lfNew.lfWeight = FW_BOLD;

strcpy (lfNew.lfFaceName, "Book Antiqua"); //or any other font
m_fontSpecial.CreateFontIndirect(&lfNew);

now use GetDlgItem() and SetFont() to change the font to some control, for example if u have message box and the text is displayed by using CStatic do like this:

GetDlgItem(IDC_STATIC)->SetFont(&m_fontSpecial, TRUE)

if u need a sample app post your e-mail address.

cheers
Admin notified of User neglect. Force-accepted by
Netminder
CS Moderator