Screen Saver

I need an example for a screen saver
with out MFC
dafokiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

abancroftCommented:
From MSDN:

Each screen saver must support a window procedure named ScreenSaverProc. Like most window procedures, ScreenSaverProc processes a set of specific messages and passes any unprocessed messages to a default procedure. However, instead of passing them to the DefWindowProc function, ScreenSaverProc passes unprocessed messages to the DefScreenSaverProc function. Another difference between ScreenSaverProc and a normal window procedure is that the handle passed to ScreenSaverProc identifies the entire desktop rather than a client window. The following example shows the ScreenSaverProc window procedure for the sample screen saver.

LONG WINAPI ScreenSaverProc(hwnd, message, wParam, lParam)
HWND  hwnd;
UINT  message;
DWORD wParam;
LONG  lParam;
{
static HDC          hdc;    /* device-context handle */
static RECT         rc;     /* RECT structure */
static UINT         uTimer; /* timer identifier */
 
    switch(message)
    {
        case WM_CREATE:
 
            /* Retrieve the application name from the .rc file. */
 
            LoadString(hMainInstance, idsAppName, szAppName, 40);
 
            /* Retrieve the .ini (or registry) file name. */
 
            LoadString(hMainInstance, idsIniFile, szIniFile,
                MAXFILELEN);
 
            /* Retrieve any redraw speed data from the registry. */
 
            lSpeed = GetPrivateProfileInt(szAppName, szRedrawSpeed,
                DEFVEL, szIniFile);
 
           /*
            * Set a timer for the screen saver window using the
            * redraw rate stored in Regedit.ini.
            */
 
            uTimer = SetTimer(hwnd, 1, lSpeed * 1000, NULL);
            break;
 
        case WM_ERASEBKGND:
 
           /*
            * The WM_ERASEBKGND message is issued before the
            * WM_TIMER message, allowing the screen saver to
            * paint the background as appropriate.
            */
 
            hdc = GetDC(hwnd);
            GetClientRect (hwnd, &rc);
            FillRect (hdc, &rc, GetStockObject(BLACK_BRUSH));
            ReleaseDC(hwnd,hdc);
            break;
 
        case WM_TIMER:
 
           /*
            * The WM_TIMER message is issued at (lSpeed * 1000)
            * intervals, where lSpeed == .001 seconds. This
            * code repaints the entire desktop with a white,
            * light gray, dark gray, or black brush each
            * time a WM_TIMER message is issued.
            */
 
            hdc = GetDC(hwnd);
            GetClientRect(hwnd, &rc);
            if (i++ <= 4)
                FillRect(hdc, &rc, GetStockObject(i));
            else
                (i = 0);
            ReleaseDC(hwnd,hdc);
            break;
 
        case WM_DESTROY:
 
           /*
            * When the WM_DESTROY message is issued, the screen saver
            * must destroy any of the timers that were set at WM_CREATE
            * time.
            */
 
            if (uTimer)
                KillTimer(hwnd, uTimer);
            break;
    }
 
   /*
    * DefScreenSaverProc processes any messages
    * ignored by ScreenSaverProc.
    */
 
    return DefScreenSaverProc(hwnd, message, wParam, lParam);
}
 
0
KangaRooCommented:
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

basantCommented:
Do u want the program using Windows Fns or u want to make a screen saver using Windows hook.
0
laeuchliCommented:
look despite what the samples say, all a screen saver is is a program that takes command line input and parses it for the screen saver commands that windows sends. To find out what they are just take a look at the command line of your app when you rename it to a .scr file. Then parse for thoses inputs.
0
abancroftCommented:
What!!!!

What inputs? Give some examples.
0
laeuchliCommented:
ok, I will give a example after school, I have to get back to work now. I will show you at 4:30
0
laeuchliCommented:
ok, windows passes "s" when it is starting the screen saver. "c" when it is asking for a configeration, and "p" when it is asking for a password.
0
abancroftCommented:
After doing some digging I find that you are correct, ASSUMING that the screen saver library is NOT used.

If the screen saver library is used, it takes care of this detail.

However, it (the screen saver library) also takes care of a bunch of other messages. e.g. WM_SETCURSOR, WM_ACTIVATE, WM_ACTIVATEAPP etc.
0
dafokiAuthor Commented:
laeuchli
i tried whats you said and it's not working
0
laeuchliCommented:
well what part is not working? What did you want it to do that it's not doing? It does not setup your screen or look for mouse movements or anything.show me your code.
0
aviranCommented:
laeuchli did you meant that the screen saver argument should "s" for the screen saver to run and "c" for the configeration to come up?


0
laeuchliCommented:
yes thats right. s when the screen saver is being called on to run and c when its being called on to be configered.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dafokiAuthor Commented:
it works
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.