Function Reference


_WinAPI_MessageBoxIndirect

Creates, displays, and operates a message box

#include <WinAPIDlg.au3>
_WinAPI_MessageBoxIndirect ( $tMSGBOXPARAMS )

Parameters

$tMSGBOXPARAMS $tagMSGBOXPARAMS structure that contains information used to display the message box.

Return Value

Success: One of the $ID* constants.
Failure: 0.

Remarks

When you use a system-modal message box to indicate that the system is low on memory, the strings pointed to by the
"Text" and "Caption" members of the $tagMSGBOXPARAMS structure should not be taken from a resource file, because
an attempt to load the resource may fail.

If you create a message box while a dialog box is present, use a handle to the dialog box as the hWnd parameter.
The hWnd parameter should not identify a child window, such as a control in a dialog box.

See Also

Search MessageBoxIndirect in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDlg.au3>

Local Const $sTitle = 'Message'
Local Const $sText = 'This is a simple message box with a custom icon.'

Local $tMBP = DllStructCreate($tagMSGBOXPARAMS & ';wchar szCaption[' & (StringLen($sTitle) + 1) & '];wchar szText[' & (StringLen($sText) + 1) & ']')
DllStructSetData($tMBP, 'Size', DllStructGetPtr($tMBP, 'szCaption') - DllStructGetPtr($tMBP))
DllStructSetData($tMBP, 'hOwner', 0)
DllStructSetData($tMBP, 'hInstance', _WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'))
DllStructSetData($tMBP, 'Text', DllStructGetPtr($tMBP, 'szText'))
DllStructSetData($tMBP, 'Caption', DllStructGetPtr($tMBP, 'szCaption'))
DllStructSetData($tMBP, 'Style', BitOR($MB_OKCANCEL, $MB_USERICON))
DllStructSetData($tMBP, 'Icon', 239)
DllStructSetData($tMBP, 'ContextHelpId', 0)
DllStructSetData($tMBP, 'MsgBoxCallback', 0)
DllStructSetData($tMBP, 'LanguageId', 0)
DllStructSetData($tMBP, 'szCaption', $sTitle)
DllStructSetData($tMBP, 'szText', $sText)

Local $iResult = _WinAPI_MessageBoxIndirect($tMBP)

ConsoleWrite('Return: ' & $iResult & @CRLF)