Restrict to open same window multiple times in autocad and inventor

Restrict to open same window multiple times in autocad and inventor

Anonymous
Not applicable
526 Views
2 Replies
Message 1 of 3

Restrict to open same window multiple times in autocad and inventor

Anonymous
Not applicable

How to restrict to open same window multiple times in autocad and inventor?

The scenario is when any window in autocad or inventor is opened then if we again try to open the same window then it will get opened and multiple same window get displayed.

 

So i want to restrict to open a window if the window is already opened.

Is there any solution for this?

Here is the code to open a window.

code to open a windowcode to open a window

0 Likes
527 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant

Hi,

 

You should either use a modal dialog or, if you need a modelss UI, use a PaletteSet.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 3

m.cicognani
Contributor
Contributor

Something like this?

 

            // check if another window of the same type is already open
            foreach (System.Windows.Forms.Form f in System.Windows.Forms.Application.OpenForms)
            {
                if (f is frmBatchManager)
                {
                    if (f.WindowState != System.Windows.Forms.FormWindowState.Normal) f.WindowState = System.Windows.Forms.FormWindowState.Normal;

                    f.BringToFront();
                    return;
                }
            }

            // Not found, open a new modeless window
            frmBatchManager dlg = new frmBatchManager();
            Application.ShowModelessDialog(dlg);
0 Likes