Insider Interno
Insider Interno

Reputation: 17

C# - Show form under other applications

Is it possible to create a form that always remains under other applications?

Because the following property exists:

this.TopMost = true;

but there is no property like:

this.BottomMost = true;

Each time the user clicks on the form, it is not positioned at the top level, as normally happens, but remains below other applications. However when the user presses show desktop or Win + D, the desktop is shown but with the form on top.

The form is shown as a kind of Windows Gadget, but it is not a gadget since in Windows 10 they are difficult to activate.

Upvotes: 1

Views: 399

Answers (1)

Haverka
Haverka

Reputation: 38

If the form doesn't need to be shown at all times, then just use this code:

       public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.Activated += Form1_Activated;
        this.KeyDown += Form1_KeyDown;
    }

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.D && e.Control)
        {
            Shell32.ShellClass shell = new Shell32.ShellClass();
            shell.MinimizeAll();
            this.Show();
        }
    }

    private void Form1_Activated(object sender, EventArgs e)
    {
        this.Hide();
    }
}

However, you need to add a COM reference named "Microsoft Shell Controls And Automation" Also, you will need to change the Form1_KeyDown to something out of this: Global keyboard capture in C# application

Upvotes: 0

Related Questions