Show / Hide Table of Contents

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
Inheritance
object
dialog

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. null if no controls.

DefaultButton

Specifies which button responds to the Enter key. If 0 or not set, auto-selects.

DialogWindow

Gets dialog window handle as wnd.

EditControl

Gets edit control handle as wnd.

IsOpen

Returns true if the dialog is open and your code can send messages to it.

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 true, will set topmost style when creating the dialog. If false, will not set. If null (default), the dialog will be topmost if both these are true: no owner window, dialog.options.topmostIfNoOwnerWindow is true (default).

Width

Sets the width of the dialog's client area.

Methods

Name Description
SetButtons(Strings, bool, Strings)

Sets common and/or custom buttons and custom buttons style.

SetCheckbox(string, bool)

Adds check box (if text is not null/empty).

SetEditControl(DEdit, string, Strings)

Adds Edit or Combo control.

SetExpandControl(bool, string, string)

Set properties of the control that shows and hides text added by dialog.SetExpandedText.

SetExpandedText(string, bool)

Adds text that the user can show and hide.

SetFooter(string)

Adds text and common icon at the bottom of the dialog.

SetFooter(string, DIcon)

Adds text and common icon at the bottom of the dialog.

SetFooter(string, object)

Adds text and custom icon at the bottom of the dialog.

SetIcon(DIcon)

Sets common icon. Or custom icon from app resources.

SetIcon(object)

Sets custom icon.

SetOwnerWindow(AnyWnd, bool, bool)

Sets owner window.

SetRadioButtons(Strings, int)

Adds radio buttons.

SetText(string, string)

Sets text.

SetTimeout(int, string, bool)

Let the dialog close itself after closeAfterS seconds. Then dialog.ShowDialog returns dialog.Timeout.

SetTitleBarText(string)

Changes title bar text. If title is null or "" or this function not called, will use dialog.options.defaultTitle.

SetXY(Coord, Coord, bool)

Sets dialog position in screen.

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.

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.

show(string, string, Strings, DFlags, DIcon, AnyWnd, string, string, string, DControls, int, Coord, Coord, screen, int, Action<DEventArgs>)

Shows dialog.

showError(string, string, Strings, DFlags, AnyWnd, string, string, int)

Shows dialog with DIcon.Error icon.

showInfo(string, string, Strings, DFlags, AnyWnd, string, string, int)

Shows dialog with DIcon.Info icon.

showInput(out string, string, string, DEdit, string, Strings, DFlags, AnyWnd, string, string, string, DControls, Coord, Coord, screen, int, Action<DEventArgs>, string, Action<DEventArgs>)

Shows dialog with a text edit field and gets that text.

showInputNumber(out int, string, string, int?, DFlags, AnyWnd)

Shows dialog with a number edit field and gets that number.

showList(Strings, string, string, DFlags, AnyWnd, string, string, string, DControls, int, Coord, Coord, screen, int, Action<DEventArgs>)

Shows dialog with a list of command-link buttons, and returns 1-based button index or 0.

showNoWait(string, string, Strings, DFlags, DIcon, AnyWnd, string, string, string, DControls, int, Coord, Coord, screen, int, Action<DEventArgs>)

Shows dialog like dialog.show but does not wait. Creates dialog in other thread and returns without waiting until it is closed.

showOkCancel(string, string, DFlags, DIcon, AnyWnd, string, string, int)

Shows dialog with OK and Cancel buttons.

showProgress(bool, string, string, string, DFlags, AnyWnd, string, string, string, DControls, Coord, Coord, screen, int, Action<DEventArgs>)

Shows dialog with progress bar. Creates dialog in new thread and returns without waiting until it is closed.

showWarning(string, string, Strings, DFlags, AnyWnd, string, string, int)

Shows dialog with DIcon.Warning icon.

showYesNo(string, string, DFlags, DIcon, AnyWnd, string, 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 F1.

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.