Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Show modeless WinForms/WPF dialogs centerd on Revit's window

1 REPLY 1
SOLVED
Reply
Message 1 of 2
christostsar
215 Views, 1 Reply

Show modeless WinForms/WPF dialogs centerd on Revit's window

Is it possible to show a modeless WinForms or WPF dialog cented on Revit's window?

How would the window position and width/height be retrieved for this to be possible?

1 REPLY 1
Message 2 of 2
RPTHOMAS108
in reply to: christostsar

Yes but you have to set the parent/owner

 

For WPF use

Dim Win As New Window()
Dim WHlp1 As New Interop.WindowInteropHelper(Win)
WHlp1.Owner = commandData.Application.MainWindowHandle

RPTHOMAS108_0-1691021829084.png

 

For Forms use

    Public Class RevitWindow
        Implements IWin32Window

        Public ReadOnly Property Handle As IntPtr Implements IWin32Window.Handle
        Public Sub New(UIApp As UIApplication)
            Handle = UIApp.MainWindowHandle
        End Sub
    End Class
    Private Function Obj_XXa(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData,
ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Result

        Dim RW As New RevitWindow(commandData.Application)
        Dim Form1 As New Windows.Forms.Form
        Form1.ShowDialog(RW)

        Return Result.Succeeded

    End Function

RPTHOMAS108_1-1691022597520.png

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report