Class dialog
Standard dialogs to show information or get user input.
public class dialog
Remarks
You can use static functions (less code) or create class instances (more options). More info: dialog.show.
Uses task dialog API TaskDialogIndirect.
Cannot be used in services. Instead use MessageBox.Show with option ServiceNotification or DefaultDesktopOnly, or API MessageBox with corresponding flags.
Examples
Simple examples.
dialog.show("Info");
string s = "More info.";
dialog.showInfo("Info", s);
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();
d.SetText("Main text.", "More text.\nSupports <a href=\"link data\">links</a> if you subscribe to HyperlinkClicked event.");
d.SetButtons("1 OK|2 Cancel|3 Custom|4 Custom2");
d.SetIcon(DIcon.Warning);
d.SetExpandedText("Expanded info\nand more info.", true);
d.CanBeMinimized = true;
d.SetCheckbox("Check");
d.SetRadioButtons("1 r1|2 r2");
d.SetTimeout(30, "OK");
d.HyperlinkClicked += e => { dialog.show("link clicked", e.LinkHref, owner: e.hwnd); };
d.ButtonClicked += e => { print.it(e.Button); if(e.Button == 4) e.DontCloseDialog = true; };
d.ProgressBar = true; 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
Constructors
Name | Description |
---|---|
dialog(string, string, Strings, DFlags, DIcon, AnyWnd, string, string, string, DControls, int, Coord, Coord, screen, int, Action<DEventArgs>) | Initializes a new dialog instance and sets main properties. |
Fields
Name | Description |
---|---|
Timeout | The return value of ShowX functions on timeout. |
Properties
Name | Description |
---|---|
CanBeMinimized | Add Minimize button to the title bar. |
Controls | After closing the dialog contains values of checkbox, radio buttons and/or text edit control.
|
DefaultButton | Specifies which button responds to the |
DialogWindow | Gets dialog window handle as wnd. |
EditControl | Gets edit control handle as wnd. |
IsOpen | Returns |
ProgressBar | Show progress bar. |
ProgressBarMarquee | Show progress bar that does not indicate which part of the work is already done. |
Result | Selected button id. The same as the dialog.ShowDialog return value. |
RtlLayout | Right-to left layout. Default = dialog.options.rtlLayout. |
Screen | Sets the screen (display monitor) where to show the dialog in multi-screen environment. |
Send | Allows to modify dialog controls while it is open, and close the dialog. |
Topmost | Makes the dialog window topmost or non-topmost.
If |
Width | Sets the width of the dialog's client area. |
Methods
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. |