TOP Languages C++ Visual C++ .NET MSIL
enum class Colors{Red,Green,Blue,};
Colors col = Color::Red;
int i = static_cast<int>(color);
Colors color = static_cast<Colors>(2);
array<Colors>^arr = static_cast<array<Colors>^>(Enum::GetValues(Colors::typeid));
Array^ a = Enum::GetNames( Colors::typeid );
for ( i = 0; i < a->Length; i++ ) Console::Write( " {0}", a->GetValue( i ) );
Console::WriteLine("{0}",Colors::Blue.ToString());
Colors col = Color::Red;
int i = static_cast<int>(color);
Colors color = static_cast<Colors>(2);
array<Colors>^arr = static_cast<array<Colors>^>(Enum::GetValues(Colors::typeid));
Array^ a = Enum::GetNames( Colors::typeid );
for ( i = 0; i < a->Length; i++ ) Console::Write( " {0}", a->GetValue( i ) );
Console::WriteLine("{0}",Colors::Blue.ToString());
enum だとnamespace が深くなるので代替手段
ref class A{
public:
static const VALUE1=1;
};
int i=A::VALUE1;
ref class A{
public:
static const VALUE1=1;
};
int i=A::VALUE1;
void ColoredConsole::Sample(){ array<String^>^colorNames = Enum::GetNames( ConsoleColor::typeid ); for each(String^ col in colorNames){ ConsoleColor c = *dynamic_cast<ConsoleColor^>(Enum::Parse( ConsoleColor: :typeid, col )); Write(c,ConsoleColor::Black,col); WriteLine(c,ConsoleColor::White,col); } }
Destructors in a reference type perform deterministic clean up of your resources.
Finalizers clean up unmanaged resources and can be called deterministically by the destructor or non-deterministically by the garbage collector.
When a Close() method is called, any managed resource can be temporarily closed and can be opened once again.
Finalizers clean up unmanaged resources and can be called deterministically by the destructor or non-deterministically by the garbage collector.
When a Close() method is called, any managed resource can be temporarily closed and can be opened once again.
http://vene.wankuma.com/prog/CppCli_Generics.aspx
generic | can be used from an other assembly |
template | can be used in the same assembly |
- about.txt favicon.img を用意.
; about.txt ; vim:encoding=CP932 ; vim:fileencoding=utf-8 ; vim:bomb AboutCaptionFormat_ja={0}のバージョン情報 AboutCaptionFormat_en={0}'s version information
- 下記makefile で.resource生成
ABOUT_TXT=about.txt ABOUT_IMG=about.ico ABOUT_RESOURCES=$(ABOUT_TXT:%.txt=%.resources) ABOUT_RESX=$(ABOUT_TXT:%.txt=%.resx) ABOUT_RESX_STR=$(ABOUT_TXT:%.txt=%_str.resx) ABOUT_RESX_BIN=$(ABOUT_TXT:%.txt=%_bin.resx) $(ABOUT_RESOURCES): $(ABOUT_TXT) $(ABOUT_IMG) resgen $(ABOUT_TXT) $(ABOUT_RESX_STR) resxgen -p -o $(ABOUT_RESX_BIN) -e $(ABOUT_IMG) resx_merge -i $(ABOUT_RESX_STR) -i $(ABOUT_RESX_BIN) -o $(ABOUT_RESX) #cat data\ name $(ABOUT_RESX) resgen $(ABOUT_RESX) $(ABOUT_RESOURCES)
- プログラムの$(OBJS)とリンク
CLRIMAGETYPE=pure LOPT=-ENTRY:main -SUBSYSTEM:WINDOWS -clrimagetype:$(CLRIMAGETYPE) ASSEMBLY_RESOURCES+= /assemblyResource:$(ABOUT_RESOURCES) $(TARGET).exe: $(OBJS) $(ABOUT_RESOURCES) link $(OBJS) /out:$@ $(LOPT) $(ASSEMBLY_RESOURCES)
- プログラム中のアクセス
System::Resources::ResourceManager^ rm ; System::Globalization::CultureInfo^ ci; rm = gcnew System::Resources::ResourceManager( "about", System::Reflection::Assembly::GetExecutingAssembly() ); ci = gcnew System::Globalization::CultureInfo( System::Globalization::CultureInfo::CurrentUICulture->Name ); String^ ci_name=String::Format("_{0:##}",ci->Name->Substring(0,2)); String^ fmt=rm->GetString(String::Format("AboutCaptionFormat{0}",ci_name),ci); if(fmt == nullptr||fmt->Length==0) fmt="{0}'s version information"; Text = String::Format(fmt,System::Windows::Forms::Application::ProductName); System::Drawing::Icon^ icon = safe_cast<System::Drawing::Icon^>(rm->GetObject("about.ico"));
- 多国語対応
- frディレクトリ作成
- fr/about.fr.txt 作成
- fr/about.fr.resources 生成
- fr/test_main.resources.dll生成
CULTUREDIRS=fr DLLS=$(shell for x in $(CULTUREDIRS); do echo $$x/$(TARGET).resources.dll; done) CULTURE_TEXTFILES:=$(shell for x in $(CULTUREDIRS); do echo $$x/strings.$$x.txt; done) CULTURE_RESOURCES=$(CULTURE_TEXTFILES:%.txt=%.resources) $(CULTURE_RESOURCES): $(CULTURE_TEXTFILES) $(DLLS): $(CULTURE_RESOURCES) @(for x in $(CULTUREDIRS); do \ if [ ! -d $$x ] ; then mkdir $$x; fi ;\ al /t:lib /culture:$$x /embed:$$x\\about.$$x.resources /out:$$x\\$(TARGET).resources.dll ;\ done;)
最新コメント