Visual C++ .NET/Development/ResourceManager — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
Multicultural Application
#include "stdafx.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Globalization;
using namespace System::Threading;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
Thread::CurrentThread->CurrentCulture = gcnew CultureInfo("fr-fr");
Thread::CurrentThread->CurrentUICulture = Thread::CurrentThread->CurrentCulture;
InitializeComponent();
}
System::Windows::Forms::Label^ lbHello;
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->lbHello = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// lbHello
//
this->lbHello->AccessibleDescription = nullptr;
this->lbHello->AccessibleName = nullptr;
resources->ApplyResources(this->lbHello, L"lbHello");
this->lbHello->BackColor = System::Drawing::SystemColors::Control;
this->lbHello->Name = L"lbHello";
//
// Form1
//
this->AccessibleDescription = nullptr;
this->AccessibleName = nullptr;
resources->ApplyResources(this, L"$this");
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = nullptr;
this->Controls->Add(this->lbHello);
this->Font = nullptr;
this->Icon = nullptr;
this->Name = L"Form1";
this->ResumeLayout(false);
}
};
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::Run(gcnew Form1());
return 0;
}
Multicultural Console
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Resources;
using namespace System::Threading;
using namespace System::Globalization;
void main()
{
Assembly ^assembly = Assembly::GetExecutingAssembly();
ResourceManager ^rmgr =
gcnew ResourceManager("MulticulturalConsole.Colors", assembly);
Console::WriteLine(rmgr->GetObject("Color1"));
Console::WriteLine(rmgr->GetObject("Color2"));
Console::WriteLine(rmgr->GetObject("Color3"));
Console::WriteLine(rmgr->GetObject("Color4"));
Thread::CurrentThread->CurrentUICulture = gcnew CultureInfo("fr-fr");
Console::WriteLine(rmgr->GetObject("Color1"));
Console::WriteLine(rmgr->GetObject("Color2"));
Console::WriteLine(rmgr->GetObject("Color3"));
Console::WriteLine(rmgr->GetObject("Color4"));
}