Thread: Screensaver

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    Screensaver

    I have a program that I want to turn to a screensaver, where can I find some info on how to do it?

    I dont want to use the scrnsave library.

    My compiler is MSVC 6.0 and the program is attached.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I decided to do what your doing a while ago and try figure what's happening without using the screensaver library....as soon as I more or less figured it all out, I realised that there was no benefit to doing this without the lib.....the lib does things very effectively and does cut out a lot of the mediocrity......but hell if you want to go down this avenue read on....

    There are a few things you need to take care of when not using the scrnsave.lib.....

    [list=1][*]Message interaction

    Add the following handlers to your win proc

    Code:
    case WM_SYSCOMMAND:
                  if(wParam == SC_SCREENSAVE || wParam == SC_CLOSE)
                     return FALSE;
               break;
    
    		   case WM_ACTIVATE:
    			   if(wParam == TRUE)
    				   break;
    		   case WM_MOUSEMOVE:
    		   case WM_LBUTTONDOWN:
    		   case WM_MBUTTONDOWN:
    		   case WM_RBUTTONDOWN:
    		   case WM_KEYDOWN:
    		   case WM_KEYUP:
    		   
    			   
    				   DestroyWindow(hwnd);
    			
               break;
    [*] Multiple instances

    Use FindWindow to find other instances of your screensaver, and if the return is not NULL then terminate the app (The system spawns screensavers whenever a certain time elapses with no activity....over time it may spawn loads of screensavers!!)[*] Dialog Interaction

    The dialog on the Desktop->properties allows users to chose screensaver, configure them and preview them....

    When a screensaver is activated, it has a commandline that controls whether the config dialog should be shown, whether the screensaver should preview as a child of the preview box or whether it should run normally...you need to parse the commandline and act accordingly.....

    For example with MyScreensaver.scr...

    Code:
    MyScreensaver /c
    Show the dialog box with whatever toplevel window thats there as its parent.

    Code:
    MyScreensaver /s
    Run the screensaver as normal

    Code:
    MyScreensaver /p 2546
    Run the screensaver in preview mode...the number at the end is the handle to the window that will preview your screensaver.....Parse this string....turn it to a DWORD (and then a HWND)...Get the size of the rect....draw a preview.....
    [/list=1]

    At this point you might agree with me that this is starting to get to be a pain in the butt.........personally......I will go with the scrnsave.lib from now on !

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    The reason I want to work it from scratch is I have a library that handles all my window creation, keyboard, mouse, etc.. And I want to add support for makeing screensavers.

    You can see the lib here.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Eber Kain
    The reason I want to work it from scratch is I have a library that handles all my window creation, keyboard, mouse, etc.. And I want to add support for makeing screensavers.

    You can see the lib here.
    Fair enough....if you are building a lib like that......

    Its not too over the top to do this stuff I suppose....maybe I was in a moaning mood this morning

    Hope the info helped anyway....good luck!

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    57
    I am thinking of making a quick screen saver with OpenGL, does the "scrnsave" library work with that? Where can i access it, and does it have documentation for how to use it? Thanks.
    Language: C++
    Compiler: Visual C++ 6.0
    Currently Working On: Simple OpenGL aspects

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Check out DEVIL Screensaver System!
    By hartwork in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 08-31-2005, 06:28 PM
  2. Canīt create an OpenGL screensaver
    By the dead tree in forum Windows Programming
    Replies: 14
    Last Post: 08-24-2004, 06:18 PM
  3. custom screensaver in XP
    By Draco in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2004, 08:13 PM
  4. OpenGL to Windows Screensaver
    By drdroid in forum Windows Programming
    Replies: 7
    Last Post: 01-03-2003, 09:41 AM
  5. johny castaway screensaver
    By DavidP in forum Tech Board
    Replies: 5
    Last Post: 11-09-2002, 06:05 PM