AtlMessageBoxCheck
Adds additional buttons (Yes to all, No to all) and Do not ask/tell me again check box to the standard Windows message box. Also included is a VS.NET style message box.
This is a WTL adoption of the MFC XMessageBox - A reverse-engineered MessageBox() function.
Syntax
The AtlMessageBoxCheck function creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.
AtlMessageBoxCheck uses the application default style specified at compile time, while AtlMessageBoxCheckNet and AtlMessageBoxCheckWin display a message box in style of VS.NET and Windows respectively.
int AtlMessageBoxCheck( HWND hWndOwner, _U_STRINGorID message, _U_STRINGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION ); int AtlMessageBoxCheckNet( HWND hWndOwner, _U_STRINGorID message, _U_STRINGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION ); int AtlMessageBoxCheckWin( HWND hWndOwner, _U_STRINGorID message, _U_STRINGorID title = (LPCTSTR)NULL, UINT uType = MB_OK | MB_ICONINFORMATION );
Parameters
- hWndOwner
- Same as
MessageBox
. - message
- Same as
MessageBox
, but also accepts resource string identifiers. - title
- Same as
MessageBox
, but also accepts resource string identifiers. - uType
-
Same as
MessageBox
. Additional flags:- MB_CONTINUEABORT
- The message box contains two buttons: Continue and Abort.
- MB_DONOTASKAGAIN
- Adds a checkbox Do not ask me again to the message box.
- MB_DONOTTELLAGAIN
- Adds a checkbox Do not tell me again to the message box.
- MB_DONOTSHOWAGAIN
- Add a checkbox Do not show this message again to the message box.
- MB_YESTOALL
- Adds a button Yes to all to the message box. This flag must be used with either
MB_YESNO
orMB_YESNOCANCEL
. - MB_NOTOALL
- Adds a button No to all to the message box. This flag must be used with either
MB_YESNO
orMB_YESNOCANCEL
. - MB_NORESOURCE
- Do not try to load the button strings from the resources. If this flag is not set, the implementation tries to load the button names form the string table in the current module resource (determined via
_pModule->GetResourceInstance()
), usingBXT_IDS_MB_TEXT_BASE + ButtonID
for the resource identifier.BXT_IDS_MB_TEXT_BASE
defaults to 57005. Additionally, the macroBXT_MB_MAX_BUTTON_TEXT
should define the maximum string length (defaults to 48). - MB_NOSOUND
- Do not play sound when mb is displayed
- MB_DEFBUTTON5
- The fifth button is the default button.
- MB_DEFBUTTON6
- The sixth button is the default button.
Return Value
Same as MessageBox
. Additional, one of the following menu-item values may be returned.
IDYESTOALL | Yes to all button was selected. |
IDNOTOALL | No to all button was selected. |
When one of the MB_DONOTASKAGAIN
, MB_DONOTTELLAGAIN
or MB_DONOTSHOWAGAIN
flags has been used, the return value can be OR'd with IDCHECKMARKED
to indicate that the checkbox was checked. To extract the button ID, AND the return value with MB_RESULTBUTTONMASK
.
Sample
This simple function opens the message box only when the user did not mark the checkbox in an early call.
bool AskUser(const CString& message) { static int nRet = 0; if((nRet & IDCHECKMARKED) == 0) { UINT uType = MB_ICONINFORMATION | MB_YESNO | MB_DONOTSHOWAGAIN; nRet = AtlMessageBoxCheck(m_hWnd, (LPCTSTR)message, _T("Question (Bad title but this " "is only a sample)"), uType); } return (nRet & MB_RESULTBUTTONMASK) == IDYES; }
About the Implementation
Uses memory dialog template to create the dialog box. Helper classes: CDlgTemplateBase
manages DLGTEMPLATE
integrity, CMsgBoxTemplateT
provides layout customization of the message box dialog template, CMessageBoxCheckT
implements the message box creation and operation.