A Wrapper for MessageBoxIndirect
Posted
by Peter Kenyon
on February 24th, 2000
Environment: Windows NT4 SP5, Visual C++ 6 SP2
Introduction
Sometimes you might wish you could use other icons in a message box apart from the ones Windows gives you, or you might want to have more control over how your message box, specify which language to use, etc. Well, there is a way to do all this using the little-known API call MessageBoxIndirect.
Here is a class which encapsulates MessageBoxIndirect (actually, it inherits from the MESSAGEBOXPARAMS structure which you pass to MessageBoxIndirect). You can use it like an MFC CDialog, although there are no dependencies on MFC.
Usage
- Declare a CMessageBox object
- Initialize it (If you are just displaying a standard Message Box you can skip this step
- Call DoModal.
#include "MessageBox.h" .... CMessageBox box;or
CMessageBox box(hWnd, "My Text", "My Caption", MB_OK);
box.SetIcon(IDI_SOMEICON);
box.SetLangID(MAKELANGID(LANG_CHINESE,
SUBLANG_CHINESE_TRADITIONAL));
if(box.DoModal() == MB_OK)
{
// Do something here
}
else
{
// Do something else
}
That's it!
Downloads
Download demo project - 16 KbDownload source - 2 Kb

Comments
There are no comments yet. Be the first to comment!