Customizing a Screen Saver for a Thin Client (Windows Embedded CE 6.0)
1/5/2010
This topic provides guidelines about how to create a custom screen saver for a Windows Embedded CE powered thin client that uses the Windows Thin Client Shell.
Source Code for Screen Savers
Windows Embedded CE provides public source code for the three screen savers that are available with Remote Desktop Protocol (RDP) when you are using the Windows Thin Client Shell (SYSGEN_WBTSHELL) for an operating system (OS) design. The following chart shows these three screen savers.
Screen saver | Description | Source code |
---|---|---|
ssfloat |
A customizable floating-style screen saver |
%WINCEROOT_%\PUBLIC\RDP\OAK\UIT\SCRSAVE\FLOAT |
ssblank |
A customizable blank screen saver that turns off the monitor |
%WINCEROOT_%\PUBLIC\RDP\OAK\UIT\SCRSAVE\BLANK |
sstile |
A customizable tiled-style screen saver that displays four bitmaps in each corner of the screen |
%WINCEROOT_%\PUBLIC\RDP\OAK\UIT\SCRSAVE\TILE |
To create a custom screensaver, you can use one of the provided screen savers as a template and add your own custom code. For example, you can modify the ssfloat screen saver to display a series of custom bitmap images based on a timer. Or, you could use DirectDraw with Graphics Device Interface (GDI) to create a full-color graphics screen saver program. Be aware that when a screen saver is graphics-intensive, it may require additional supporting components, drivers, and memory space.
Before you write any screen saver code, you should examine the source code for the provided screen savers as an example. This source code is described in the following paragraphs.
Ssfloat Source Code Walkthrough
The ssfloat source code is located in %WINCEROOT_%\PUBLIC\RDP\OAK\UIT\SCRSAVE\FLOAT\scrsave.c. Scrsave.c implements the functions StartScreenSaver and StopScreenSaver, both defined in scrsave.h, located in %WINCEROOT_%\PUBLIC\RDP\OAK\UIT\INC. Scrsave.c also provides a DLL entry point function, an application-defined screen saver thread function, a custom function called DrawBitmap, and a WndProc to handle the windows messages for the screen saver.
The StartScreenSaver function implementation first checks whether the screen saver thread is running. If the thread is running, this means the screen saver is active, and StopScreenSaver is called to deactivate it.
Next, StartScreenSaver calls the CreateThread function to start a new screen saver thread by calling the thread function ScreenSaverThread. ScreenSaverThread first loads the bitmap file that is located in \Windows\windowsce.bmp. Then, it sets the on-screen width and height for the bitmap, creates and registers a new window class named SCR_SAVE_WINDOW_CLASS, calls CreateWindowExW to create a topmost window above all other windows in the z-order, and finally calls ShowWindow to show the new window.
ScreenSaverThread then starts a message loop for the window. The WndProc of the window handles all the necessary windows messages. This includes WM_CREATE and WM_PAINT. With WM_CREATE, WndProc sets a timer. With WM_PAINT, it calls the custom DrawBitmap function. When the message loop receives WM_QUIT, ScreenSaverThread deletes the loaded bitmap and unregisters the window class.
The StopScreenSaver function checks whether the screen saver thread is running. If it is, StopScreenSaver sends its window a WM_CLOSE message, ends the screen saver thread, and closes its handle.
Ssblank Source Code Walkthrough
The ssblank source code is located in %WINCEROOT_%\PUBLIC\RDP\OAK\UIT\SCRSAVE\BLANK\scrsave.c. Scrsave.c implements the functions StartScreenSaver and StopScreenSaver. These are both defined in scrsave.h, located in %WINCEROOT_%\PUBLIC\RDP\OAK\UIT\INC. Scrsave.c also provides a DLL entry point function.
The StartScreenSaver function implementation for ssblank checks whether the graphics adapter supports an escape value for GETPOWERMANAGEMENT. It does this by calling ExtEscape, passing in QUERYESCSUPPORT. If an escape value is supported, the function returns nonzero. If this is the case, ssblank creates a VIDEO_POWER_MANAGEMENT structure of the appropriate size and uses it to set the power state of the display screen to VideoPowerOff.
StopScreenSaver does the opposite of StartScreenSaver by performing the same set of steps to set the power state of the display screen to VideoPowerOn.
Sstile Source Code Walkthrough
The sstile source code is located in %WINCEROOT_%\PUBLIC\RDP\OAK\UIT\SCRSAVE\TILE\scrsave.c. Scrsave.c implements the function StartScreenSaver and StopScreenSaver. These are both defined in scrsave.h, located in %WINCEROOT_%\PUBLIC\RDP\OAK\UIT\INC. Scrsave.c also provides a DLL entry point function, an application-defined screen saver thread function, and a WndProc to handle the windows messages for the screen saver.
The StartScreenSaver function implementation is identical to ssfloat's function implementation. A small difference occurs when this function calls the thread function ScreenSaverThread. ScreenSaverThread loads the bitmap located in \Windows\windowsce.bmp, but then ScreenSaverThread calls CreatePatternBrush for the bitmap, and then uses this pattern brush for the window background. A pattern brush is a bitmap that the system uses to paint the interior of filled shapes, such as a rectangle. In this case, the window is filled with a pattern created by tiling the specified bitmap.
The StopScreenSaver function implementation is identical to the ssfloat function implementation.
Build a Custom Screen Saver DLL
Instead of customizing one of the three available screen savers, you may also create your own custom screen saver DLL and add it to the OS design before you build a run-time image. Make sure that it is based on one of the example screen savers, includes the header files windows.h, commctrl.h, types.h, scrsave.h, scrsavep.h, and regmgr.h, and implements the StartScreenSaver and StopScreenSaver functions.
For information about how to add a project to an OS design, see Adding a Subproject to an OS Design.
Edit the Screen Saver Registry Settings
To make sure that your custom screen saver is displayed during idle time on your thin client, you must edit the registry settings in rdp.reg before you build a run-time image. If you have customized one of the three screen savers, make sure that you set the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBT\Shell\ScreenSaver registry key to either ssblank
, ssfloat
, or sstile
.
If you have built a custom screen saver DLL and added it to the run-time image, you must set the ScreenSaver registry key to the name of the DLL. For example, if you created a screen saver called images.dll, set the ScreenSaver registry key to images
. For more information, see Configuring Screen Savers on a Thin Client.
To get started with customizing a screensaver
In Platform Builder, select Catalog Items View.
Expand the Core OS node and navigate to Core OS\CEBASE\Shell and User Interface\Graphical Shell\Windows Client Shell.
Expand the Windows Client Shell node.
Select the Windows Based Terminal Screensavers component.
Right-click the component and select Display in Solution View.
In the Solution Explorer window, expand the highlighted scrsave node, expand the folder that represents the screen saver that you want to customize, and then expand Source files.
Double-click scrsave.c.
When you are finished with customizing the code, on the File menu, select Save <Filename>.
Right-click on the scrsave node and select Sysgen.
Configure the registry by completing the steps in Configuring Screen Savers on a Thin Client.