Screen Saver Base Class

–>

In Window95 a screen saver can be previewed in display property dialog . How can the
application knows whether it runs in full screen mode or in the preview mode . If the the
first parameter is ‘c’ you need to run
config . if it is ‘p’ you need to create a
preview window . If it is ‘s’ you need to
create full screen window .

I write the three base class which are for the common usage .

  1. One is derived from CWinApp , it(CSSApp) will judge whether runs in
    full screen mode or in preview mode and call the proper member function to start task .
  2. The other two are derived from CWnd , one(CFullWnd) is full screen
    window the other(CSmallWnd) is preview window.

There are some virtual member function in the CSSApp .

  1. InitInstance(…) It will judge the running mode and call the proper
    function (DoConfig, DoSmall or DoFull) .Your class derived from CSSApp must call it in
    InitInstance .
  2. DoConfig(…) You must override it to display your configuration dialog
    .
  3. DoSmall(…) You must override it to create your preview mode window .
    You need create a child whose parent window is CWnd* pParent =
    CWnd::FromHandle((HWND)atol(__argv[2]))
    .
  4. DoFull(…) You must override it to display the full screen window .

The class CFullWnd and CSmallWnd can be the base
class of your full screen window class and preview window class . When the window is
created it will generate a timer . The thing you need to do is overriding the OnTimer(…)
function .

Download demo project – 177 KB

Download source – 27 KB

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read