- Use Modern GUI Forms
Modern C++ compilers with IDE (Visual C++, C++ Builder, Objective-C, Android Studio, etc.) use a graphical interface by operating system behaviors of the application compiled. Console-based applications are good, but in some cases, you may need to add more features. UI elements make it easy to use applications and understand things on the user side.
Also, these UI elements, graphics, and images make your application visually stunning.
Visual C++ has third-party applications that support skins/styles for UI elements like SkinFramework and SkinCrafter for previous Visual C++ versions.
Skin Framework for Visual C++ MFC provides a skinning user interface framework that was developed with Windows Themes (Visual Styles) in mind. Themed applications can be created with only a few lines of code.
SkinCrafter is another choice for older Visual C++ applications (2012 or earlier). Application skinning is available for a large range of programming languages, tools, and frameworks in SkinCrafter. Apparently, it has no support for the latest Visual C++ versions.
RAD Studio and C++ Builder offer a great variety of styles on both VCL and FMX applications. They also allow users to change the style of application on runtime. These styles can be used for multiplatform applications and can be customized by using the included Bitmap Style Designer in RAD Studio. You can also create a new style from scratch. The easiest way to get started with a brand new style is to use the VCL style template in the Bitmap Style Designer as a guide. VCL Styles supports the Windows theme engine and FMX styles for the cross-platform FireMonkey UI framework are compatible with other operating systems. In addition to window and UI element skins, Styles also comes with a lot of modern icons. Most VCL and FMX Styles are free, and new free versions also can be downloaded by GetIt or by other online web pages.
Table of Contents
Tip 6: Develop GUI-based applications to make easy, understandable apps with stunning graphics.
- Use UI element properties as an output or use UI element methods
In C++, you often write to the console via std::cout, an object is used with streams and so supports the << operator; the direction of arrows shows the output, and anything on the right side of this operator goes as an output. For example:
[crayon-67686aaba2466342135363/]In Modern C++, do not use cout. In backend applications or other OS applications use std::wcout as in the example below. Like strings, this is because it’s a wide character output, ie Unicode.
[crayon-67686aaba246d187576625/]In general, everything goes on Unicode strings or wide strings in Modern C++, and UI apps never use std::cout or std::wcout. Because modern applications are supported with GUIs like buttons, edit boxes, text boxes, drop-down combo boxes, menus, and so on and Modern C++ development IDEs (like C++ Builder, Visual C++) also support Unicode strings, we use the properties of any components as an output instead of using cout.
For example, we can output the name and age to a text property of a label in C++ Builder as below.
[crayon-67686aaba246e602977552/]This print() function example below in C++ Builder outputs Unicode string to Lines of a Memo component.
[crayon-67686aaba246f672100160/]Tip 7: Use UI element properties as an output or UI element methods to output your data.
8. Use UI element properties as an input or use UI element methods
In a console application, the std::cin object is used with the >> operator; the direction of the arrows shows the input, and anything on the right side of this operator goes as an output. For example:
As we described before, Unicode strings or wide strings are needed. In Modern C++, do not use std::cin in backend applications or other OS applications; try to use std::wcin as in the example below.
[crayon-67686aaba2471460870585/]As described above, in visual programming we add texts, text boxes, buttons, labels, drop down labels, and so on, and we call them UI elements, components, or visual tools.
In Modern C++ we use these element properties as an input, or we use their methods to get inputs. For example, we can get input for the name and age from the text property of an edit (text input) component in C++ Builder as below.
[crayon-67686aaba2473435682833/]Tip 8: Use UI element properties as an input or use UI element methods to get input.
- Use methods and features of standard libraries
Many libraries in C++ provide functions for many different applications, while some basic libraries that are like a standard for all c++ applications: STL (Standard Template Library, part of all C++ distributions), which has different implementations depending on the vendor, eg the GNU C++ Standard Library (libstdc++), Microsoft C++ Standard Library (STL), and LLVM C++ Standard Library (libc++).
The STL defines its methods, types etc in the std:: namespace. You can read about the features included in the STL here. There is a great video that shows most of the algorithms of STL here.
Algorithms in this library are optimized well to run faster, and are compatible with many data types. For example, instead of writing a sorting method for a function (e.g., bubble sort, quick sort, merge sort, etc.), you can use parallel algorithms to do multitask operations to use all CPU cores. Some other examples are heaps, permutation, numerical algorithms, querying, searching, fill, copy, move, remove, unique operations in memory, and transform algorithms.
[crayon-67686aaba2474034248157/]Boost Library is another great library to use more algorithms. Boost provides free and well-reviewed portable C++ source libraries that work well with the C++ Standard Library. Boost libraries are intended to be widely useful and usable across a broad spectrum of applications. The Boost license encourages both commercial and noncommercial use.
Tip 9: Use optimized methods and features of standard libraries as much as possible.
Read part 1 of this blog post here
Read part 3 of this blog post here
Find valuable insights on how you can perform a C++ std conversion in this article.
Additionally, learn about TURLStream and how it extends the base class constructor C++.