Click here to Skip to main content
15,883,901 members
Articles / Desktop Programming / ATL

Classic Shell

Rate me:
Please Sign up or sign in to vote.
4.99/5 (135 votes)
23 Feb 2010MIT33 min read 954K   10K   195  
Classic Start menu and other shell features for Windows 7 and Vista.
// Classic Shell (c) 2009-2010, Ivo Beltchev
// The sources for Classic Shell are distributed under the MIT open source license

#include "TranslationSettings.h"
#include "ParseSettings.h"

static CSettingsParser g_Settings;

// Parses the settings from an ini file. Supports UTF16, UTF8 or ANSI files
void ParseTranslations( const wchar_t *fname )
{
	g_Settings.Reset();

	if (!g_Settings.LoadText(fname)) return;
	g_Settings.ParseText();

	wchar_t languages[100]={0};
	{
		ULONG size=4; // up to 4 languages
		ULONG len=_countof(languages);
		GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME,&size,languages,&len);
		// uncomment this to force a specific language
//		memcpy(languages,L"bg-BG",10); len=7;
		wcscpy_s(languages+len-1,10,L"default");
		languages[len+7]=0;
	}

	g_Settings.FilterLanguages(languages);
}

// Returns a setting with the given name. If no setting is found, returns def
const wchar_t *FindTranslation( const char *name, const wchar_t *def )
{
	return g_Settings.FindSetting(name,def);
}

const wchar_t *FindTranslation( const wchar_t *name, const wchar_t *def )
{
	return g_Settings.FindSetting(name,def);
}

// Checks for right-to-left languages
bool IsLanguageRTL( void )
{
#ifdef _DEBUG
	//	return true; // uncomment this to simulate RTL environment
#endif
	LOCALESIGNATURE localesig;
	LANGID language=GetUserDefaultUILanguage();
	if (GetLocaleInfoW(language,LOCALE_FONTSIGNATURE,(LPWSTR)&localesig,(sizeof(localesig)/sizeof(wchar_t))) && (localesig.lsUsb[3]&0x08000000))
		return true;
	return false;
}

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


Written By
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.

Comments and Discussions