Desktop Clocks strike back!
I wanted to create application that will always be on top of my screen, but will not bother me when I work with the other windows behind it. It could be some kind of desktop clocks.
It was not so difficult to implement: I decided to use pure WINAPI, so solution was clear – to use WS_EX_LAYERED flag for visual transparency and WS_EX_TRANSPARENT for “physical” transparency (mouse clicked through the application window).
I also added a functionality of “being more transparent when have mouse pointer other me”, so it makes my clocks a little bit friendlier to the user.
But user still needs to have a way to interact with clocks window using mouse: to move it or to close it.
This is the solution that I found: when user “touches” top border of the clocks (actually, just moves mouse cursor over there), it starts loosing its transparency. After it loses it completely, it also loses “physical” transparency, so user can click on it. I also added a sort of border and mouse cursor change to show user that he is able to drag the window.
After user releases the window after dragging and mouse cursor goes out of window rectangle, Clocks becomes transparent again. I like this solution pretty much 😉
You can find here source code and executable (12 kb, rename doc to zip after downloading, the project is for VS 2005, but this plays no big role, since everything is in a single source file).