August 1997

Undocumented Winsys

by Kent Reisdorph

A couple of Winsys classes aren't documented in Borland C++. One of these is the TUIMetric class, which encapsulates the Windows API function GetSystemMetrics(). While the accompanying article, "Using OWL Classes in C++Builder," isn't about system metrics, a quick example will help you understand just what this class does. Let's say you want to find the height of a single-line menu bar. You could use the API as follows:

int width = GetSystemMetrics(SM_CYMENU); 
Or, you could use TUIMetric to accomplish the same task. By using the TUIMetric class you can shorten the line a bit:
int width = TUIMetric::CyMenu;
It's up to you to decide whether using TUIMetric provides enough savings to make using it in your applications worthwhile.

You may also want to check out the Winsys class TSystem. This class provides functions for querying the operating system for information like the current OS (Windows 95 or NT), the version number, the build number, and so on. Functions include IsNT(), IsWin95(), Has3dUI(), GetProcessorType(), GetBuildNumber(), and more.

Like TUIMetric, TSystem is undocumented as far as I know, so even if you're a seasoned OWL programmer you may not be aware that it exists. This class may prove handy if your application needs to know such OS information as the specific version of Windows the user is running under.

Kent Reisdorph is a editor of the C++Builder Developer's Journal as well as director of systems and services at TurboPower Software Company, and a member of TeamB, Borland's volunteer online support group. He's the author of Teach Yourself C++Builder in 21 Days and Teach Yourself C++Builder in 14 Days. You can contact Kent at editor@bridgespublishing.com.