# Min/Max all windows currently open

This topic is 3617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all, I was just messing around today trying to implement a windows form that is transparent. On it I placed a simple label with a message saying press a key to min/max all open windows. The problem I have, is that the form will loose focus (not be the currently active form) upon undo of minimized windows. Is there a way to make it always topmost and always the currently active application?
using System;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Minimize_Open_Windows
{
public partial class Form1 : Form
{
bool minimized;
Shell32.ShellClass shell = new Shell32.ShellClass();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
shell.MinimizeAll();
minimized = true;
this.Show();
}

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (minimized)
{
shell.UndoMinimizeALL();
label1.Text = "Press any key to minimize all windows!";
minimized = false;
}
else
{
shell.MinimizeAll();
label1.Text = "Press any key to maximize all windows!";
minimized = true;
}
}
}
}

I have tried various combinations of this.Activate(), this.Topmost = true, this.focus() and nothing seems to work correctly. Using .net 2.0 and VS 2005 on a Vista Ultimate environment. Any suggestions? Thanks, Shawn

##### Share on other sites
Quote:
 Is there a way to make it always topmost and always the currently active application?

You can't. Consider what would happen if there were two applications running that both wanted to be topmost and have the input focus all the time...

Also, what's wrong with the built in shortcut of Windows key + D to minimize / restore all windows?

##### Share on other sites
Nothing is wrong with the Win-D combo. I was just messing around and trying to do it in code but keep focus and all. Thanks for the info though.

• 34
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631355
• Total Posts
2999519
×