Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Writing a Screensaver

Writing a Screensaver

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gamefreak2291
    wrote on last edited by
    #1

    So, I got a little bored and decided to create a desktop locker through the screensaver function of windows. I'm running XP and Dev C++ 4.9.9.2 and Dev is causing my problem. Other places I've checked said i would need to link "comctl32.lib" which I can't seem to locate on my computer or the internet for download. Incase it would be of any use I'll post my program code.

    #include <iostream>
    #include <windows.h>
    #include <scrnsave.h>

    unsigned char new1;
    using namespace std;

    LONG WINAPI ScreenSaverProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
    {
          // Handles screen saver messages
          switch(message)
          {
          case WM_CREATE:
                // Creation of the screen saver window
                return 0;
          case WM_ERASEBKGND:
                // Erases the screen saver background
                return 0;
          case WM_TIMER:
    uTimer = SetTimer(hwnd, 1, 1000, NULL);
                // Handles the timer
                return 0;
          case WM_DESTROY:
    KillTimer(hwnd, uTimer);
                // Cleans up the screen saver window
                PostQuitMessage(0);
                return 0;
          }
          return DefScreenSaverProc(hwnd,message,wparam,lparam);
    }
    BOOL WINAPI ScreenSaverConfigureDialog(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
    {
          return true;
    }
    BOOL WINAPI RegisterDialogClasses(HANDLE hmodule)
    {
          return true;
    }

    I receive an error with the "uTimer = SetTimer(hwnd, 1, 1000, NULL);" line of code, but I'm assuming that its linked to the comctl32.lib considering I read scrnsave.h requires it; also the code compiles but does not work without the uTimer line.

    C A 2 Replies Last reply
    0
    • G gamefreak2291

      So, I got a little bored and decided to create a desktop locker through the screensaver function of windows. I'm running XP and Dev C++ 4.9.9.2 and Dev is causing my problem. Other places I've checked said i would need to link "comctl32.lib" which I can't seem to locate on my computer or the internet for download. Incase it would be of any use I'll post my program code.

      #include <iostream>
      #include <windows.h>
      #include <scrnsave.h>

      unsigned char new1;
      using namespace std;

      LONG WINAPI ScreenSaverProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
      {
            // Handles screen saver messages
            switch(message)
            {
            case WM_CREATE:
                  // Creation of the screen saver window
                  return 0;
            case WM_ERASEBKGND:
                  // Erases the screen saver background
                  return 0;
            case WM_TIMER:
      uTimer = SetTimer(hwnd, 1, 1000, NULL);
                  // Handles the timer
                  return 0;
            case WM_DESTROY:
      KillTimer(hwnd, uTimer);
                  // Cleans up the screen saver window
                  PostQuitMessage(0);
                  return 0;
            }
            return DefScreenSaverProc(hwnd,message,wparam,lparam);
      }
      BOOL WINAPI ScreenSaverConfigureDialog(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
      {
            return true;
      }
      BOOL WINAPI RegisterDialogClasses(HANDLE hmodule)
      {
            return true;
      }

      I receive an error with the "uTimer = SetTimer(hwnd, 1, 1000, NULL);" line of code, but I'm assuming that its linked to the comctl32.lib considering I read scrnsave.h requires it; also the code compiles but does not work without the uTimer line.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Suposedly comctl32.lib comes with Microsoft's Platform SDK (you can download that from the MS site), i checked on my system and it sits in "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib" (yes, yes, i am still using VS2003, so sue me :) ), so the platform SDK thing seems to be right. No idea if you can use that with Dev C++ or not...

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      1 Reply Last reply
      0
      • G gamefreak2291

        So, I got a little bored and decided to create a desktop locker through the screensaver function of windows. I'm running XP and Dev C++ 4.9.9.2 and Dev is causing my problem. Other places I've checked said i would need to link "comctl32.lib" which I can't seem to locate on my computer or the internet for download. Incase it would be of any use I'll post my program code.

        #include <iostream>
        #include <windows.h>
        #include <scrnsave.h>

        unsigned char new1;
        using namespace std;

        LONG WINAPI ScreenSaverProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
        {
              // Handles screen saver messages
              switch(message)
              {
              case WM_CREATE:
                    // Creation of the screen saver window
                    return 0;
              case WM_ERASEBKGND:
                    // Erases the screen saver background
                    return 0;
              case WM_TIMER:
        uTimer = SetTimer(hwnd, 1, 1000, NULL);
                    // Handles the timer
                    return 0;
              case WM_DESTROY:
        KillTimer(hwnd, uTimer);
                    // Cleans up the screen saver window
                    PostQuitMessage(0);
                    return 0;
              }
              return DefScreenSaverProc(hwnd,message,wparam,lparam);
        }
        BOOL WINAPI ScreenSaverConfigureDialog(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
        {
              return true;
        }
        BOOL WINAPI RegisterDialogClasses(HANDLE hmodule)
        {
              return true;
        }

        I receive an error with the "uTimer = SetTimer(hwnd, 1, 1000, NULL);" line of code, but I'm assuming that its linked to the comctl32.lib considering I read scrnsave.h requires it; also the code compiles but does not work without the uTimer line.

        A Offline
        A Offline
        Adam Maras
        wrote on last edited by
        #3

        SetTimer is linked in via user32.dll, not the common controls library. Do you have any of the Windows Platform SDKs installed? (I'm not sure what Dev C++ comes with as far as built-in libraries...)

        Adam Maras | Software Developer Microsoft Certified Professional Developer

        G 1 Reply Last reply
        0
        • A Adam Maras

          SetTimer is linked in via user32.dll, not the common controls library. Do you have any of the Windows Platform SDKs installed? (I'm not sure what Dev C++ comes with as far as built-in libraries...)

          Adam Maras | Software Developer Microsoft Certified Professional Developer

          G Offline
          G Offline
          gamefreak2291
          wrote on last edited by
          #4

          No I don't have the SDK platforms, I have VS2008 on another computer or older harddrive somewhere but I have no idea which one and don't exactly prefer using VS over Dev.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups