Click here to Skip to main content
11,645,087 members (64,946 online)
Click here to Skip to main content
Add your own
alternative version

Classic Shell

, 23 Feb 2010 MIT 470.8K 8.6K 193
Classic Start menu and other shell features for Windows 7 and Vista.
ClassicShellSetup.zip
ClassicShellSetup.exe
ClassicShellSrc.zip
ClassicShell
ClassicExplorer
ClassicCopyExt.rgs
ClassicExplorer.rgs
ClassicExplorer32.def
ClassicExplorer64.def
Explorer.ini
ExplorerBand.rgs
ExplorerBHO.rgs
ExplorerL10N.ini
up.ico
up2Disabled.ico
up2Hot.ico
up2Normal.ico
up2Pressed.ico
upDisabled.ico
ClassicShellSetup
ClassicShell.ico
ClassicShellBanner.jpg
ClassicShellSetup.manifest
ClassicShellSetup32
ClassicShellSetup32.vdproj
ClassicShellSetup64
ClassicShellSetup64.vdproj
ClassicStartMenu
ClassicStartMenu.manifest
ClassicStartMenuDLL
StartMenu.ini
StartMenuItems.ini
StartMenuL10N.ini
Docs
ClassicExplorer_files
after.png
before.png
ClassicShell.png
FolderView.gif
iconoffset.png
statusbar.png
titlebar.png
toolbar.png
ClassicShellEULA.rtf
ClassicShellReadme.rtf
ClassicStartMenu_files
ClassicShell.png
screenshot.png
skins.gif
ParseSettings
Skins
ClassicSkin
main_bitmap.bmp
selection.bmp
VistaAero
main_bitmap.bmp
selection.bmp
Win7Aero
main_bitmap.bmp
selection.bmp
Win7Basic
main_bitmap.bmp
selection.bmp
// Classic Shell (c) 2009-2010, Ivo Beltchev
// The sources for Classic Shell are distributed under the MIT open source license

#include "stdafx.h"
#include "Settings.h"
#include "ExplorerBand.h"
#include "ExplorerBHO.h"
#include "resource.h"
#include "GlobalSettings.h"
#include "TranslationSettings.h"

