Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <scrnsave.h>
- #include <commctrl.h>
- #include "resource.h"
- // Include these libraries
- #pragma comment(lib, "ScrnSave.lib")
- #pragma comment(lib, "comctl32.lib")
- // Screen saver library contains the main function and other
- // Startup code required for a scrnsaver user defined vars
- #define TIMER 1
- // Global variables
- int Width, Height; // Size of screen variables
- // Screensaver procedure...first when window is created:
- // 1) get users window resolution
- // 2) call a function that sets up OpenGL
- // 3) Setup a TIMER that will be used to drive animations
- LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- static HDC hDC; // Handle to device context
- static HGLRC hRC; // Handle to OpenGL rendering context
- static RECT rect; // Instance of structure RECT which defines the
- // coords of the upper-left and lower-right
- // corners of a rectangle
- switch(message)
- {
- // Set timer and any other initializations
- case WM_CREATE:
- GetClientRect(hWnd, &rect); // Get window dimensions
- Width = rect.right; // Store width
- Height = rect.bottom; // Store height
- SetTimer(hWnd, TIMER, 10, NULL);
- return 0;
- case WM_DESTROY: // Destroy timer and perform cleanup
- KillTimer(hWnd, TIMER); // Destroy timer
- return 0;
- case WM_TIMER: // Perform drawing operations
- return 0;
- }
- // Unprocessed messages are handled by the screen saver
- // library by calling the following:
- return DefScreenSaverProc(hWnd, message, wParam, lParam);
- }
- // The system will call the following function when the user is
- // in the control panel setting up the screensaver and they
- // press the setting button...
- BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- // Dialog message handling
- switch(message)
- {
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case IDOK:
- EndDialog(hDlg, LOWORD(wParam) == IDOK);
- return true;
- case IDCANCEL:
- EndDialog(hDlg, LOWORD(wParam) == IDOK);
- return true;
- }
- }
- return false;
- }
- // The following function registers any nonstandard window
- // classes required by the screen saver if the screen saver
- // does not require this functionality simply return true
- BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
- {
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement