Author Archives: Nicolas Riousset

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.

How to kill all active connections to a SQL Server DB before a restore ?

You may have faced situations when you need to restore a SQL Server database, but the restoration fails because a connected user prevents SQL Server from acquiring the required exclusive mode.

The T-SQL script below will kill all active sessions by switching immediately to exclusive mode. you’ll then be able to restore the db (or perform any other operation requiring exclusive mode), before switching back to multi-user mode. Continue reading