Method dialog.show
Overload
Shows dialog.
public static int show(string text1 = null, string text2 = null, Strings buttons = default, DFlags flags = 0, DIcon icon = 0, AnyWnd owner = default, string expandedText = null, string footer = null, string title = null, DControls controls = null, int defaultButton = 0, Coord x = default, Coord y = default, screen screen = default, int secondsTimeout = 0, Action<DEventArgs> onLinkClick = null)
Parameters
text1 (string)
Main instruction. Bigger font. |
text2 (string)
Text below main instruction. |
buttons (Strings)
Button ids and labels. Examples: |
flags (DFlags) |
icon (DIcon) |
owner (AnyWnd)
Owner window. See dialog.SetOwnerWindow. |
expandedText (string)
Text that the user can show and hide. |
footer (string)
Text at the bottom of the dialog. Icon can be specified like |
title (string)
Title bar text. If omitted, |
controls (DControls)
Can be used to add more controls and later get their values: checkbox, radio buttons, text input. |
defaultButton (int)
id of button that responds to the |
x (Coord)
X position in dialog.Screen. If default - center. Examples: |
y (Coord)
Y position in dialog.Screen. If default - center. |
screen (screen)
dialog.Screen. Examples: |
secondsTimeout (int)
If not 0, after this time (seconds) auto-close the dialog and return dialog.Timeout. |
onLinkClick (Action<DEventArgs>)
A link-clicked event handler function, eg lambda. Enables hyperlinks in small-font text. Example:
|
Returns
int
Selected button id. |
Exceptions
Win32Exception
Failed to show dialog. |
Remarks
Tip: Use named arguments. Example: dialog.show("Text", icon: DIcon.Info, title: "Title")
.
This function allows you to use many dialog features, but not all. Alternatively you can create a dialog class instance, set properties and call ShowDialog. Example in dialog class help.
More info about the buttons parameter
Missing ids are auto-generated, for example "OK|Cancel|100 Custom1|Custom2"
is the same as "1 OK|2 Cancel|100 Custom1|101 Custom2"
.
The first in the list button is default, ie responds to the Enter
key. For example, "2 No|1 Yes"
adds Yes and No buttons and makes No default.
To create keyboard shortcuts, use &
character in custom button labels. Use &&
for literal &
. Example: "1 &Tuesday[]2 T&hursday[]3 Saturday && Sunday"
.
Trims newlines around ids and labels. For example, "\r\n1 One\r\n|\r\n2\r\nTwo\r\n\r\n"
is the same as "1 One|2 Two"
.
There are 6 common buttons: OK, Yes, No, Retry, Cancel, Close. Buttons that have other labels are custom buttons. How common buttons are different:
- DFlags.CommandLinks does not change their style.
- They have keyboard shortcuts that cannot be changed. Inserting
&
in a label makes it a custom button. - Button Cancel can be selected with the
Esc
key. It also adds X (Close) button in title bar, which selects Cancel. - Always displayed in standard order (eg YesNo, never NoYes). But you can for example use
"2 No|1 Yes"
to set default button = No. - The displayed button label is localized, ie different when the Windows UI language is not English.
You can use flag DFlags.CommandLinks to change the style of custom buttons.
See also: dialog.SetButtons.
Examples
if(1 != dialog.show("Continue?", null, "1 OK|2 Cancel", icon: DIcon.Info)) return;
print.it("OK");
switch (dialog.show("Save changes?", "More info.", "1 Save|2 Don't Save|0 Cancel")) {
case 1: print.it("save"); break;
case 2: print.it("don't"); break;
default: print.it("cancel"); break;
}
var con = new DControls { Checkbox = "Check", RadioButtons = "1 One|2 Two|3 Three", EditType = DEdit.Combo, EditText = "zero", ComboItems = ["one", "two"] };
var r = dialog.show("Main text", "More text.", "1 OK|2 Cancel", expandedText: "Expanded text", controls: con, secondsTimeout: 30);
print.it(r, con.IsChecked, con.RadioId, con.EditText);
switch(r) {
case 1: print.it("OK"); break;
case dialog.Timeout: print.it("timeout"); break;
default: print.it("Cancel"); break;
}