Click here to Skip to main content
13,863,336 members
Click here to Skip to main content
Add your own
alternative version


93 bookmarked
Posted 18 Nov 2002
Licenced CPOL

On Screen Displays, OSDs

, 23 Nov 2002
Rate this:
Please Sign up or sign in to vote.
Discusses OSDs and shows you how to implement one under Win32

Sample Image - Forecast.jpg


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:

  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!


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


About the Author

Mehdi Mousavi
United States United States
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++.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
_Nomad_12-Feb-10 15:14
member_Nomad_12-Feb-10 15:14 
QuestionThis Code for C# or delphi ? Pin
ikarus79-Dec-05 10:23
memberikarus79-Dec-05 10:23 
GeneralOSD in full screen games Pin
Member 201618116-Sep-05 2:17
memberMember 201618116-Sep-05 2:17 
Generalhandsome Pin
HuangShansong29-Jun-05 0:09
memberHuangShansong29-Jun-05 0:09 
Generalhave a problem error on XP sp2 Pin
iuzadd13-Dec-04 21:54
memberiuzadd13-Dec-04 21:54 
QuestionHow to obtain the same result in a MFC project? Pin
Nico772-Oct-04 4:59
memberNico772-Oct-04 4:59 
Generalosd window will interfere DirectX window. Pin
Member 4503529-Oct-03 18:38
memberMember 4503529-Oct-03 18:38 
GeneralGot clean compile and link, but program won't run. Pin
WREY17-Sep-03 19:31
memberWREY17-Sep-03 19:31 
GeneralRe: Got clean compile and link, but program won't run. Pin
Mehdi Mousavi26-Sep-03 1:58
memberMehdi Mousavi26-Sep-03 1:58 
GeneralUsing Windows Xp Pro and SDK Platform, but... Pin
sdavis294-May-03 11:28
membersdavis294-May-03 11:28 
GeneralRe: Using Windows Xp Pro and SDK Platform, but... Pin
Yohi18-Oct-03 5:47
memberYohi18-Oct-03 5:47 
GeneralModify to display computername and username Pin
robmail24-Apr-03 12:11
memberrobmail24-Apr-03 12:11 
GeneralRe: Modify to display computername and username Pin
robmail26-Apr-03 15:44
memberrobmail26-Apr-03 15:44 
GeneralRe: Modify to display computername and username Pin
robmail26-Apr-03 16:07
memberrobmail26-Apr-03 16:07 
GeneralGenerating a bitmap with text. Pin
jjordan7-Apr-03 19:06
memberjjordan7-Apr-03 19:06 
iluvclubs3-Feb-03 11:23
memberiluvclubs3-Feb-03 11:23 
General.NET Pin
William Bartholomew26-Nov-02 11:38
memberWilliam Bartholomew26-Nov-02 11:38 
GeneralScreensaver Issues Pin
Kevin Cotter26-Nov-02 5:04
memberKevin Cotter26-Nov-02 5:04 
GeneralRe: Screensaver Issues Pin
John Bates26-Nov-02 15:02
memberJohn Bates26-Nov-02 15:02 
GeneralNot erasing the background properly?! Pin
DWOO23-Nov-02 18:56
memberDWOO23-Nov-02 18:56 
GeneralRe: Not erasing the background properly?! Pin
Mehdi Mousavi24-Nov-02 16:08
memberMehdi Mousavi24-Nov-02 16:08 
GeneralRe: Not erasing the background properly?! Pin
DWOO25-Nov-02 4:08
memberDWOO25-Nov-02 4:08 
GeneralRe: Not erasing the background properly?! Pin
wheregone16-Mar-03 23:05
memberwheregone16-Mar-03 23:05 
GeneralRe: Not erasing the background properly?! Pin
thunderace6-Sep-03 8:56
memberthunderace6-Sep-03 8:56 
Questionhow about a NT version!! Pin
Agnihothra19-Nov-02 17:47
memberAgnihothra19-Nov-02 17:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Cookies | Terms of Use | Mobile
Web04 | 2.8.190214.1 | Last Updated 24 Nov 2002
Article Copyright 2002 by Mehdi Mousavi
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid