Click here to Skip to main content
14,975,411 members
Articles / Desktop Programming / MFC
Posted 3 Jan 2003


22 bookmarked

PowerMini v1.2 - add a new minimizing feature with your browser.

Rate me:
Please Sign up or sign in to vote.
2.50/5 (5 votes)
16 Jan 20035 min read
Opens your default browser while minimizing all other windows. A very simple Win32 application.

Sample Image - powermini.jpg


This idea mainly came to me while working on my old Fujitsu 266 Mhz, running Windows 2000, with only 64MB of RAM. Internet browsing was painfully slow. When I had multiple windows open and maximized/restored down, it was most excruciating! Yes, I could just click on "Show Desktop", then click on my IE shortcut, but that's 2 clicks man!! Come on! I wanted an option on Internet Explorer to minimize all other windows, then open my new instance of IE. This should be an option, if you ask me, but is not. So forth was born PowerMini!

Introduction cont'd

This article does not have great coding content but has potential to become a great CP community application or at least, influence browser developers to include minimizing other windows when starting, as an option. Another motivating factor for me to make this article: I am tired of seeing "Articles Submitted 0" in my profile. I have published one article on CodeGuru though.

I would also like to disclaim, that none of the code was written by me. The meat of the app was by Tone Skoda and is noted in the source. It took me a long time to find a function to handle the minimizing of windows. Now I kind of threw the application together and have tried to comment it to the best I could. I know there are improvements that could be made to the code, that I am sure people will point out. This will be good. It will help me become a better programmer, since I am a stand alone, self-taught programmer, big thanks to CP! This function definitely needs improving! I tried searching around to see how I could get my hands on getting the default browser, but no luck, and scrapped investing anymore time into it. Feel free to improve this part! (Started improving in v1.1).


I think it would be great if others would add what they would like to see in this application, instead of asking me to write the code. For example, someone gets an idea, that someone writes the code, that person posts a discussion message with the added code, I will update the source and application version in the article.

Setting up PowerMini for Use

You have two options. Download the installation only file, above. This installs it for you, with no source code included.


  1. Download the file (Demo project above). This contains the VC6 project and some extra resources files. Then extract to desired folder.
  2. Locate the PowerMini.exe file in the Release subfolder and create a shortcut to the desktop (right-click > Send to > Desktop)
  3. Drag and Drop the PowerMini shortcut to your QuickLaunch Toolbar. NOTE: You may change the shortcut icon to any of the 5 different icons included in the .exe. Feel free to design and add your own, they will probably be better than mine :)

I personally have the regular IE shortcut in my QuickLaunch toolbar with PowerMini right next to it.

The Code Version 1.2

This 1.2 update was needed after trying to add Crazy Browser to the list of supported browsers. I think Crazy Browser sets itself as the default browser correctly (or incorrectly), as mentioned I have not found any well documented information about how Windows finds the default web browser. Anyway, Crazy Browser when setting itself as the default browser, writes a registry key to HKEY_CLASSES_ROOT\htmlfile\shell in the registry and NOT to HKEY_CLASSES_ROOT\htmlfile\shell\open\command! Which kind of creates some problems, on my Windows 98se machine at work (not on my WinXP laptop though?!?). If Crazy Browser is your default browser and you use an internet shortcut, it opens whatever is in the HKEY_CLASSES_ROOT\htmlfile\shell\open\command path instead of Crazy Browser, maybe this is why it is called "Crazy"Image 2, sorry couldn't resist. The PowerMini v1.2 now has 2 supporting functions instead of 1.

  • CString GetRegKey(HKEY m_Folder, CString str_Path, CString str_Name) returns any given registry REG_SZ data.
  • CString GetHomePage() returns the users' homepage URL.
#include <span class="code-string">"stdafx.h"</span>
#include <span class="code-string">"resource.h"</span>
////by Tone Skoda 
#include <span class="code-keyword"><windows.h></span>
#include <span class="code-keyword"><windowsx.h></span>

#define M_MINIMIZE  //minimize all desktop windows
#undef M_RESTORE   //restore all desktop windows
#undef M_CLOSE     //close all desktop windows
////End of code by Tone Skoda 

HICON    m_hIcon;
CString str_Browser;
  //holds "iexplore.exe", "Netscp.exe", or 
  //"yourpath:\Crazy Browser\Crazy Browser.exe" for now
  //Must get filename so ShellExecute may 
  //open multiple instances.
//end of Globals

//Helper Function to return REG_SZ data
CString GetRegKey(HKEY m_Folder, 
      CString str_Path, CString str_Name)
    CString str_KeyOut;

extern const char *MyKeys;
    #define MY_BUFSIZE2 120 // Arbitrary initial value.
    HKEY hKey1;
    TCHAR szData[MY_BUFSIZE2];
    DWORD dwBufLen2 = MY_BUFSIZE2;
    LONG lRet1;

