OnSettingChange (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires that a memo and a TApplicationEvent be added to the form. Change the Windows Locale by using the Regional and Language Options in the Windows Control Panel.

Code

void __fastcall TForm1::ApplicationEvents1SettingChange(TObject *Sender, int Flag,
		  const UnicodeString Section, int &Result)
{
  Memo1->Lines->BeginUpdate();
  try
  {
//    char buffer[64];
	String buffer;
	buffer.sprintf(L"Section = %s", String(Section).c_str());
	Memo1->Lines->Add(buffer);
	buffer.sprintf(L"Flag = %8x", Flag);
	Memo1->Lines->Add(buffer);
	if (wcscmp(String(Section).c_str(), L"intl") == 0)
	{
	  buffer.sprintf(L"DefaultLCID = %8x", SysLocale.DefaultLCID);
	  Memo1->Lines->Add(buffer);
	  buffer.sprintf(L"PriLangID = %8x", SysLocale.PriLangID);
	  Memo1->Lines->Add(buffer);
	  buffer.sprintf(L"SubLangID = %8x", SysLocale.SubLangID);
	  Memo1->Lines->Add(buffer);
	  buffer.sprintf(L"FarEast = %s", BoolToStr(SysLocale.FarEast, true));
	  Memo1->Lines->Add(buffer);
	  buffer.sprintf(L"MiddleEast = %s", BoolToStr(SysLocale.MiddleEast, true));
	  Memo1->Lines->Add(buffer);
	  Memo1->Lines->Add(L"");
	}
  }
  __finally
  {
	Memo1->Lines->EndUpdate();
  }
}

Uses