2

I got an interesting request from the higher ups. They want a simple app that will show on users' computers to display the time in multiple time zones. That, in itself, is trivial; a simple window with a timer that will get the current UTC time and convert it to any number of time zones they want to see to update some labels' text.

Here's the rub, though; to meet requirements all around, the window can never obscure nor be obscured by anything else on the desktop. The user will be running other applications that must be fully visible at all times, and at the same time this app cannot be covered by one of those windows.

So, I was thinking of implementing it in one of two ways:

  • As an app that is always on top, but the background would be completely transparent and the time displays would be 50% transparent or some such. Moving the mouse over the window would "highlight" the time displays by removing their transparency and/or adding opaque high-contrast backgrounds. AFAIK this solution cannot use Windows Aero, because the OS of the primary users would be Windows XP.

  • As an app that uses low-level Windows messages to somehow mimic the behavior of the Windows taskbar in its "always on top" mode; it will dock to the top of the screen, will always show on top of "normal"-state windows, and additionally will govern the "maximize" behavior of other windows so that those windows won't overlap it when maximized.

I really have no idea where to start to implement either of these, but I would hazard a guess that given the WinXP limitation, the second option is easier if possible at all. So, what behaviors would I be looking to implement to tell Windows to never maximize over the top of my form?

KeithS
  • 70,210
  • 21
  • 112
  • 164
  • It's been awhile since I've looked at them but I'm wondering if something like Yahoo Widgets would meet your requirements exactly without needing to write a thing. http://widgets.yahoo.com/ – dkackman Dec 14 '11 at 18:54
  • 1
    You'll need to pinvoke SHAppBarMessage(). Plenty of google hits for that, first hit: http://www.codeproject.com/KB/dotnet/AppBar.aspx – Hans Passant Dec 14 '11 at 19:09
  • @dkackman: It's a good thought but I don't think the higher-ups will go for having Yahoo products installed on these workstations. The regs in question are UL regs, and the computers are used basically by call staff so they have the workstations locked down pretty hard. – KeithS Dec 14 '11 at 19:13
  • @HansPassant: That's EXACTLY what I needed. I'll research more and see if this is feasible in our situation, but the basic concept matches our requirements perfectly. – KeithS Dec 14 '11 at 19:19

1 Answers1

1

As an epitaph, since Hans Passant seems reticent to post answers, I found that what I needed was to make the app an "Application Desktop Toolbar", or Appbar. The CodePlex link Hans gave, http://codeproject.com/KB/dotnet/AppBar.aspx, as well as the MSDN article on the topic, http://msdn.microsoft.com/en-us/library/windows/desktop/cc144177%28v=vs.85%29.aspx, give a lot of information. I was able to pretty much copy/paste the region of code from CodePlex defining the AppBar behavior into an otherwise normal .NET form, to create a simple proof-of-concept:

enter image description here

The one change I made from the CodePlex code was to sever the half of RegisterBar() that registers the form as an AppBar from the code that tears it down, so a call to RegisterBar() always does exactly that instead of alternately registering and un-registering it.

KeithS
  • 70,210
  • 21
  • 112
  • 164