I want to create an on-screen display, i.e. text or simple graphics that appear on top of everything else being displayed. I know in Linux this is achieved with xosd, but how do you do it in Windows? (Assume XP and up if it makes it easier, and I would also be interested in knowing if the method is different in Vista/7)
-
Is it enough to just display a non-activated always-on-top window, or do you want to draw text and simple graphics directly on the screen surface?– AndersOct 31, 2010 at 9:49
-
Directly I guess - the user shouldn't be able to interact with it at all.– ZoFreXOct 31, 2010 at 18:41
3 Answers
You can use NativeWindow to do this as described here.
The article explains how to create an OSD window with animation/semi-transparent effects, in C#, using the NativeWindow class.
-
1I don't think ZoFreX was looking for C# code, but that article does use all the right Win32 APIs so duplicating the effect in native code should not be hard. Nov 1, 2010 at 14:03
-
Yeah, the code is less important than explaining what properties the window needs, and why. That article contained exactly what I was looking for, thanks!– ZoFreXNov 1, 2010 at 22:49
Use the WS_EX_LAYERED
style to make the window transparent, and SetWindowPos(..., HWND_TOPMOST, ...)
to make it float above other windows.
You can call SetForeGroundWindow
-
1A OSD is usually not a active window, besides, you can't just call SetForeGroundWindow since only the foreground process is allowed to do that.– AndersOct 31, 2010 at 12:09