Skip to content

Enhancement : Set parent to Revit #5

@MarkAckerley

Description

@MarkAckerley

This keeps the window ontop of Revit when it is opened, minimises it with Revit and additionally stops the window showing on the task bar.

Test code originally from here https://stackoverflow.com/questions/55339082/is-this-a-way-to-show-a-modeless-dialog-from-a-dockable-pane-using-wpf (I'm sure you will improve it!)

public void ShowForm(UIApplication uiapp)
        {
            // If we do not have a dialog yet, create and show it
            if (_mMyForm != null && _mMyForm == null) return;
            //EXTERNAL EVENTS WITH ARGUMENTS
            EventHandlerWithStringArg evStr = new EventHandlerWithStringArg();
            EventHandlerWithWpfArg evWpf = new EventHandlerWithWpfArg();

            _mMyForm = new Ui(uiapp, evStr, evWpf);

            HwndSource hwndSource = HwndSource.FromHwnd(uiapp.MainWindowHandle);
            System.Windows.Window wnd = hwndSource.RootVisual as System.Windows.Window;
            if (wnd != null)
            {
                _mMyForm.Owner = wnd;
                _mMyForm.ShowInTaskbar = false;
                _mMyForm.Show();
            }
        }

Cheers,

Mark

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions