Welcome to CScreenSaver, a collection of freeware MFC classes to encapsulate screen savers.
The screen saver library provided in the Windows SDK namely SCRSAVE.LIB is designed for SDK apps and cannot be used with traditional MFC apps. CScreenSaver provides an MFC class framework to allow screen savers to be built using "normal" MFC code.
Features |
Usage |
History |
API Reference |
Contacting the Author |
v1.08 (25 April 2022)
v1.07 (25 March 2020)
v1.06 (23 December 2019)
v1.05 (3 June 2019)
v1.04 (29 October 2018)
v1.03 (30 January 2016)
v1.02 (18 July 2006)
v1.01 (6 January 2006)
v1.0 (5 May 2000)
The API consists of the following member functions of the classes CScreenSaverApp & CScreenSaverWnd
CScreenSaverApp::CScreenSaverApp
CScreenSaverApp::SetScreenSaverTemplate
CScreenSaverApp::ParseCommandLine
CScreenSaverApp::ProcessShellCommand
CScreenSaverApp::InitInstance
CScreenSaverApp::ShowConfigureDialog
CScreenSaverWnd::CScreenSaverWnd
CScreenSaverWnd::Create
CScreenSaverWnd::SetPreviewFlag
CScreenSaverWnd::GetBoundingRect
CScreenSaverWnd::GetWindowStyle
CScreenSaverWnd::GetExtendedWindowStyle
CScreenSaverApp::CScreenSaverApp
CScreenSaverApp::CScreenSaverApp();
Remarks
Standard constructor for the app class. This class is derived from the standard MFC class CWinApp and handles all the command line parsing for screen savers as well as the creation of the screen saver window. You should call SetScreenSaverTemplate in your derived instances. constructor
CScreenSaverApp::SetScreenSaverTemplate
void CScreenSaverApp::SetScreenSaverTemplate(CRuntimeClass* pRuntimeScreenSaverWnd);
Parameters
pRuntimeScreenSaverWnd a pointer to the RUNTIME_CLASS of the screen saver window class you want to use.
Remarks
You should call this function in your apps constructor to inform the framework what derived class of CScreenSaverWnd to use. To see an example of this, see the code in the sample screen savers app.cpp module.
CScreenSaverApp::ParseCommandLine
virtual void CScreenSaverApp::ParseCommandLine(CScreenSaverCommandLineInfo& rCmdInfo);
Parameters
rCmdInfo a reference to a simple derived class from CCommandLineInfo used to hold the results of the command line when it is parsed.
Remarks
This function parses the command line. It handles all the command line options appropriate for a screen saver (The command line to the screen saver is in fact the API used by screen savers) plus a few undocumented ones. This function is automatically called for you in the InitInstance method of CScreenSaverApp, so there should be no need to override this.
The command line parameters supported are:
/c [HWND] | Shows the Screen saver configuration dialog |
/p [HWND] |
Displays the screen saver in "Preview" mode. |
/s |
Runs the screen saver for real. |
CScreenSaverApp::ProcessShellCommand
virtual BOOL CScreenSaverApp::ProcessShellCommand(CScreenSaverCommandLineInfo& rCmdInfo);
Return Value
The return value should be used as the return value from the InitInstance method.
Parameters
rCmdInfo a reference to a the parsed command line info.
Remarks
Internally this function takes the command line information as parsed using ParseCommandLine and uses them to create the screen saver window as appropriate. It also handles bringing up the configure dialog and the change password dialog as appropriate. This function is automatically called for you in the InitInstance method of CScreenSaverApp, so there should be no need to override this.
virtual bool CScreenSaverApp::InitInstance();
Return Value
As per CWinApp::InitInstance.
Remarks
This derived method handles all the command line parsing and creation of the screen saver window for you. You should only need to override this function if you need to do something special in your app's initialisation.
CScreenSaverApp::ShowConfigureDialog
void CScreenSaverApp::ShowConfigureDialog(CWnd* pParentWnd);
Parameters
pParentWnd The window that any dialogs / window which this method shows should be modal with respect to.
Remarks
You need to override this function in your derived version of CScreenSaverApp to display some dialog to allow the settings specific of your screen saver to be configured. You also need to handle the persistence of the values. If you forget to override this function, then a simple message box will be shown to remind you to implement it. Normally what you should do here is display some type of CDialog or CPropertySheet derived window.
CScreenSaverWnd::CScreenSaverWnd
CScreenSaverWnd::CScreenSaverWnd();
Remarks
Standard constructor for the screen saver window class. Internally this just initializes protected member variables needed by the class.
virtual BOOL CScreenSaverWnd::Create(bool bChild, CWnd* pParentWnd);
Return Value
TRUE if the window was created successfully otherwise FALSE.
Parameters
bChild TRUE if the screen saver window should be created as a child (WS_CHILD). This is required when the screen saver is run in preview mode.
pParentWnd The parent window which the screen saver should use.
Remarks
This function creates the screen saver window. It is modelled on the CWnd method of the same name. The default implementation creates a screen saver of the appropriate size, window styles and the correct parent. It also initializes the window with an appropriate cursor and a black background.
CScreenSaverWnd::SetPreviewFlag
void CScreenSaverWnd::SetPreviewFlag(bool bPreview);
Parameters
bPreview TRUE if the screen saver window is being run in preview mode else FALSE.
Remarks
This function is used to inform the screen saver window that it is in preview mode rather than running for real. This function is called automatically for you in CScreenSaverApp. The window needs to be able to differentiate between the two modes of the screen saver so that it does not close down when you move the mouse over it when in preview mode.
CScreenSaverWnd::GetBoundingRect
virtual BOOL CScreenSaverWnd::GetBoundingRect(bool bChild, CWnd* pParentWnd, CRect& rRect);
Return Value
TRUE if the function succeeds otherwise FALSE.
Remarks
By default the rect returned will be the bounding rect for the virtual desktop. This ensures that in systems with multiple monitors, that the screen saver will span across all the monitors.
CScreenSaverWnd::GetWindowStyle
virtual DWORD CScreenSaverWnd::GetWindowStyle();
Return Value
The window styles to use when creating the screen saver window via the "Create" method.
Remarks
By default the style value returned will be setup depending on the command line send into the screen saver. For example when run in preview mode, the WS_CHILD style will be used while the WS_POPUP style will be used when run normally.
CScreenSaverWnd::GetExtendedWindowStyle
virtual DWORD CScreenSaverWnd::GetExtendedWindowStyle();
Return Value
The extended window styles to use when creating the screen saver window via the "Create" method.
Remarks
By default the style value returned will be setup depending on the command line sent into the screen saver. For example when in normal display mode, the WS_EX_TOPMOST will be used.
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
25 April 2022