Select 'Configuration Manager' Active solution configuration > Release Active solution platform > Select New. Then select x64 and it will create the new configuration (if it doesn't exist then 64bit compilers are not installed) To build the x64 executable just select x64 from the projects drop down on the toolbar. Note that it will be created in a […]
All posts by
Setting App To Different Localization
Change the local of the current thread System::Threading::Thread::CurrentThread->CurrentCulture = gcnew System::Globalization::CultureInfo("fr-FR"); System::Threading::Thread::CurrentThread->CurrentUICulture = gcnew System::Globalization::CultureInfo("fr-FR"); CurrentCulture is the .NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting introduced in Windows 2000. This is primarily […]
.Making Values Localization Safe
To deal with values stored with decimal points or commas, etc depending on the location of a user, for all values (int, single, double, etc) don't use Convert::To# anywhere. Use ::Parse like this instead: = Int32::Parse(sTemp, System::Globalization::CultureInfo::InvariantCulture);
Localization using *.resx files
You can create a separate resources file for each language in managed C++ which contain all the strings used by the application. In the solution explorer, right-click the Resource Files folder for the project > Add > New Item > Visual C++ > Resource > Assembly Resource File (.resx). Give it the name AppLocalization.resx for example. Add your strings to the file. Important […]
.Garbage collector general
Force garbage collection to finish up its background tasks: GC::Collect(); GC::WaitForPendingFinalizers();
Unlocking files used by your application so they can be moved or deleted
Sometimes it is necessary to force the background garbage collector to finish up all its tasks so a file recently used can be moved or deleted: //First force the garbage collector to finish up so the file is released from its last access GC::Collect(); GC::WaitForPendingFinalizers();
Checkboxes
Turning On Checkboxes For A TreeView MyTreeView->CheckBoxes = true; Showing Checkboxes only for certain nodes This isn't a feature of TreeView, but can easily be created by using images – see below… Using images for tree view nodes (e.g. checkboxes only for some nodes) Add an image list to your form. Set its ImageSize property to match the […]
Sort List
Sort A List MyListName->Sort(); Sort A List Of Custom Classes You need to add a CompareTo method to the class which will be used when Sort is called. It needs to be virtual for C++/CLI and you also need to add :IComparable to the class definition. Example For An Int Value (Uses a '.' for the […]
.Tree View General
Clear Tree View tvSelectProbe->Nodes->Clear(); Add A Node tvSelectProbe->Nodes->Add("Some Text"); Add Sub Nodes The Tree View is made up of TreeNodes which themselves can be made up of TreeNodes… this->SuspendLayout(); //Create first sub node TreeNode ^TreeNode2 = gcnew TreeNode("Tree Node 2"); TreeNode2->Nodes->Add("Sub 2"); //Create second sub node TreeNode ^TreeNode3 = gcnew TreeNode("Tree Node 3"); TreeNode3->Nodes->Add("Sub 3A"); […]
SELECT Queries
SELECT Query Example Command1->CommandText = "SELECT * FROM MyTable WHERE SomeColumnName >= @StartValue AND SomeColumnName <= @EndValue"; Command1->Parameters->AddWithValue("@StartValue", 14); Command1->Parameters->AddWithValue("@EndValue", 28); System::Data::SQLite::SQLiteDataReader ^Reader1 = Command1->ExecuteReader(); { while (Reader1->Read()) { MyVariable = Convert::ToString(Reader1["SomeColumnName1"]); MyVariable2 = Convert::ToInt32(Reader1["SomeColumnName2"]); } } Reader1->Close(); //Bugfix to workaround sqlite "database is locked" issue when updating after a read while (!Reader1->IsClosed) System::Threading::Thread::Sleep(1); //mS […]
