Click here to Skip to main content
Licence CPOL
First Posted 18 Nov 2002
Views 149,943
Bookmarked 85 times

On Screen Displays, OSDs

By | 23 Nov 2002 | Article
Discusses OSDs and shows you how to implement one under Win32

Sample Image - Forecast.jpg

Foreword

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.

Considerations

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:

  1. 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 WS_EX_TOPMOST style.
  2. 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.
  3. 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!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mehdi Mousavi

Architect

United States United States

Member

Mehdi Mousavi is a professional computer programmer. He has written many programs using C, C++, MFC, Win32, COM, DCOM, JavaScript, ASP, HTML, DHTML, SQL, C# and MC++.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 Pinmember_Nomad_14:14 12 Feb '10  
QuestionThis Code for C# or delphi ? Pinmemberikarus79:23 9 Dec '05  
GeneralOSD in full screen games PinmemberPOD87@inbox.ru1:17 16 Sep '05  
Generalhandsome PinmemberHuangShansong23:09 28 Jun '05  
Generalhave a problem error on XP sp2 Pinmemberiuzadd20:54 13 Dec '04  
QuestionHow to obtain the same result in a MFC project? PinmemberNico773:59 2 Oct '04  
Generalosd window will interfere DirectX window. Pinmemberlcp_true17:38 9 Oct '03  
GeneralGot clean compile and link, but program won't run. PinmemberWREY18:31 17 Sep '03  
GeneralRe: Got clean compile and link, but program won't run. PinmemberMehdi Mousavi0:58 26 Sep '03  
GeneralUsing Windows Xp Pro and SDK Platform, but... Pinmembersdavis2910:28 4 May '03  
GeneralRe: Using Windows Xp Pro and SDK Platform, but... Pinmembere-sushi22:52 25 May '03  
GeneralRe: Using Windows Xp Pro and SDK Platform, but... PinmemberYohi4:47 18 Oct '03  
GeneralModify to display computername and username Pinmemberrobmail11:11 24 Apr '03  
GeneralRe: Modify to display computername and username Pinmemberrobmail14:44 26 Apr '03  
GeneralRe: Modify to display computername and username Pinmemberrobmail15:07 26 Apr '03  
GeneralGenerating a bitmap with text. Pinmemberjjordan18:06 7 Apr '03  
GeneralLOWERMOST Vs. TOPMOST Pinmemberiluvclubs10:23 3 Feb '03  
General.NET PinmemberWilliam Bartholomew10:38 26 Nov '02  
GeneralScreensaver Issues PinmemberKevin Cotter4:04 26 Nov '02  
GeneralRe: Screensaver Issues PinmemberJohn Bates14:02 26 Nov '02  
GeneralNot erasing the background properly?! PinmemberDWOO17:56 23 Nov '02  
GeneralRe: Not erasing the background properly?! PinmemberMehdi Mousavi15:08 24 Nov '02  
GeneralRe: Not erasing the background properly?! PinmemberDWOO3:08 25 Nov '02  
GeneralRe: Not erasing the background properly?! Pinmemberwheregone22:05 16 Mar '03  
GeneralRe: Not erasing the background properly?! Pinmemberthunderace7:56 6 Sep '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 24 Nov 2002
Article Copyright 2002 by Mehdi Mousavi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid