Introduction
This application displays the current state of the CAPS lock, NUM lock, and SCROLL lock in a single Windows tray icon.
Background
Recently I bought a wireless keyboard that lacks any LED indication for the state of the CAPS lock and NUM lock. This is infuriatingly inconvenient, so I whipped up this little application using the Win32++ framework by David Nash.
Using the Code
The included solution and project are for Visual Studio 2008. The source should work in any development environment for Windows.
The Win32++ framework is refreshingly simple compared to MFC and a delight to work with. This application is actually a modified sample from among the dozens of working samples that come with Win32++. (I actually found it refreshing that all the samples 'just worked' right out of the zip file - with project and solution files for a handful of development environments - a rare gem in the open source world.)
The only thing I had to figure out for myself was how to get the main form to start up in the hidden state and show the tray icon without any user interaction. The trick is to set the creation style to WS_ICONIC
and the extended style to something that doesn't minimize to the task bar, like WS_EX_TOOLWINDOW
.
void CView::PreCreate( CREATESTRUCT& cs )
{
cs.dwExStyle = WS_EX_TOOLWINDOW; cs.style = WS_ICONIC; cs.hMenu = LoadMenu( GetApp()->GetResourceHandle(),
MAKEINTRESOURCE( IDM_MINIMIZED ) );
}
Points of Interest
Feel free to improve the icons; I am not an artist. Enjoy!
History
- July 2010 - Initial submission