// Dialog proc for the Settings dialog. Edits the settings and saves them to the registry
INT_PTR CALLBACK SettingsDlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	if (uMsg==WM_INITDIALOG)
	{
		void *pRes=NULL;
		HRSRC hResInfo=FindResource(g_Instance,MAKEINTRESOURCE(VS_VERSION_INFO),RT_VERSION);
		if (hResInfo)
		{
			HGLOBAL hRes=LoadResource(g_Instance,hResInfo);
			pRes=LockResource(hRes);
		}
		wchar_t title[100];
		if (pRes)
		{
			VS_FIXEDFILEINFO *pVer=(VS_FIXEDFILEINFO*)((char*)pRes+40);
			swprintf_s(title,L"Settings for Classic Explorer %d.%d.%d",HIWORD(pVer->dwProductVersionMS),LOWORD(pVer->dwProductVersionMS),HIWORD(pVer->dwProductVersionLS));
		}
		else
			swprintf_s(title,L"Settings for Classic Explorer");
		SetWindowText(hwndDlg,title);

		HICON icon=(HICON)LoadImage(g_Instance,MAKEINTRESOURCE(IDI_APPICON),IMAGE_ICON,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON),LR_DEFAULTCOLOR);
		SendMessage(hwndDlg,WM_SETICON,ICON_BIG,(LPARAM)icon);
		icon=(HICON)LoadImage(g_Instance,MAKEINTRESOURCE(IDI_APPICON),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),LR_DEFAULTCOLOR);
		SendMessage(hwndDlg,WM_SETICON,ICON_SMALL,(LPARAM)icon);

		CRegKey regSettings;
		if (regSettings.Open(HKEY_CURRENT_USER,L"Software\\IvoSoft\\ClassicExplorer")!=ERROR_SUCCESS)
			regSettings.Create(HKEY_CURRENT_USER,L"Software\\IvoSoft\\ClassicExplorer");

		DWORD EnableCopyUI, FreeSpace, FoldersSettings, BigButtons, ToolbarButtons, UpButton;
		if (regSettings.QueryDWORDValue(L"EnableCopyUI",EnableCopyUI)!=ERROR_SUCCESS)
			EnableCopyUI=1;
		if (regSettings.QueryDWORDValue(L"FreeSpace",FreeSpace)!=ERROR_SUCCESS)
			FreeSpace=(LOWORD(GetVersion())==0x0106)?CExplorerBHO::SPACE_SHOW:0;
		if (regSettings.QueryDWORDValue(L"FoldersSettings",FoldersSettings)!=ERROR_SUCCESS)
			FoldersSettings=CExplorerBHO::FOLDERS_DEFAULT;
		if (regSettings.QueryDWORDValue(L"BigButtons",BigButtons)!=ERROR_SUCCESS)
			BigButtons=0;
		if (regSettings.QueryDWORDValue(L"ToolbarButtons",ToolbarButtons)!=ERROR_SUCCESS)
			ToolbarButtons=DEFAULT_BUTTONS|((CBandWindow::ID_LAST-1)<<24);
		if (regSettings.QueryDWORDValue(L"UpButton",UpButton)!=ERROR_SUCCESS)
			UpButton=1;

		if (!(ToolbarButtons&0xFF000000)) ToolbarButtons|=0x07000002; // for backwards compatibility (when there were 7 buttons the the button count was not saved)
		unsigned int mask1=(((2<<(ToolbarButtons>>24))-1)&~1); // bits to keep
		unsigned int mask2=(((2<<CBandWindow::ID_LAST)-1)&~1)&~mask1; // bits to replace with defaults
		ToolbarButtons=(ToolbarButtons&mask1)|(DEFAULT_BUTTONS&mask2)|((CBandWindow::ID_LAST-1)<<24);
		if ((ToolbarButtons&0xFFFFFF)==0)
			ToolbarButtons|=1<<DEFAULT_ONLY_BUTTON;

		RECT rc1,rc2;
		GetWindowRect(hwndDlg,&rc1);
		GetWindowRect(GetParent(hwndDlg),&rc2);
		OffsetRect(&rc1,(rc2.left+rc2.right)/2-(rc1.left+rc1.right)/2,(rc2.top+rc2.bottom)/2-(rc1.top+rc1.bottom)/2);
		if (rc1.top<rc2.top) OffsetRect(&rc1,0,rc2.top-rc1.top);
		SetWindowPos(hwndDlg,NULL,rc1.left,rc1.top,rc1.right-rc1.left,rc1.bottom-rc1.top,SWP_NOZORDER);
		SendMessage(hwndDlg,DM_REPOSITION,0,0);

		CheckDlgButton(hwndDlg,IDC_CHECKCOPY,(EnableCopyUI==1 || EnableCopyUI==2)?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECKCOPYFOLDER,(EnableCopyUI&1)?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECKSIZE,FreeSpace?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECKBHO,(FoldersSettings&CExplorerBHO::FOLDERS_ALTENTER)?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECKAUTO,(FoldersSettings&CExplorerBHO::FOLDERS_AUTONAVIGATE)?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECKNOFADE,(FoldersSettings&CExplorerBHO::FOLDERS_NOFADE)?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECKOFFSET,(FoldersSettings&CExplorerBHO::FOLDERS_FULLINDENT)?BST_CHECKED:BST_UNCHECKED);

		int style=(FoldersSettings&CExplorerBHO::FOLDERS_STYLE_MASK);
		SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_ADDSTRING,0,(LPARAM)L"Windows Vista");
		SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_ADDSTRING,0,(LPARAM)L"Windows XP Classic");
		SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_ADDSTRING,0,(LPARAM)L"Windows XP Simple");
		if (style==CExplorerBHO::FOLDERS_CLASSIC)
			SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_SETCURSEL,1,0);
		else if (style==CExplorerBHO::FOLDERS_SIMPLE)
			SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_SETCURSEL,2,0);
		else
			SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_SETCURSEL,0,0);

		CheckDlgButton(hwndDlg,IDC_CHECKUP,UpButton?BST_CHECKED:BST_UNCHECKED);

		CheckDlgButton(hwndDlg,IDC_CHECKBIG,BigButtons?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK1,(ToolbarButtons&(1<<CBandWindow::ID_GOUP))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK2,(ToolbarButtons&(1<<CBandWindow::ID_CUT))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK3,(ToolbarButtons&(1<<CBandWindow::ID_COPY))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK4,(ToolbarButtons&(1<<CBandWindow::ID_PASTE))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK5,(ToolbarButtons&(1<<CBandWindow::ID_DELETE))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK6,(ToolbarButtons&(1<<CBandWindow::ID_PROPERTIES))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK7,(ToolbarButtons&(1<<CBandWindow::ID_EMAIL))?BST_CHECKED:BST_UNCHECKED);
		CheckDlgButton(hwndDlg,IDC_CHECK8,(ToolbarButtons&(1<<CBandWindow::ID_SETTINGS))?BST_CHECKED:BST_UNCHECKED);

		if (FindSetting("ToolbarItems"))
		{
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK1),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK2),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK3),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK4),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK5),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK6),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK7),FALSE);
			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK8),FALSE);
		}
	}
	if (uMsg==WM_INITDIALOG || (uMsg==WM_COMMAND && wParam==MAKEWPARAM(IDC_COMBOSTYLE,CBN_SELENDOK)))
	{
		int style=(int)SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_GETCURSEL,0,0);
		EnableWindow(GetDlgItem(hwndDlg,IDC_CHECKNOFADE),style!=1);
		EnableWindow(GetDlgItem(hwndDlg,IDC_CHECKOFFSET),style!=1);
		if (uMsg==WM_COMMAND)
			return TRUE;
	}
	if (uMsg==WM_INITDIALOG || (uMsg==WM_COMMAND && wParam==IDC_CHECKCOPY))
	{
		EnableWindow(GetDlgItem(hwndDlg,IDC_CHECKCOPYFOLDER),IsDlgButtonChecked(hwndDlg,IDC_CHECKCOPY)==BST_CHECKED);
		if (uMsg==WM_COMMAND)
			return TRUE;
	}
	if (uMsg==WM_INITDIALOG)
		return TRUE;
	if (uMsg==WM_COMMAND && wParam==IDOK)
	{
		CRegKey regSettings;
		if (regSettings.Open(HKEY_CURRENT_USER,L"Software\\IvoSoft\\ClassicExplorer")!=ERROR_SUCCESS)
			regSettings.Create(HKEY_CURRENT_USER,L"Software\\IvoSoft\\ClassicExplorer");

		DWORD EnableCopyUI, FreeSpace, FoldersSettings, BigButtons, ToolbarButtons, UpButton;
		if (regSettings.QueryDWORDValue(L"EnableCopyUI",EnableCopyUI)!=ERROR_SUCCESS)
			EnableCopyUI=1;
		if (regSettings.QueryDWORDValue(L"FreeSpace",FreeSpace)!=ERROR_SUCCESS)
			FreeSpace=(LOWORD(GetVersion())==0x0106)?CExplorerBHO::SPACE_SHOW:0;
		if (regSettings.QueryDWORDValue(L"FoldersSettings",FoldersSettings)!=ERROR_SUCCESS)
			FoldersSettings=CExplorerBHO::FOLDERS_DEFAULT;
		if (regSettings.QueryDWORDValue(L"BigButtons",BigButtons)!=ERROR_SUCCESS)
			BigButtons=0;
		if (regSettings.QueryDWORDValue(L"UpButton",UpButton)!=ERROR_SUCCESS)
			UpButton=1;
		if (regSettings.QueryDWORDValue(L"ToolbarButtons",ToolbarButtons)!=ERROR_SUCCESS)
			ToolbarButtons=DEFAULT_BUTTONS|((CBandWindow::ID_LAST-1)<<24);
		DWORD ToolbarButtons0=ToolbarButtons;
		if (!(ToolbarButtons&0xFF000000)) ToolbarButtons|=0x07000002; // for backwards compatibility (when there were 7 buttons the the button count was not saved)
		unsigned int mask1=(((2<<(ToolbarButtons>>24))-1)&~1); // bits to keep
		unsigned int mask2=(((2<<CBandWindow::ID_LAST)-1)&~1)&~mask1; // bits to replace with defaults
		ToolbarButtons=(ToolbarButtons&mask1)|(DEFAULT_BUTTONS&mask2)|((CBandWindow::ID_LAST-1)<<24);
		if ((ToolbarButtons&0xFFFFFF)==0)
			ToolbarButtons|=1<<DEFAULT_ONLY_BUTTON;

		DWORD EnableCopyUI2=(IsDlgButtonChecked(hwndDlg,IDC_CHECKCOPY)==BST_CHECKED)?2:0;
		if (IsDlgButtonChecked(hwndDlg,IDC_CHECKCOPYFOLDER)==BST_CHECKED)
			EnableCopyUI2=EnableCopyUI2?1:3;
		DWORD FreeSpace2=(IsDlgButtonChecked(hwndDlg,IDC_CHECKSIZE)==BST_CHECKED)?CExplorerBHO::SPACE_SHOW:0;
		DWORD FoldersSettings2=0;
		if (IsDlgButtonChecked(hwndDlg,IDC_CHECKBHO)==BST_CHECKED)
			FoldersSettings2|=CExplorerBHO::FOLDERS_ALTENTER;
		if (IsDlgButtonChecked(hwndDlg,IDC_CHECKAUTO)==BST_CHECKED)
			FoldersSettings2|=CExplorerBHO::FOLDERS_AUTONAVIGATE;
		int style=(int)SendDlgItemMessage(hwndDlg,IDC_COMBOSTYLE,CB_GETCURSEL,0,0);
		if (style==0) FoldersSettings2|=CExplorerBHO::FOLDERS_VISTA;
		if (style==1) FoldersSettings2|=CExplorerBHO::FOLDERS_CLASSIC;
		if (style==2) FoldersSettings2|=CExplorerBHO::FOLDERS_SIMPLE;
		if (IsDlgButtonChecked(hwndDlg,IDC_CHECKNOFADE)==BST_CHECKED)
			FoldersSettings2|=CExplorerBHO::FOLDERS_NOFADE;
		if (IsDlgButtonChecked(hwndDlg,IDC_CHECKOFFSET)==BST_CHECKED)
			FoldersSettings2|=CExplorerBHO::FOLDERS_FULLINDENT;

		DWORD UpButton2=(IsDlgButtonChecked(hwndDlg,IDC_CHECKUP)==BST_CHECKED)?1:0;
		DWORD BigButtons2=(IsDlgButtonChecked(hwndDlg,IDC_CHECKBIG)==BST_CHECKED)?1:0;
		DWORD ToolbarButtons2=0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK1)==BST_CHECKED)?(1<<CBandWindow::ID_GOUP):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK2)==BST_CHECKED)?(1<<CBandWindow::ID_CUT):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK3)==BST_CHECKED)?(1<<CBandWindow::ID_COPY):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK4)==BST_CHECKED)?(1<<CBandWindow::ID_PASTE):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK5)==BST_CHECKED)?(1<<CBandWindow::ID_DELETE):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK6)==BST_CHECKED)?(1<<CBandWindow::ID_PROPERTIES):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK7)==BST_CHECKED)?(1<<CBandWindow::ID_EMAIL):0;
		ToolbarButtons2|=(IsDlgButtonChecked(hwndDlg,IDC_CHECK8)==BST_CHECKED)?(1<<CBandWindow::ID_SETTINGS):0;
		ToolbarButtons2|=((CBandWindow::ID_LAST-1)<<24);
		if ((ToolbarButtons2&0xFFFFFF)==0)
			ToolbarButtons2|=1<<DEFAULT_ONLY_BUTTON;

		int res=0;
		if (EnableCopyUI!=EnableCopyUI2)
		{
extern bool g_bHookCopyThreads;
			if (!g_bHookCopyThreads && (EnableCopyUI2==1 || EnableCopyUI2==2))
				res|=2;
			regSettings.SetDWORDValue(L"EnableCopyUI",EnableCopyUI2);
		}
		if (FreeSpace!=FreeSpace2)
		{
			regSettings.SetDWORDValue(L"FreeSpace",FreeSpace2);
			res|=1;
		}
		if (FoldersSettings!=FoldersSettings2)
		{
			regSettings.SetDWORDValue(L"FoldersSettings",FoldersSettings2);
			if ((FoldersSettings^FoldersSettings2)!=CExplorerBHO::FOLDERS_ALTENTER)
				res|=1;
		}
		if (UpButton!=UpButton2)
		{
			regSettings.SetDWORDValue(L"UpButton",UpButton2);
			res|=1;
		}
		if (BigButtons!=BigButtons2)
		{
			regSettings.SetDWORDValue(L"BigButtons",BigButtons2);
			res|=1;
		}
		if (ToolbarButtons0!=ToolbarButtons2)
		{
			regSettings.SetDWORDValue(L"ToolbarButtons",ToolbarButtons2);
			if (ToolbarButtons!=ToolbarButtons2)
				res|=1;
		}

		EndDialog(hwndDlg,res);
		return TRUE;
	}
	if (uMsg==WM_COMMAND && wParam==IDCANCEL)
	{
		EndDialog(hwndDlg,0);
		return TRUE;
	}
	if (uMsg==WM_NOTIFY)
	{
		NMHDR *pHdr=(NMHDR*)lParam;
		if (pHdr->idFrom==IDC_LINKHELP && (pHdr->code==NM_CLICK || pHdr->code==NM_RETURN))
		{
			wchar_t path[_MAX_PATH];
			GetModuleFileName(g_Instance,path,_countof(path));
			*PathFindFileName(path)=0;
			wcscat_s(path,DOC_PATH L"ClassicExplorer.html");
			ShellExecute(NULL,NULL,path,NULL,NULL,SW_SHOWNORMAL);
			return TRUE;
		}
	}
	return FALSE;
}

