Class dialog
Standard dialogs to show information or get user input.
public class dialog
Remarks
You can use static functions like dialog.show (less code) or create class instances.
Uses task dialog API TaskDialogIndirect.
Cannot be used in services. Instead use System.Windows.Forms.MessageBox.Show with option ServiceNotification or DefaultDesktopOnly, or API MessageBox with corresponding flags, or API WTSSendMessage.
Examples
Simple examples.
dialog.show("Example", "Message.);
if(!dialog.showYesNo("Continue?", "More info.")) return;
switch(dialog.show("Save?", "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;
}
if(!dialog.showInput(out string s, "Example")) return;
print.it(s);
This example creates a class instance, sets properties, shows dialog, uses events, uses result.
var d = new dialog("Example", "Message.");
d.Buttons("1 OK|2 Cancel|3 Custom|4 Custom2", asCommandLinks: true)
.Icon(DIcon.Warning)
.ExpandedText("Expanded info.", true)
.Checkbox("Check")
.RadioButtons("1 r1|2 r2")
.CloseAfter(30, "OK");
d.ButtonClicked += e => { print.it(e.Button); if(e.Button == 4) e.DontCloseDialog = true; };
d.Progress();
d.Timer += e => { e.d.Send.Progress(e.TimerTimeMS / 100); };
var r = d.ShowDialog();
print.it(r, d.Controls.IsChecked, d.Controls.RadioId);
switch(r) { case 1: print.it("OK"); break; case dialog.Timeout: print.it("timeout"); break; }
Namespace: Au
Assembly: Au.dll
Inheritance
Constructors
| Name | Description |
|---|---|
| dialog(string, DText, Strings, DFlags, DIcon, AnyWnd, DText, DText, string, DControls, Coord, Coord, screen, int) | Initializes a new dialog instance and sets main properties. |
Fields
| Name | Description |
|---|---|
| Timeout | The return value of |
Properties
| Name | Description |
|---|---|
| Controls | After closing the dialog contains values of checkbox, radio buttons and/or text edit control.
|
| DialogWindow | Gets dialog window handle as wnd. |
| EditControl | Gets edit control handle as wnd. |
| IsOpen | Returns |
| Result | Selected button id. The same as the dialog.ShowDialog return value. |
| Send | Allows to modify dialog controls while it is open, and close the dialog. |
Methods
| Name | Description |
|---|---|
| Buttons(Strings, bool) | Sets buttons. |
| ButtonsList(Strings, bool) | Sets custom buttons to be displayed as a list. |
| Checkbox(string, bool) | Adds check box (if text is not |
| CloseAfter(int, string, bool) | Sets to automatically close the dialog after timeoutS seconds. Then dialog.ShowDialog returns dialog.Timeout. |
| Default(int) | Sets default button. It responds to the |
| Edit(DEdit, string, Strings) | Adds Edit or ComboBox control. |
| ExpandedText(DText, bool) | Adds text in expander control. |
| Expander(bool, string, string) | Set properties of the expander control that shows and hides text added by dialog.ExpandedText. |
| FooterIcon(DIcon) | Adds footer icon. |
| FooterIcon(object) | Sets footer icon. |
| FooterText(DText) | Adds footer text. |
| Icon(DIcon) | Sets common icon. |
| Icon(object) | Sets custom icon. |
| InScreen(screen) | Sets the screen (display monitor) where to show the dialog in multi-screen environment. |
| OwnerWindow(AnyWnd, bool, bool) | Sets owner window. |
| Progress(bool, bool) | Sets progress bar. |
| RadioButtons(Strings, int) | Adds radio buttons. |
| ShowDialog() | Shows the dialog. Call this method after setting text and other properties. |
| ShowDialogNoWait() | Shows the dialog in new thread and returns without waiting until it is closed. |
| Text1(string) | Sets heading text. |
| Text2(DText) | Sets message text. |
| ThreadWaitForClosed() | Can be used by other threads to wait until the dialog is closed. |
| ThreadWaitForOpen() | Can be used by other threads to wait until the dialog is open. |
| Title(string) | Sets title bar text. If not set, will use dialog.options.defaultTitle. |
| Wider(int) | Makes the dialog wider. |
| XY(Coord, Coord, bool) | Sets dialog position in screen. |
| show(string, DText, Strings, DFlags, DIcon, AnyWnd, DText, DText, string, DControls, Coord, Coord, screen, int) | Shows dialog. |
| showError(string, DText, Strings, DFlags, AnyWnd, DText, string, int) | Shows dialog with DIcon.Error icon. |
| showInfo(string, DText, Strings, DFlags, AnyWnd, DText, string, int) | Shows dialog with DIcon.Info icon. |
| showInput(out string, string, DText, DEdit, string, Strings, DFlags, AnyWnd, DText, DText, string, DControls, Coord, Coord, screen, int, string, Action<DEventArgs>) | Shows dialog with a text edit field and gets that text. |
| showInputNumber(out int, string, DText, int?, DFlags, AnyWnd) | Shows dialog with a number edit field and gets that number. |
| showList(Strings, string, DText, DFlags, AnyWnd, DText, DText, string, DControls, Coord, Coord, screen, int) | Shows dialog with a list of command-link buttons, and returns 1-based button index or 0. |
| showNoWait(string, DText, Strings, DFlags, DIcon, AnyWnd, DText, DText, string, DControls, Coord, Coord, screen, int) | Shows dialog like dialog.show but does not wait. Creates dialog in other thread and returns without waiting until it is closed. |
| showOkCancel(string, DText, DFlags, DIcon, AnyWnd, DText, string, int) | Shows dialog with OK and Cancel buttons. |
| showProgress(bool, string, DText, string, DFlags, AnyWnd, DText, DText, string, DControls, Coord, Coord, screen, int) | Shows dialog with progress bar. Creates dialog in new thread and returns without waiting until it is closed. |
| showWarning(string, DText, Strings, DFlags, AnyWnd, DText, string, int) | Shows dialog with DIcon.Warning icon. |
| showYesNo(string, DText, DFlags, DIcon, AnyWnd, DText, string, int) | Shows dialog with Yes and No buttons. |
Events
| Name | Description |
|---|---|
| ButtonClicked | When the user selects a button. |
| Created | After the dialog has been created and before it is displayed. |
| Destroyed | When the dialog is closed and its window handle is no longer valid. |
| HelpF1 | When the user presses |
| HyperlinkClicked | When the user clicks a hyperlink in the dialog text. |
| OtherEvents | Events other than dialog.Created, dialog.Destroyed, dialog.Timer, dialog.ButtonClicked, dialog.HyperlinkClicked, dialog.HelpF1. See API TaskDialogCallbackProc. |
| Timer | Every 200 ms. |