DCSIMG
Daily Tip: How to Activate Minimized Window (Form) - Maxim

Daily Tip: How to Activate Minimized Window (Form)

This solution can be used in WPF and in WinForms (with some improvements).

Many times UI programmer needs to activate window, the activation can be done by using “Activate()” function in window. The problem is that this function will not show window if it is minimized. In that case you can use this workaround:

using System;
using System.Windows; 

namespace Test
{
       public partial class MyWindow
       {
              /// <summary>
              /// Gets Previouse Window State
              /// </summary>
              public WindowState PreviouseWindowState { get; private set; }  

              /// <summary>
              /// Constructor
              /// </summary>
              public MyWindow()
              {
                     InitializeComponent();

 

                     // store 1st value
                     PreviouseWindowState = WindowState;

 

                     // attach to event (used to store prev. win. state)
                     LayoutUpdated += Window_LayoutUpdated;
              }  

              /// <summary>
              /// Occures on layout change
              /// </summary>
              /// <param name="sender"></param>
              /// <param name="e"></param>
              private void Window_LayoutUpdated(object sender, EventArgs e)
              {
                     PreviouseWindowState = WindowState;
              }  

              /// <summary>
              /// Activates Window
              /// </summary>
              /// <param name="restoreIfMinimized">if [true] restore prev. win. state</param>
              /// <returns></returns>
              public bool Activate(bool restoreIfMinimized)
              {
                     if (restoreIfMinimized && WindowState == WindowState.Minimized)
                     {
                           WindowState = PreviouseWindowState == WindowState.Normal
                                                                     ? WindowState.Normal : WindowState.Maximized;
                     }
                     return Activate();
              }
       }
} 

As you can see I added new overloaded function “Activate(bool)” that allows activation of minimized window, thanks to new property “PreviouseWindowState” that stores previous value of “WindowState” when “Window_LayoutUpdated” in called.

Source Code: Window.cs

Remarks: Any comments/improvements will be accepted with pleasure. Of course, you must understand that this code is a contribution and I’m not responsible for any damage that may be caused by using it. All rights reserved ®.

Comments

# re: Daily Tip: How to Activate Minimized Window (Form)

Friday, December 25, 2009 2:22 AM by sam

thanks :)

your trick helped me!

# Single Instance Application Manager

Saturday, February 13, 2010 10:24 PM by Maxim

Some .Net applications are required to run as single instance process (at startup, each process “ensures

# re: Daily Tip: How to Activate Minimized Window (Form)

Saturday, February 13, 2010 10:27 PM by Maxim

10x

# re: Daily Tip: How to Activate Minimized Window (Form)

Wednesday, February 17, 2010 10:44 PM by Odina

Hi all. Greetings to all. Help me! I can not find sites on the: Non electric waffle iron. I found only this - <a href="www.isola4you.org/.../electric-branding-iron-for-cattle">electric branding iron for cattle</a>. Although appropriate barbequing hours could heat apparatus lights which add wrestler knowledge from camera without winding simple sectors of versatile wastes, the higher application of the wall of these products may retrofit the grafting of affordable note, electric iron. Electric iron, it held at time 1 on the evaluation ingredients and found power contact. With best wishes :-), Odina from Arabia.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, March 04, 2010 9:28 PM by Steph

Hello,

First thanks a lot!

I got some troubles with the Windows State restoration and finally did:

       private void Main_Resize(object sender, EventArgs e)

       {

           if(WindowState != FormWindowState.Minimized) PreviouseWindowState = WindowState;

       }

       public void Activate(bool RestoreIfMinimized)

       {

           if (RestoreIfMinimized && (WindowState == FormWindowState.Minimized))

           {

               WindowState = PreviouseWindowState;

           }

           Activate();

       }

Which made it.

Steph.

# re: Daily Tip: How to Activate Minimized Window (Form)

Wednesday, October 24, 2012 1:19 AM by seo

Plz don't erase this particular publish. I want seek attribute in Exotic Concept. Plz help me.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 4:49 PM by Shaffer

George Forman used to have a monopoly in the genre of former athletes marketing indoor counter top grills.

Now unplug and open the Belgian waffle maker to confirm if it is properly baked.

Another to let you know the baking is in progress and the final light that

tells the cook the product is done.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:00 PM by Gavin

The Valor Fitness BG-11 10 Pair Dumbbell Rack comes with protective rubber base caps and four

angled iron beams. Take a chest press for example; the main muscle worked is the chest,

secondary maybe the triceps. To add variety to your routine one

must mix up your reps, sets, weight used, rest periods, exercises, duration, and intensity.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:05 PM by Vanwinkle

5. Who's gonna keep 'em down. Along the various groups of survivors

the doctor manages to outlive, he finds that the infection

may have been started by a food processing plant and an additive

that is found in nearly every food and beverage.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:08 PM by Henderson

Stand upright, knees slightly bent, shoulder

width apart, holding dumbbells in front of thighs. Start a jogging

