Home

AfxMessageBox

AfxMessageBox is a utility function provided by the Microsoft Foundation Class (MFC) library that displays a simple, modal message box with minimal programming effort. It serves as a wrapper around the Windows MessageBox API, integrating with MFC's application context and resources.

The typical signature is int AfxMessageBox(LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0). The function shows

Usage notes: AfxMessageBox is modal to the calling thread and uses the MFC application context to determine

Examples:

- AfxMessageBox(_T("Operation completed successfully."));

- int res = AfxMessageBox(_T("Delete file?"), MB_YESNO | MB_ICONQUESTION);

See also: MessageBox (Windows API), CDialog in MFC.

a
dialog
containing
the
specified
text
and
a
set
of
buttons
and
icons
determined
by
the
nType
flags
(for
example
MB_OK,
MB_YESNO,
MB_ICONINFORMATION,
MB_ICONQUESTION,
etc.).
It
returns
the
identifier
of
the
button
the
user
pressed
(such
as
IDOK,
IDCANCEL,
IDYES,
IDNO).
The
text
can
be
provided
as
a
CString
or
a
TCHAR
string,
and
you
can
format
it
as
needed
using
CString::Format
before
calling
AfxMessageBox.
the
dialog’s
owner
and
caption.
If
a
caption
is
not
specified,
the
dialog
typically
uses
the
application's
window
title.
The
nIDHelp
parameter
can
be
used
to
integrate
the
message
box
with
the
help
system
in
an
application
that
supports
context-sensitive
help.