revit-wpf-template icon indicating copy to clipboard operation
revit-wpf-template copied to clipboard

Enhancement : Set parent to Revit

Open MarkAckerley opened this issue 5 years ago • 1 comments

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

MarkAckerley avatar Jul 06 '20 09:07 MarkAckerley

@MarkAckerley thanks for getting this up here - I'll build and test locally when I have a chance. If you want, feel free to open up a pull request with those changes as well.

mitevpi avatar Jul 06 '20 13:07 mitevpi