Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
IDE

15 Tips to Graduate from Classroom C++ to Modern C++ Part 2/3

digital-particles
  1. 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. 

15-tips-tour_first

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.

222

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.

333

Tip 6: Develop GUI-based applications to make easy, understandable apps with stunning graphics.

  1. 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:

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.

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.

This print() function example below in C++ Builder outputs Unicode string to Lines of a Memo component.

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.

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.

Tip 8: Use UI element properties as an input or use UI element methods to get input.

  1. 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.

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


What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and other operating systems. He was born in 1974, Eskisehir-Turkey. He graduated from the Department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later, he started to work in the same university as an assistant. He received his MSc and Ph.D. degrees from the same department of the same university. Since 2012, he is the founder and CEO of Esenja LLC Company. Some of his interests are Programming, Thermodynamics, Fluid Mechanics, and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations. He has married, and he is a father of a son.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES