functions

fhMessageBox

Description

Displays a message box with a choice of various buttons (or just an 'OK' button if not otherwise specified). Returns the button clicked on as a text string.

There is no need to call fhUpdateDisplay before calling this function, as there would be if you were using an IUP function to display a message box.

Syntax

strButton = fhMessageBox(strMessage[,strMessageBoxFormat[,strMessageBoxIcon[, hParentWnd]]])

Parameters

strMessage
string: A message text to be displayed
strMessageBoxFormat
Specifies the number and type of buttons. If not supplied or an empty string (""), defaults to "MB_OK". Options are:
MB_OK OK Button Only
MB_ABORTRETRYIGNORE 3 Buttons Abort,Retry and Ignore
MB_OKCANCEL 2 Buttons OK and Cancel
MB_RETRYCANCEL 2 Buttons Retry and Cancel
MB_YESNO 2 Buttons Yes and No
MB_YESNOCANCEL 3 Buttons Yes, No and Cancel
strMessageBoxIcon
Specifies an icon to display with the message (the actual icons will vary slightly depending on the version of windows installed):
MB_ICONEXCLAMATION
MB_ICONINFORMATION
MB_ICONQUESTION
MB_ICONSTOP
hParentWnd
Requires version 7 or later.  Optional parent window handle ('light userdata').  If you are calling the function from a dialog box, such as an IUP dialog box, you must pass in the window handle of the dialog box - see second example below.

Return Value

strButton

One of the following strings will be returned, based on the button pressed by the user:

OK
Cancel
Abort
Retry
Ignore
Yes
No

Remarks

Example
fhMessageBox("Hello World", "MB_OK", "MB_ICONEXCLAMATION")
res = fhMessageBox("Do you wish to continue?", "MB_YESNO", "MB_ICONQUESTION")
if res == "No" then 
    fhMessageBox("You clicked No")
elseif res == "Yes" then 
    fhMessageBox("You clicked Yes") 
end 

fhMessageBox OK fhMessageBox Yes/No

require("iuplua");
iup.SetGlobal("CUSTOMQUITMESSAGE","YES");
 
local btn = iup.button{title="click me"};
local dlg=iup.dialog{ iup.vbox{ iup.label{title="Hello"}, btn}, title="Test Click", size="200x200"};
iup.SetAttribute(dlg, "NATIVEPARENT", fhGetContextInfo("CI_PARENT_HWND"));
 
function btn:action() 
	local res = fhMessageBox("Hello world", "MB_OK", "", dlg.HWND)
end
 
	iup.Popup(dlg);
	iup.Destroy(dlg);