MESSAGEBOX (function): Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Initial version)
 
m (Update info on case agnostic and optional arg. behavior)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:_MESSAGEBOX (function)}}
{{DISPLAYTITLE:_MESSAGEBOX (function)}}
The '''_MESSAGEBOX''' function displays a message dialog box, which presents a message and returns the button id clicked by the user. The return value can be '''0''' for '''"cancel"'''/'''"no"''', '''1''' for '''"ok"'''/'''"yes"''', '''2''' for '''"no"''' in '''"yesnocancel"'''.
The '''_MESSAGEBOX''' function displays a message dialog box, which presents a message and returns the button ID clicked by the user. The return value can be '''0''' for '''"cancel"'''/'''"no"''', '''1''' for '''"ok"'''/'''"yes"''', '''2''' for '''"no"''' in '''"yesnocancel"'''.




{{PageSyntax}}
{{PageSyntax}}
:{{Parameter|result&}} = [[_MESSAGEBOX (function)|_MESSAGEBOX]]({{Parameter|title$}}, {{Parameter|message$}}, {{parameter|dialogType$}}, {{Parameter|iconType$}}[, {{Parameter|defaultButton&}}])
:{{Parameter|result&}} = [[_MESSAGEBOX (function)|_MESSAGEBOX]]([{{Parameter|title$}}][, {{Parameter|message$}}][, {{parameter|dialogType$}}][, {{Parameter|iconType$}}][, {{Parameter|defaultButton&}}])




Line 11: Line 11:
* {{Parameter|message$}} is the dialog box message
* {{Parameter|message$}} is the dialog box message
* {{Parameter|dialogType$}} is the dialog box type and shows different buttons based on the value (this can be '''"ok"''', '''"okcancel"''', '''"yesno"''', or '''"yesnocancel"''')
* {{Parameter|dialogType$}} is the dialog box type and shows different buttons based on the value (this can be '''"ok"''', '''"okcancel"''', '''"yesno"''', or '''"yesnocancel"''')
* {{Parameter|iconType$}} is the icon type that is displayed inside the dialog box (this can be '''"info"''', '''"warning"''', or '''"error"''')
* {{Parameter|iconType$}} is the icon type that is displayed inside the dialog box (this can be '''"info"''', '''"warning"''', '''"error"''', or '''"question"''')
* {{Parameter|defaultButton&}} can be '''0''' for '''"cancel"'''/'''"no"''', '''1''' for '''"ok"'''/'''"yes"''', '''2''' for '''"no"''' in '''"yesnocancel"'''
* {{Parameter|defaultButton&}} can be '''0''' for '''"cancel"'''/'''"no"''', '''1''' for '''"ok"'''/'''"yes"''', '''2''' for '''"no"''' in '''"yesnocancel"'''
* All parameters accept an empty string ('''""''') in which case system defaults are used




{{PageDescription}}
{{PageDescription}}
* '''"ok"''', '''"okcancel"''', '''"yesno"''', or '''"yesnocancel"''' can be in any case
* '''"info"''', '''"warning"''', '''"error"''', or '''"question"''' can be in any case
* All parameters accept nothing or an empty string ('''""'''). In both cases system defaults are used
* The dialog box automatically becomes a modal window if the application window is visible
* The dialog box automatically becomes a modal window if the application window is visible
* '''"ok"''', '''"okcancel"''', '''"yesno"''', or '''"yesnocancel"''' are expected to be in lower case
* '''"info"''', '''"warning"''', or '''"error"''' are expected to be in lower case




{{PageAvailability}}
{{PageAvailability}}
* '''QB64-PE v3.4 and up'''
* '''QB64-PE v3.4.0 and up'''




{{PageExamples}}
{{PageExamples}}
; Example : Hello, world with common dialogs
; Example : Simple yes/no message box example
{{CodeStart}}
{{CodeStart}}
{{Cl|IF}} {{Cl|_MESSAGEBOX (function)|_MESSAGEBOX}}("My Cool App", "Do you want to hear a beep?", "yesno", "question") = 1 {{Cl|THEN}}
{{Cl|IF}} {{Cl|_MESSAGEBOX (function)|_MESSAGEBOX}}("My Cool App", "Do you want to hear a beep?", "yesno", "question") = 1 {{Cl|THEN}}
Line 40: Line 40:
* [[_NOTIFYPOPUP]]
* [[_NOTIFYPOPUP]]
* [[_MESSAGEBOX]]
* [[_MESSAGEBOX]]
* [[_INPUTBOX$]]
* [[_SELECTFOLDERDIALOG$]]
* [[_SELECTFOLDERDIALOG$]]
* [[_INPUTBOX$]]
* [[_COLORCHOOSERDIALOG]]
* [[_OPENFILEDIALOG$]]
* [[_OPENFILEDIALOG$]]
* [[_SAVEFILEDIALOG$]]
* [[_SAVEFILEDIALOG$]]

Latest revision as of 02:39, 13 August 2023

The _MESSAGEBOX function displays a message dialog box, which presents a message and returns the button ID clicked by the user. The return value can be 0 for "cancel"/"no", 1 for "ok"/"yes", 2 for "no" in "yesnocancel".


Syntax

result& = _MESSAGEBOX([title$][, message$][, dialogType$][, iconType$][, defaultButton&])


Parameters

  • title$ is the dialog box title
  • message$ is the dialog box message
  • dialogType$ is the dialog box type and shows different buttons based on the value (this can be "ok", "okcancel", "yesno", or "yesnocancel")
  • iconType$ is the icon type that is displayed inside the dialog box (this can be "info", "warning", "error", or "question")
  • defaultButton& can be 0 for "cancel"/"no", 1 for "ok"/"yes", 2 for "no" in "yesnocancel"


Description

  • "ok", "okcancel", "yesno", or "yesnocancel" can be in any case
  • "info", "warning", "error", or "question" can be in any case
  • All parameters accept nothing or an empty string (""). In both cases system defaults are used
  • The dialog box automatically becomes a modal window if the application window is visible


Availability

  • QB64-PE v3.4.0 and up


Examples

Example
Simple yes/no message box example
IF _MESSAGEBOX("My Cool App", "Do you want to hear a beep?", "yesno", "question") = 1 THEN
    BEEP
ELSE
    _MESSAGEBOX "My Cool App", "The sound of silence."
END IF


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link