Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the difference between AfxMessageBox and MessageBox in VC++?

2,356 views
Skip to first unread message

alan

unread,
Apr 21, 2003, 5:48:27 AM4/21/03
to
Hi all,

I would like to know the difference between AfxMessageBox and
MessageBox in VC++ 6.0 version.

which one should I use?

I am a newbie in VC.
Pls advise me!

Thank you very much.'
cheers,
Alan

William DePalo [MVP VC++ ]

unread,
Apr 21, 2003, 10:22:00 AM4/21/03
to
"alan" <cheung...@i-cable.com> wrote in message
news:7bd5ab13.03042...@posting.google.com...

> I would like to know the difference between AfxMessageBox and
> MessageBox in VC++ 6.0 version.

MessageBox() is provided by Win32 itself and is meant to be called from just
about anything in any language that knows what an exported function in a DLL
is.

AfxMessageBox() is a function in the Microsoft Foundation Class (MFC)
library that comes with MS' C++ compiler.

> which one should I use?

Whichever one you want. :-)

Regards,
Will


Michael T. Pudelko

unread,
Apr 21, 2003, 11:29:47 AM4/21/03
to
Hi Alan,

The other thing that is cool about AfxMessageBox() is that it sticks in the
application name automatically in the message box's caption. And if you
don't like the default behavior, you can just override CWinApp::DoMessageBox
and customize it to your heart's desire.

Like Will says, the choice is completely yours as to which to use -- as long
as you are writing an MFC app. FWIW, I've found AfxMB more useful in most
situations.

Regards,
Mike

"William DePalo [MVP VC++ ]" <willd....@mvps.org> wrote in message
news:eQliXGBC...@TK2MSFTNGP12.phx.gbl...

Anthony Yio

unread,
Apr 21, 2003, 11:25:50 PM4/21/03
to
AfxMessageBox is a MFC based dialog box. MessageBox itself is a Windows API.
AfxMessageBox save you lot of hassle from declaring the detail of your
messagebox behaviour


"alan" <cheung...@i-cable.com>
??????:7bd5ab13.03042...@posting.google.com...

James Curran/MVP

unread,
Apr 22, 2003, 11:54:47 AM4/22/03
to
William DePalo [MVP VC++ ] wrote:
>
> MessageBox() is provided by Win32 itself and is meant to be called
> from just about anything in any language that knows what an exported
> function in a DLL is.
>
> AfxMessageBox() is a function in the Microsoft Foundation Class (MFC)
> library that comes with MS' C++ compiler.

All these responses ignore CWnd::MessageBox, whose different from
AfxMessageBox isn't as clear....


--
Truth,
James Curran
www.noveltheory.com (personal)
www.njtheater.com (professional)


Carl Daniel [VC++ MVP]

unread,
Apr 22, 2003, 12:05:54 PM4/22/03
to
James Curran/MVP wrote:
> William DePalo [MVP VC++ ] wrote:
>>
>> MessageBox() is provided by Win32 itself and is meant to be called
>> from just about anything in any language that knows what an exported
>> function in a DLL is.
>>
>> AfxMessageBox() is a function in the Microsoft Foundation Class (MFC)
>> library that comes with MS' C++ compiler.
>
> All these responses ignore CWnd::MessageBox, whose different from
> AfxMessageBox isn't as clear....

CWnd::MessageBox simply calls ::MessageBox, after supplying one or two
defaults (the HWND and the caption, unless a caption was passed-in).

-cd


0 new messages