//Find Registry Data
          lRet1 = RegQueryValueEx(hKey1,
        //Turn TCHAR into CString
       str_KeyOut = szData;


    return str_KeyOut;

CString GetHomePage()
    extern CString str_Browser;
    CString str_BrowserName;
    CString str_HomePageOut;
    DWORD dwBufLen2 = MY_BUFSIZE2;
    //See if Default Browser's Name is 
    //written and Assign to local var
    str_BrowserName = 

    //if there is a value here navigate to corresponding regfolder
    if (str_BrowserName != "")
        if(str_BrowserName == "CrazyBrowser")
            str_Browser = GetRegKey(HKEY_CLASSES_ROOT,
            //Remove it's flag
            str_Browser.Replace(" \"%1\"", "");    
        else if(str_Browser != "\"iexplore.exe\"" || "\"Netscp.exe\"")
            AfxMessageBox("Sorry, Your default browser is 
                not IE or Netscape.\r\
                Please email me your browser's registry homepage 
                key so I may update this program and source.\r\
        str_Browser = GetRegKey(HKEY_CLASSES_ROOT,

        //Remove any flags on end
        int int_length, int_flagstart, int_chrtoDelete;
        int_length = str_Browser.GetLength();
        int_flagstart = str_Browser.Find(" -");
        int_chrtoDelete = int_length - int_flagstart;
        str_Browser.Delete(int_flagstart, int_chrtoDelete);

        //we need to get just the filename
        //recount length
        int_length = str_Browser.GetLength();
        //find pos of "\" before file name
        int_flagstart = str_Browser.ReverseFind('\\');
        //get length of filename
        int_chrtoDelete = int_length - int_flagstart;
        //get length of char to delete
        int_chrtoDelete = int_length - int_chrtoDelete;
        //start deleting after the first "
        str_Browser.Delete(1, int_chrtoDelete);

        //Now we know the Default Browser, Lets get it's Homepage
        if(str_Browser == "\"Netscp.exe\"")
            //Get Netscape's homepage reg entry
            str_HomePageOut = GetRegKey(HKEY_CURRENT_USER,
               "Software\\Netscape\\Netscape Navigator\\Main",
               "Home Page");
        else if(str_Browser == "\"iexplore.exe\"" || "Crazy Browser.exe")
            //Get IE's homepage reg entry
            str_HomePageOut = GetRegKey(HKEY_CURRENT_USER,
              "Software\\Microsoft\\Internet Explorer\\Main", 
              "Start Page");
        else if(str_Browser != "\"iexplore.exe\"" || "\"Netscp.exe\"")
            AfxMessageBox("Sorry, Your default browser 
                is not IE or Netscape.\r<br>Please email 
                me your browser's registry homepage key 
                so I may update this program and source.\r

        //I don't have any other the other Browser's 
        //installed on my system, so I need help getting
        //the Registry keys

    }//end of else
    return str_HomePageOut;

The 2nd function:

////by Tone Skoda 
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam)
    long style;

        if(style & WS_OVERLAPPEDWINDOW &&
            (style & WS_POPUP)== false)
            if( IsIconic(hwnd) == false )
#ifdef M_RESTORE
            if( IsIconic(hwnd) == true )
#ifdef M_CLOSE
    return true;
////End of code by Tone Skoda

The WinMain:

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
    //call external var
    extern CString GetHomePage();
    extern CString str_Browser;
    extern HICON m_hIcon;
    //Assign Icon with the .exe
    CWnd m_hWnd;
    m_hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));

////by Tone Skoda 
    //turn off minimize/restore animations

    //turn on minimize/restore animations
////End of code by Tone Skoda 

    //fill the url to local var
    CString str_Homepage = GetHomePage();

    //open the browser
    ShellExecute(m_hWnd, "open", str_Browser, 
         str_Homepage, NULL, SW_SHOWDEFAULT);

    return true;

Points of Interest

I was surprised not to find any existing code on the major coding sites about how to minimize and maximize open windows. Maybe because it is common knowledge, but not to this wanna-be programmer.

Known Issues/Limits

  • Only looks for Internet Explorer and Netscape homepages (only b/c they are the only ones I have installed). I will update as I receive more info on other browsers (this info might be good/useful to have documented in one place anyway. I tried searching the net for a page that has info on the registry keys for browsers and their homepages, but no such site exists).
  • Does not fully minimize restored windows (it mini's them, but not fully).
  • "It's bad for people trying to learn from your code." see .S.Rod. 15:16 4 Jan '03 post. Sorry you "Professionals", I'm still learningImage 3
  • 2 unresolved externals error - Debug ONLY.
  • VC7 build errors, better off just creating a new project and pasting code, and importing icons.

Desired Add-ons

  • An Options popup menu if user right-clicks on shortcut or PowerMini.exe (like IE's) (I tried doing this feature myself but found myself investing too much time and not getting answers to my stumbling).
  • Cooler icons in the build, so you have plenty of options to choose from.
  • Anything else you can think of.


Article posted 1/4/03 12:10am PT

  • 1/4/03 11:35am PT: Removed the setup.exe from Oops, wonder why it was so big.
  • 1/4/03 1:20pm PT: Improved GetHomePage() by getting actual default browser instead of guessing.
  • 1/4/03 1:20pm PT: Posted v1.1 src and install.
  • 1/17/03 8:31pm PT: Posted v1.2 src and install. Added support for Crazy Browser. Improved some functions.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Chief Technology Officer
United States United States
Born in Pennsylvania (USA), just north of Philadelphia. Joe has been programming since he was ten[now much older]. He is entirely self-taught programmer, & he is currently working as an IT Manager in Seattle WA. He was previously U.S. Navy Active Reservist for (SPAWAR)
In '98 was honorably discharged from the USN. He served onboard the USS Carl Vinson (94-98) He was lucky enough to drink President Clinton's leftover wine, promoted by his Captain, and flew in a plane off the flightdeck but not all at the same time. His interests, when time allows, are developing
misc apps and Artificial Intelligence proof-of-concept demos that specifically exhibits human behavior. He is a true sports-a-holic, needs plenty of caffeine, & a coding junkie. He also enjoys alternative music and a big Pearl Jam, Nirvana, new alternative music fan, and the Alison Wonderland.
He is currently working on<> which he says is fun and cool. Cool | :cool: :cheers:

Joe is an INTP[
^] personality type. Joe "sees everything in terms of how it could be improved, or what it could be turned into. INTP's live primarily inside their own minds." INTPs also can have the "greatest precision in thought and language. Can readily discern contradictions and inconsistencies. The world exists primarily to be understood. 1% of the total population" [

Comments and Discussions

QuestionAvant Browser ?????? Pin
yousefk13-Dec-06 0:52
Memberyousefk13-Dec-06 0:52 
GeneralThe homepage when its not IE or Netscape Pin
Nnamdi Onyeyiri17-Jan-03 21:35
MemberNnamdi Onyeyiri17-Jan-03 21:35 
GeneralTry CrazyBrowser! Pin
Kant17-Jan-03 10:06
MemberKant17-Jan-03 10:06 
GeneralRe: Try CrazyBrowser! Pin
JoeSox17-Jan-03 10:45
MemberJoeSox17-Jan-03 10:45 
GeneralRe: Try CrazyBrowser! Pin
JoeSox17-Jan-03 17:50
MemberJoeSox17-Jan-03 17:50 
GeneralOpera do it already ;) Pin
Kochise5-Jan-03 22:07
MemberKochise5-Jan-03 22:07 
GeneralRe: Opera do it already ;) Pin
JoeSox6-Jan-03 5:42
MemberJoeSox6-Jan-03 5:42 
GeneralRe: Opera do it already ;) Pin
rkiesler18-Jan-03 13:25
Memberrkiesler18-Jan-03 13:25 
GeneralRe: Opera do it already ;) Pin
JoeSox19-Jan-03 15:44
MemberJoeSox19-Jan-03 15:44 
GeneralRe: Opera do it already ;) Pin
rkiesler20-Jan-03 3:55
Memberrkiesler20-Jan-03 3:55 
GeneralRe: Opera do it already ;) Pin
JoeSox20-Jan-03 6:51
MemberJoeSox20-Jan-03 6:51 
GeneralRe: Opera do it already ;) Pin
JoeSox20-Feb-03 10:15
MemberJoeSox20-Feb-03 10:15 
GeneralRe: Opera do it already ;) Pin
Kochise20-Feb-03 21:29
MemberKochise20-Feb-03 21:29 
Generala few suggestions Pin
Stephane Rodriguez.4-Jan-03 9:16
MemberStephane Rodriguez.4-Jan-03 9:16 
GeneralRe: a few suggestions Pin
JoeSox4-Jan-03 9:33
MemberJoeSox4-Jan-03 9:33 
GeneralDefault web browser Pin
Nnamdi Onyeyiri4-Jan-03 0:36
MemberNnamdi Onyeyiri4-Jan-03 0:36 
GeneralRe: Default web browser Pin
JoeSox4-Jan-03 7:30
MemberJoeSox4-Jan-03 7:30 
GeneralRe: Default web browser Pin
Christian Graus4-Jan-03 11:23
protectorChristian Graus4-Jan-03 11:23 
GeneralRe: Default web browser Pin
Nnamdi Onyeyiri4-Jan-03 11:25
MemberNnamdi Onyeyiri4-Jan-03 11:25 
i am running ie6 on winxp. when i 'iexplore.exe -nohome' in the start->run, it loaded ie without the homepage. when i typed 'iexplore.exe' in start->run, it loaded ie with the homepage, therefore, that swith prevents it from loading the homepage when it starts.

Sonork | 100.21142 | TheEclypse

GeneralRe: Default web browser Pin
JoeSox4-Jan-03 13:09
MemberJoeSox4-Jan-03 13:09 
GeneralRe: Default web browser Pin
JoeSox17-Jan-03 17:55
MemberJoeSox17-Jan-03 17:55 
GeneralRe: Default web browser Pin
Nnamdi Onyeyiri17-Jan-03 21:31
MemberNnamdi Onyeyiri17-Jan-03 21:31 
GeneralRe: Default web browser Pin
Tammenterho6-Jul-07 0:38
MemberTammenterho6-Jul-07 0:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.