Keep tool always above Tekla Strucures
Updated:
13 May 2019
This guide introduces two options on how to keep the tool above Tekla Structures:
- Set Tekla Structures to be the parent form of the tool and call API methods inside a thread (see Keep logic and user interface separate).
For example, all picker calls must be done with asynchronous calls; that is, with background worker. It is not possible to use picker from dialog thread if child windowing is used.private void button1_Click(object sender, EventArgs e) { System.ComponentModel.BackgroundWorker BackgroundWorker = new System.ComponentModel.BackgroundWorker(); BackgroundWorker.DoWork += delegate { Picker P = new Picker(); try { ModelObject MO = P.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT) as ModelObject; if(Tekla.Structures.Model.Operations.Operation.IsNumberingUpToDate(MO)) MessageBox.Show("NumberingUpToDate"); else MessageBox.Show("Numbering not UpToDate"); } catch { } }; BackgroundWorker.RunWorkerAsync(); }
-
Do not set the parent form of the tool but instead force it to be topmost or modal.
The simplest way to set the tool above Tekla Structures is to show the tool as a child of the Tekla Structures window. This requires a small change in the startup code. The examples below uses Tekla application library.
-
Change the startup code (usually in Program.cs file) from this:
​Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 form1 = new Form1(); form1.Show(TeklaStructures.MainWindow); Application.Run(form1);
Now the tool acts as a child window and stays always on top of the Tekla Structures main window. The tool is also hidden when the main window is minimized.