or walking club with some neighbors. Nowadays, the Bowflex produces the

optimum durability creating exercise and has special designs in comparison to

other machines.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:15 PM by Mcbee

It will also tell you when it is time to change your brushing direction and all the other things that those LCD's used to do. For people who brush their teeth more often, the bristles may begin to wear out sooner than expected. Another reason that electric toothbrushes have become more popular in recent years is because the price of it has gone down tremendously.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:21 PM by Jewell

Surrounding the crystal was a bright sphere of Divine golden light.

So you won't have to stumble around in the middle of the night to turn up or down the heater. With its Herculean power, the wind is capable of slipping into the home through tiny cracks in the windows and underneath the doors.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:50 PM by Ruiz

Here are the four most important ways slow cookers save you money:

1. College kids gain on average about ten pounds the first year.

Consumer Product Safety Commission (CPSC) is still interested in receiving

incident or injury reports that are either directly related to this product recall or involve a different hazard with the same product.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 5:52 PM by Cathey

Here are my thoughts on the Durabrand Waffle Maker. When it comes to any kind of cookware or kitchen

appliance, Wolfgang Puck remains to be at the top of the game.

Modern makers of the waffle iron give us the challenge of

choices on a large scale.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 7:04 PM by Ashe

But having bought such an expensive product there

are some care instructions hat needs to be followed to derive the maximum benefits.

The allergens in these compounds could be bad for people with sensitive skin, and some believe that long term exposure may be linked to certain cancers, like those of the ***.

The summer time is the best time to have skin exfoliation.

# re: Daily Tip: How to Activate Minimized Window (Form)

Thursday, April 04, 2013 9:08 PM by Pruett

Believe it or not, just by sitting down during this bicep curl workout will actually

add a degree of intensity. Depending on the manufacturer,

the cost of a set will vary. This set is performed using a set of dumbbells that can be lifted alternately or

simultaneously.

# re: Daily Tip: How to Activate Minimized Window (Form)

Friday, April 05, 2013 1:27 AM by Wild

Examples are : A Heartful of Love, Be Mine,

Be My Valentine etc. Therefore your needs will change in a

supplier to purchase your goods from. Let the kids make whatever they want out of the Activ-Clay.

# re: Daily Tip: How to Activate Minimized Window (Form)

Friday, April 05, 2013 3:47 PM by Morrissey

It was small enough to get into all the small hard-to-clean places.

As for the UV sanitizer, you can use it every day or just once a week.

Users usually would not need to worry regarding the battery life

of digital toothbrush indeed.

# re: Daily Tip: How to Activate Minimized Window (Form)

Monday, April 08, 2013 12:03 AM by Mann

Here are a few tips to help prevent and quickly clear up acne breakouts using natural, organic skin care products:

1) Wash your face gently two times per day with warm water and a mild soap such as a goats milk soap.

The term natural means only pure ingredients are used directly from nature

as opposed to synthetic ingredients and organic products simply means that the molecule

comprises of carbon and natural skin care products have no boundaries with

regards to organic or natural products. One of the products I bought

is the Rooting Bear Rub.

# re: Daily Tip: How to Activate Minimized Window (Form)

Monday, April 08, 2013 12:06 AM by Clancy

Michaels offers a large variety of yarn, thread, floss, kits and cutting tools.

You only want to shell out for genuine delivers so be mindful if you are needed for any fee or

membership to get access to these coupons. Every time I go into A.

# re: Daily Tip: How to Activate Minimized Window (Form)

Monday, April 08, 2013 12:40 AM by Skipper

Here are the four most important ways slow cookers save you money:1.

Don't forget Crockpot's (slow cookers) are a great way to save money; My Crockpot (slow cooker) black beans are the easiest to make, taste great and

are super inexpensive and healthy. Move any flammable objects away from the slow cooker.

# re: Daily Tip: How to Activate Minimized Window (Form)

Monday, April 08, 2013 1:35 AM by Flores

But, being laughed at while preparing for a possible zombie 2012 apocalypse,

or other consequences of the end of the Mayan calendar is going to be worth it - when the

unimaginable and previously comically impossible actually come to life.

The two shows this year have been advertised as:.

It concerns the mysterious horrors of a "flesh consuming" existence, symbolically speaking more or less, that depict the grotesque lawlessness and selfishness of humankind.

# re: Daily Tip: How to Activate Minimized Window (Form)

Monday, April 08, 2013 1:48 AM by Epperson

They have had them on since, and haven't once tried to remove them. It only takes a second for a child or pet to receive a serious burn. On a $200 a month gas bill, this would lower the bill by $50.

# Daily Tip: How to Activate Minimized Window (Form) - Maxim

Thursday, April 11, 2013 5:51 AM by rankbd.com

" This means that the most effective electric toothbrushes will be those that offer this type of technology, as it offers a better clean and better dental care and prevention than other electric toothbrushes on the market today. An electric toothbrush

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: