On Screen Displays, (A.K.A OSD) are some kind of cool features that I saw in Sony televisions many years ago for the first time. Today, I am going to show you how to implement an OSD as a standalone executable Win32 application, that reports live weather information according to an online resource.
What’s an OSD?
OSD is actually some kind of information given to the user when a certain event occurs. For example, when a user decides to manipulate the volume of her TV, a text appears at the bottom (or top) of the screen presenting the percentage of the voice’s power already settled on TV. It also displays the channel number already selected by the user at the top rid-side of the screen, usually in green color and for a period of two seconds. That’s what OSD is all about.
To start developing a neat thing, please keep in mind that an OSD is not supposed to interfere with user’s actions in any kind of form. For example, what should happen when a text is presented on screen and user tries to open up her Windows Explorer?
Well, here are three things we have to keep in mind while developing an OSD:
- The window has to be always the top most window, or else, the text might be hidden at the back of a newly-opened window. This feature is given to our OSD window using the
- The visual transparency of the text that happens to be presented on screen is the second thing you’ve to consider when developing an OSD. This is given to our window using the
WS_EX_TRANSPARENT style. This way, the user could see what is going on behind the text, too.
- The user should be able to select a window and/or icon behind the text, using her mouse or any kind of pointing devices she may have. This is supposed to be the most effective feature of an OSD which is given to our window using the
WS_EX_LAYERED style (Thanks to Microsoft that ships this cool feature with its Win2K).
Give me a sample!
The sample I’m going to bring you here is supposed to show you the current temperature of a given zip code in the country, every x minutes. The information is obtained from a web service provided by Unisys Company. The idea is that the temperature will be settled on CRT for a given period of time. To catch this period from the user I considered the command line as a channel between the application and the end-user.
Here’s the syntax of the program:
Forecast.exe /u10 /d2 /z95123
Where /u represents the update interval (in minutes) between every show, /d represents the duration for which the text will be settled on screen (in seconds), and /z represents a zip code within US.
Therefore, the above-mentioned command line means that you want Forecast to show you the weather information of San Jose city of California which will be updated every 10 minutes and will be presented on screen for a period of 2 seconds. I also tried to represent an icon in the tray bar so that the user could easily manage how to exit the program.
The final word
The program is written straight forward so that you could easily follow the source code to understand what is going on. The example I brought you here (Forecast) might be useless since there is possibly no one who monitors the temperature of a given zip code, 24 hours a day, 7 days a week. And therefore, the information already revealed in this article was only supposed to show you how to develop an OSD under Win32 platform. You can manipulate the program to give you other information as you wish. Good luck!