Which command line parser for C++ apps ?

If you need to parse command line arguments in C++, don’t reinvent the wheel, use an existing library. That’s the kind of problem that seems so simple that it’s obvious you’ll quickly hack it. Then you face parsing bugs, spaces within parameters, special characters, optional parameters, config files, etc. Eventually you’ll switch to a library, so save time and do it from the beginning.

Many libraries are available out there for C++ applications, I’ll focus on two of them : Boost.Program_options and GetPot. Continue reading

Basic color scale conversion algorithm

Your app has some pictures/icons, and you’d like to have them in different color scales, for highlighting for example.
Rather than creating a different set of icons, it is cheaper to convert them dynamically to the desired color : redscale, greenscale, or bluescale.
earth
Continue reading

How to enable/disable Windows application Visual Styles at runtime ?

The challenge : update the look&feel of an outdated Borland C++ Builder 4 application, while changing the minimum amount of code, and keeping the same old 1998 compiler… To make things even easier, the new look and feel must be enabled/disabled at runtime.

First, the application UI controls  are straight out of the nineties. To modernize their look without replacing or rewriting them, Microsoft introduced in Windows XP “Application Visual Styles”. The MSDN doc about Visual Styles is not great, but this CodeProject article from Martin Mitáš gives a great overview. Continue reading

Where are JAVA user preferences saved on Windows ?

If you want to store user preferences/settings for a JAVA application, the java.util.prefs.Preferences class is the way to go. It abstracts the storage of the user info, as explained in the JAVA doc:

This class allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store.

Question : On Windows, where are the JAVA user preferences stored ?
Answer : In the registry. Typically in HKEY_CURRENT_USER\Software\JavaSoft\Prefs\[your path] If you want to change your storage (i.e : backing store) you will need a new PreferencesFactory, as detailed in this post.