Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2010
Syntax
C# |
---|
public event EventHandler<DialogBoxShowingEventArgs> DialogBoxShowing |
Visual Basic |
---|
Public Event DialogBoxShowing As EventHandler(Of DialogBoxShowingEventArgs) |
Visual C++ |
---|
public: event EventHandler<DialogBoxShowingEventArgs^>^ DialogBoxShowing { void add (EventHandler<DialogBoxShowingEventArgs^>^ value); void remove (EventHandler<DialogBoxShowingEventArgs^>^ value); } |
Remarks
This event is raised when Revit is just about to show a dialog box or a message box.
Event is not cancellable. The 'Cancellable' property of event's argument is always False.
Depending on the type of the dialog that is being shown, the event's argument's type varies as follows: When it is a dialog box, the event's argument is an object of DialogBoxShowingEventArgs. When it is a message box, the event's argument is an object of MessageBoxShowingEventArgs,which is subclass of DialogBoxShowingEventArgs. When it is a task dialog, the event's argument is an object of TaskDialogShowingEventArgs,which is subclass of DialogBoxShowingEventArgs.
No document may be modified during this event.
The following API functions are not available for the current document during this event:
- Close()()()() and similar overloads.
- Save()()()() and similar overloads.
- SaveAs(String) and similar overloads.
Exception InvalidOperationException will be thrown if any of the above methods is called during this event.
Examples

public class Application_DialogBoxShowing : IExternalApplication { // Implement the OnStartup method to register events when Revit starts. public Result OnStartup(UIControlledApplication application) { // Register related events application.DialogBoxShowing += new EventHandler<Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs>(AppDialogShowing); return Result.Succeeded; } // Implement this method to unregister the subscribed events when Revit exits. public Result OnShutdown(UIControlledApplication application) { // unregister events application.DialogBoxShowing -= new EventHandler<Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs>(AppDialogShowing); return Result.Succeeded; } // The DialogBoxShowing event handler, which allow you to // do some work before the dialog shows void AppDialogShowing(object sender, DialogBoxShowingEventArgs args) { // Get the string id of the showing dialog String dialogId = args.DialogId; // Format the prompt information string String promptInfo = "A Revit dialog will be opened.\n"; promptInfo += "The DialogId of this dialog is " + dialogId + "\n"; promptInfo += "If you don't want the dialog to open, please press cancel button"; // Show the prompt message, and allow the user to close the dialog directly. TaskDialog taskDialog = new TaskDialog("Revit"); taskDialog.Id = "Customer DialogId"; taskDialog.MainContent = promptInfo; TaskDialogCommonButtons buttons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel; taskDialog.CommonButtons = buttons; TaskDialogResult result = taskDialog.Show(); if (TaskDialogResult.Cancel == result) { // Do not show the Revit dialog args.OverrideResult(1); } else { // Continue to show the Revit dialog args.OverrideResult(0); } } }

Public Class Application_DialogBoxShowing Implements IExternalApplication ' Implement the OnStartup method to register events when Revit starts. Public Function OnStartup(application As UIControlledApplication) As Autodesk.Revit.UI.Result Implements IExternalApplication.OnStartup ' Register related events AddHandler application.DialogBoxShowing, AddressOf AppDialogShowing Return Result.Succeeded End Function ' Implement this method to unregister the subscribed events when Revit exits. Public Function OnShutdown(application As UIControlledApplication) As Autodesk.Revit.UI.Result Implements IExternalApplication.OnShutdown ' unregister events RemoveHandler application.DialogBoxShowing, AddressOf AppDialogShowing Return Result.Succeeded End Function ' The DialogBoxShowing event handler, which allow you to ' do some work before the dialog shows Private Sub AppDialogShowing(sender As Object, args As DialogBoxShowingEventArgs) ' Get the string id of the showing dialog Dim dialogId As String = args.DialogId ' Format the prompt information string Dim promptInfo As [String] = "A Revit dialog will be opened." & vbLf promptInfo += "The DialogId of this dialog is " & dialogId & vbLf promptInfo += "If you don't want the dialog to open, please press cancel button" ' Show the prompt message, and allow the user to close the dialog directly. Dim taskDialog As New TaskDialog("Revit") taskDialog.Id = "Customer DialogId" taskDialog.MainContent = promptInfo Dim buttons As TaskDialogCommonButtons = TaskDialogCommonButtons.Ok Or TaskDialogCommonButtons.Cancel taskDialog.CommonButtons = buttons Dim result As TaskDialogResult = taskDialog.Show() If TaskDialogResult.Cancel = result Then ' Do not show the Revit dialog args.OverrideResult(1) Else ' Continue to show the Revit dialog args.OverrideResult(0) End If End Sub End Class