3
votes

I am making an application which will have an interface similar to Photoshop: multiple separate forms all help edit an object. So, i'll have multiple forms, one of which is "main" (provides file menu, settings menu, about etc) and others have controls that edit the object opened in main form.

Lets say for simplicity this is a text editor and i have MainForm and StyleForm. Now, what i need is for the whole application to show as one "bar" in the windows taskbar. This could be achieved by setting ShowInTaskbar to false for StyleForm, but then if i, say, focus other application, then focus my application, only MainForm will get on top of other windows, StyleForm will remain hidden under the window of the application i focused previously.

I found answer here Make all forms associated with a program come to the front when one form is selected but it imports a dll. Maybe there is a .net solution for this?

Also, i'd like to display something different in the taskbar, not the MainForm's caption, is that possible?

2
if both of these forms do exists in same process (same exe project or dll project) then cant you invoke a delegate and make the form also visible?Zenwalker

2 Answers

11
votes

I set the second form to ShowInTaskBar = false, set the FormBorderStyle to SizableToolWindow and then created it using the following code:

public partial class Form1 : Form
{
    Form2 f2;

    public Form1()
    {
        InitializeComponent();

        f2 = new Form2();
        f2.Owner = this;  // <-- This is the important thing
        f2.Show();
    }
}

This makes the subform F2 stay on top of Form1 and hides and shows it when the Form1 is hidden and shown.

EDIT
Oh, I used Visual Studio 2010 and .NET 4 Client Profile if that's important. This should work with other versions, however.

0
votes

In the main window, you could catch the Focus event and then for each subform call the BringToFront method