Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. #include <windows.h>
  2. #include <scrnsave.h>
  3. #include <commctrl.h>
  4. #include "resource.h"
  5.  
  6. // Include these libraries
  7.  
  8. #pragma comment(lib, "ScrnSave.lib")
  9. #pragma comment(lib, "comctl32.lib")
  10.  
  11. // Screen saver library contains the main function and other
  12. // Startup code required for a scrnsaver user defined vars
  13.  
  14. #define TIMER 1
  15.  
  16. // Global variables
  17.  
  18. int Width, Height; // Size of screen variables
  19.  
  20. // Screensaver procedure...first when window is created:
  21. // 1) get users window resolution
  22. // 2) call a function that sets up OpenGL
  23. // 3) Setup a TIMER that will be used to drive animations
  24.  
  25. LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  26. {
  27. static HDC hDC; // Handle to device context
  28. static HGLRC hRC; // Handle to OpenGL rendering context
  29. static RECT rect; // Instance of structure RECT which defines the
  30. // coords of the upper-left and lower-right
  31. // corners of a rectangle
  32.  
  33. switch(message)
  34. {
  35. // Set timer and any other initializations
  36. case WM_CREATE:
  37. GetClientRect(hWnd, &rect); // Get window dimensions
  38. Width = rect.right; // Store width
  39. Height = rect.bottom; // Store height
  40. SetTimer(hWnd, TIMER, 10, NULL);
  41. return 0;
  42.  
  43. case WM_DESTROY: // Destroy timer and perform cleanup
  44. KillTimer(hWnd, TIMER); // Destroy timer
  45. return 0;
  46.  
  47. case WM_TIMER: // Perform drawing operations
  48. return 0;
  49. }
  50.  
  51. // Unprocessed messages are handled by the screen saver
  52. // library by calling the following:
  53. return DefScreenSaverProc(hWnd, message, wParam, lParam);
  54. }
  55.  
  56.  
  57. // The system will call the following function when the user is
  58. // in the control panel setting up the screensaver and they
  59. // press the setting button...
  60.  
  61. BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  62. {
  63. // Dialog message handling
  64. switch(message)
  65. {
  66. case WM_COMMAND:
  67. switch(LOWORD(wParam))
  68. {
  69. case IDOK:
  70. EndDialog(hDlg, LOWORD(wParam) == IDOK);
  71. return true;
  72.  
  73. case IDCANCEL:
  74. EndDialog(hDlg, LOWORD(wParam) == IDOK);
  75. return true;
  76. }
  77. }
  78. return false;
  79. }
  80.  
  81.  
  82. // The following function registers any nonstandard window
  83. // classes required by the screen saver if the screen saver
  84. // does not require this functionality simply return true
  85.  
  86. BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
  87. {
  88. return true;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement