Jump to content
  • Advertisement
Sign in to follow this  
shawnre

Min/Max all windows currently open

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!