void ShowSettings( HWND parent )
{
	INT_PTR res=DialogBox(g_Instance,MAKEINTRESOURCE(IDD_SETTINGS),parent,SettingsDlgProc);
	if (res&2)
		MessageBox(parent,L"You need to log off and back on for the new settings to take effect.",L"Classic Explorer",MB_OK);
	else if (res&1)
		MessageBox(parent,L"The new settings will take effect the next time you open an Explorer window.",L"Classic Explorer",MB_OK);
}

void ShowSettingsMenu( HWND parent, int x, int y )
{
	HMENU menu=CreatePopupMenu();
	AppendMenu(menu,MF_STRING,CBandWindow::ID_SETTINGS,FindTranslation("Toolbar.Settings",L"Classic Explorer Settings"));
	HBITMAP shellBmp=NULL;
	int size=16;
	BITMAPINFO bi={0};
	bi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
	bi.bmiHeader.biWidth=bi.bmiHeader.biHeight=size;
	bi.bmiHeader.biPlanes=1;
	bi.bmiHeader.biBitCount=32;
	HDC hdc=CreateCompatibleDC(NULL);
	RECT rc={0,0,size,size};
	HICON icon=(HICON)LoadImage(g_Instance,MAKEINTRESOURCE(IDI_APPICON),IMAGE_ICON,size,size,LR_DEFAULTCOLOR);
	if (icon)
	{
		shellBmp=CreateDIBSection(hdc,&bi,DIB_RGB_COLORS,NULL,NULL,0);
		HGDIOBJ bmp0=SelectObject(hdc,shellBmp);
		FillRect(hdc,&rc,(HBRUSH)GetStockObject(BLACK_BRUSH));
		DrawIconEx(hdc,0,0,icon,size,size,0,NULL,DI_NORMAL);
		SelectObject(hdc,bmp0);
		DeleteObject(icon);

		MENUITEMINFO mii={sizeof(mii)};
		mii.fMask=MIIM_BITMAP;
		mii.hbmpItem=shellBmp;
		SetMenuItemInfo(menu,CBandWindow::ID_SETTINGS,FALSE,&mii);
	}
	DeleteDC(hdc);

	DWORD pos=GetMessagePos();
	if (!FindSettingBool("EnableSettings",true))
		EnableMenuItem(menu,0,MF_BYPOSITION|MF_GRAYED);
	int res=TrackPopupMenu(menu,TPM_RETURNCMD,x,y,0,parent,NULL);
	DestroyMenu(menu);
	if (shellBmp) DeleteObject(shellBmp);
	if (res==CBandWindow::ID_SETTINGS)
		ShowSettings(parent);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Ivo Beltchev
Software Developer (Senior)
United States United States
Ivo started programming in 1985 on an Apple ][ clone. He graduated from Sofia University, Bulgaria with a MSCS degree. Ivo has been working as a professional programmer for over 12 years, and as a professional game programmer for over 10. He is currently employed in Pandemic Studios, a video game company in Los Angeles, California.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150731.1 | Last Updated 23 Feb 2010
Article Copyright 2009 by Ivo Beltchev
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid