- Modified to use the screensaver library
authorMarc Piulachs <marc.piulachs@live.com>
Thu, 21 Feb 2008 17:07:01 +0000 (17:07 +0000)
committerMarc Piulachs <marc.piulachs@live.com>
Thu, 21 Feb 2008 17:07:01 +0000 (17:07 +0000)
- Reduce the amount of code to minimum
- Remove unneeded resources

svn path=/trunk/; revision=32442

18 files changed:
reactos/base/applications/screensavers/logon/lang/bg-BG.rc
reactos/base/applications/screensavers/logon/lang/de-DE.rc
reactos/base/applications/screensavers/logon/lang/el-GR.rc
reactos/base/applications/screensavers/logon/lang/en-US.rc
reactos/base/applications/screensavers/logon/lang/es-ES.rc
reactos/base/applications/screensavers/logon/lang/fr-FR.rc
reactos/base/applications/screensavers/logon/lang/it-IT.rc
reactos/base/applications/screensavers/logon/lang/lt-LT.rc
reactos/base/applications/screensavers/logon/lang/nl-NL.rc
reactos/base/applications/screensavers/logon/lang/pl-PL.rc
reactos/base/applications/screensavers/logon/lang/ru-RU.rc
reactos/base/applications/screensavers/logon/lang/sk-SK.rc
reactos/base/applications/screensavers/logon/lang/uk-UA.rc
reactos/base/applications/screensavers/logon/logon.c
reactos/base/applications/screensavers/logon/logon.def [new file with mode: 0644]
reactos/base/applications/screensavers/logon/logon.rbuild
reactos/base/applications/screensavers/logon/logon.rc
reactos/base/applications/screensavers/logon/resource.h

index f024ead..76e8196 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Âõîäåí åêðàíåí ïðåäïàçèòåë"
-    IDS_TITLE       "Çà"
     IDS_TEXT        "Íÿìà âúçìîæíîñò çà íàñòðîéêè."
 END
index 74f56ba..6a13ddf 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
     IDS_DESCRIPTION "Logon Bildschirmschoner"\r
-    IDS_TITLE       "Über"\r
     IDS_TEXT        "Keinerlei Einstellungen notwendig."\r
 END\r
index 59ab696..19a55a2 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_GREEK, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Ðñïöýëáîç ïèüíçò Logon"
-    IDS_TITLE       "Ðåñß"
     IDS_TEXT        "ÁõôÞ ç ðñïöýëáîç ïèüíçò äå äéáèÝôåé åðéëïãÝò ôéò ïðïßåò ìðïñåßôå íá ïñßóåôå."
 END
index d1f616a..caf8440 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Logon ScreenSaver"
-    IDS_TITLE       "About"
     IDS_TEXT        "No options need to be set."
 END
index 3824f26..87081ce 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Logotipo ReactOS"
-    IDS_TITLE       "Acerca de"
     IDS_TEXT        "Ninguna opción necesita ser configurada."
 END
index 8969c5d..dd68ecc 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
     IDS_DESCRIPTION "Écran de veille de logon"\r
-    IDS_TITLE       "À propos de"\r
     IDS_TEXT        "Il n'y a aucune option à définir."\r
 END\r
index 1fd0c1e..e2294f2 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Salvaschermo Logon"
-    IDS_TITLE       "Informazioni su ..."
     IDS_TEXT        "Nessuna impostazione necessaria."
 END
index f9f381a..6b6e411 100644 (file)
@@ -12,6 +12,5 @@ LANGUAGE LANG_LITHUANIAN, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
     IDS_DESCRIPTION "Logon"\r
-    IDS_TITLE       "Apie"\r
     IDS_TEXT        "Nëra keièiamø parametrø."\r
 END\r
index e8e276f..99660ef 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
     IDS_DESCRIPTION "Logon Schermbeveiliging"\r
-    IDS_TITLE       "Informatie"\r
     IDS_TEXT        "Geen dingen om in te stellen."\r
 END\r
index 2e719b4..98c25a8 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Wygaszacz ekranu Logon"
-    IDS_TITLE       "O programie..."
     IDS_TEXT        "Brak opcji."
 END
index 6b03d69..e21c792 100644 (file)
@@ -3,6 +3,5 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_DESCRIPTION "Çàñòàâêà ""Âõîä â ñèñòåìó"""
-    IDS_TITLE       "Πïðîãðàììå"
     IDS_TEXT        "Ýòà çàñòàâêà íå èìååò íàñòðàèâàåìûõ ïàðàìåòðîâ."
 END
index 6587293..5db5e4a 100644 (file)
@@ -7,6 +7,5 @@ LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
     IDS_DESCRIPTION "Logon - \9aetriè obrazovky"\r
-    IDS_TITLE       "Èo je ..."\r
     IDS_TEXT        "Nie sú potrebné \9eiadne nastavenia."\r
 END\r
index 628f87a..7e928ea 100644 (file)
@@ -11,6 +11,5 @@ LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
     IDS_DESCRIPTION "Çàñòàâêà ""Âõ³ä äî ñèñòåìè"""\r
-    IDS_TITLE       "Ïðî"\r
     IDS_TEXT        "Öÿ çàñòàâêà íå ìຠíàëàøòîâóâàíèõ ïàðàìåòð³â."\r
 END\r
index 6201c29..5a8b9f3 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <windows.h>
+#include <scrnsave.h>
 #include <tchar.h>
 #include "resource.h"
 
 #define APP_TIMER                      1
 #define APP_TIMER_INTERVAL     2000
 
-#define BITMAP_HEIGHT   240;
+#define BITMAP_HEIGHT   240
 #define BITMAP_WIDTH    340
 
-HINSTANCE hInstance;
-
-BOOL fullscreen = FALSE;
-
-void DrawScreen (HDC hdc, HDC hMemDC , RECT rect)
-{
-       int x;
-       int y;
-       int width = BITMAP_WIDTH;
-       int height = BITMAP_HEIGHT;
-
-       if (!fullscreen)
-       {
-               width =  width / 20;
-               height = height / 20;
-       }
-
-       x = RANDOM (0, rect.right - width);
-       y = RANDOM (0, rect.bottom - height);
-
-       BitBlt(
-               hdc,
-               x,
-               y,
-               width,
-               height,
-               hMemDC,
-               0,
-               0,
-               SRCCOPY);
-}
-
 HBITMAP GetScreenSaverBitmap (void)
 {
        OSVERSIONINFOEX osvi;
@@ -74,49 +43,39 @@ HBITMAP GetScreenSaverBitmap (void)
        switch(osvi.wProductType)
        {
                case VER_NT_WORKSTATION:
-                       return LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_WORKSTATION));
+                       return LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_WORKSTATION), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
                        break;
                default:
-                       return LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_SERVER));
+                       return LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_SERVER), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
                        break;
        }
 }
 
-LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK
+ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
-       static POINT ptLast;
-       static POINT ptCursor;
-       static BOOL  fFirstTime = TRUE;
-
-       static PAINTSTRUCT ps;
        static RECT rect;
-       static HDC hDC;
-       static HDC hMemDC;
-       static HBRUSH hBlkBrush;
        static HBITMAP bitmap;
 
-       switch (msg)
+       switch (message)
        {
                case WM_CREATE:
                {
-                       hDC = GetDC(hwnd);
-                       hBlkBrush = (HBRUSH) GetStockObject(BLACK_BRUSH);
-                       hMemDC = CreateCompatibleDC(hDC);
-                       GetClientRect(hwnd, &rect);
+                       GetClientRect(hWnd, &rect);
 
                        bitmap = GetScreenSaverBitmap ();
 
                        if(bitmap == NULL)
                        {
                                MessageBox(
-                                  hwnd,
+                                  hWnd,
                                   _T("Fatal Error: Could not load bitmap"),
                                   _T("Error"),
                                   MB_OK | MB_ICONEXCLAMATION);
                        }
 
                        SetTimer (
-                               hwnd,
+                               hWnd,
                                APP_TIMER,
                                APP_TIMER_INTERVAL,
                                NULL);
@@ -124,209 +83,73 @@ LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                         break;
                 }
                case WM_PAINT:
-                       {
-                               hDC = BeginPaint(hwnd, &ps);
-                               SelectObject(hMemDC, bitmap);
-                               DrawScreen (hDC , hMemDC , rect);
-                               EndPaint(hwnd, &ps);
-                               break;
-                       }
-               case WM_TIMER :
                {
-                       if (wParam == APP_TIMER)
-                       {
-                               InvalidateRect(hwnd, NULL, 1);
-                       }
+             BITMAP bm; /* Bitmap structure as seen in bmWidth & bmHeight */ 
+             PAINTSTRUCT ps; 
+
+             HDC hdc = BeginPaint(hWnd, &ps); 
+             HDC hdcMem = CreateCompatibleDC(hdc); 
+             HBITMAP hbmOld = SelectObject(hdcMem, bitmap); 
+
+             GetObject(bitmap, sizeof(bm), &bm); 
+
+             bm.bmWidth = 1000; 
+             bm.bmHeight = 700; 
+
+             BitBlt(
+                 hdc, 
+                 RANDOM (0, rect.right - BITMAP_WIDTH),
+                 RANDOM (0, rect.bottom - BITMAP_HEIGHT),
+                 bm.bmWidth, 
+                 bm.bmHeight, 
+                 hdcMem, 
+                 5, 
+                 5, 
+                 SRCCOPY); 
+
+             SelectObject(hdcMem, hbmOld); 
+             DeleteDC(hdcMem); 
+
+             EndPaint(hWnd, &ps);
+             break;
                }
-                 case WM_ERASEBKGND:
-                       {
-                               SelectObject(hDC, hBlkBrush);
-
-                               PatBlt(
-                                       hDC,
-                                       0,
-                                       0,
-                                       rect.right,
-                                       rect.bottom,
-                                       PATCOPY);
-                               break;
-                       }
-                       case WM_DESTROY:
-                       {
-                               KillTimer (hwnd, APP_TIMER);
-                               DeleteObject(bitmap);
-                               ShowCursor(TRUE);
-                               PostQuitMessage(0);
-                               break;
-                       }
-
-                       // break out of screen-saver if any keyboard activity
-                       case WM_NOTIFY:
-                       case WM_SYSKEYDOWN:
-                               PostMessage(hwnd, WM_CLOSE, 0, 0);
-                               break;
-
-                       // break out of screen-saver if any mouse activity
-                       case WM_LBUTTONDOWN:
-                       case WM_LBUTTONUP:
-                       case WM_RBUTTONDOWN:
-                       case WM_RBUTTONUP:
-                       case WM_MBUTTONDOWN:
-                       case WM_MBUTTONUP:
-                       case WM_MOUSEMOVE:
-                               // If we've got a parent then we must be a preview
-                               if(GetParent(hwnd) != 0)
-                                       return 0;
-
-                               if(fFirstTime)
-                               {
-                                       GetCursorPos(&ptLast);
-                                       fFirstTime = FALSE;
-                               }
-
-                       GetCursorPos(&ptCursor);
-
-                       // if the mouse has moved more than 3 pixels then exit
-                       if(abs(ptCursor.x - ptLast.x) >= 3 || abs(ptCursor.y - ptLast.y) >= 3)
-                               PostMessage(hwnd, WM_CLOSE, 0, 0);
-
-                       ptLast = ptCursor;
-
-                       return 0;
+        case WM_TIMER:
+        {
+          InvalidateRect(hWnd, NULL, 1);
+          break;
+        }
+               case WM_DESTROY:
+               {
+                       KillTimer (hWnd, APP_TIMER);
+                       DeleteObject(bitmap);
+                       PostQuitMessage(0);
+                       break;
                }
 
-       return DefWindowProc(hwnd, msg, wParam, lParam);
-}
-
-void InitSaver(HWND hwndParent)
-{
-       WNDCLASS wc;
-       ZeroMemory(&wc, sizeof(wc));
-       wc.style            = CS_HREDRAW | CS_VREDRAW;
-       wc.lpfnWndProc      = WndProc;
-       wc.lpszClassName    = APPNAME;
-       wc.hbrBackground    = (HBRUSH)GetStockObject(BLACK_BRUSH);
-       RegisterClass(&wc);
+        default:
+            // Pass Windows Messages to the default screensaver window procedure
+            return DefScreenSaverProc(hWnd, message, wParam, lParam);
+    }
 
-       if (hwndParent != 0)
-       {
-               RECT rect;
-               GetClientRect(hwndParent, &rect);
-               CreateWindow(APPNAME, APPNAME,
-                            WS_VISIBLE | WS_CHILD,
-                            0, 0,
-                            rect.right,
-                            rect.bottom,
-                            hwndParent, 0,
-                            hInstance, NULL);
-               fullscreen = FALSE;
-       }
-       else
-       {
-               HWND hwnd;
-               hwnd = CreateWindowEx(WS_EX_TOPMOST,
-                          APPNAME,
-                          APPNAME,
-                          WS_VISIBLE | WS_POPUP,
-                          0, 0,
-                          GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
-                          HWND_DESKTOP, 0,
-                          hInstance, NULL);
-
-    SetWindowPos(hwnd,
-                 0, 0, 0, 0, 0,
-                 SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_SHOWWINDOW);
-
-    ShowCursor(FALSE);
-               fullscreen = TRUE;
-       }
+       return 0;
 }
 
-VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
+BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-       UCHAR ch = *szCmdLine++;
-
-       if(ch == '-' || ch == '/')
-               ch = *szCmdLine++;
-
-       if(ch >= 'A' && ch <= 'Z')
-               ch += 'a' - 'A';                //convert to lower case
-
-       *chOption = ch;
-       ch = *szCmdLine++;
-
-       if(ch == ':')
-               ch = *szCmdLine++;
-
-       while(ch == ' ' || ch == '\t')
-               ch = *szCmdLine++;
-
-       if(isdigit(ch))
-       {
-               unsigned int i = _wtoi(szCmdLine - 1);
-               *hwndParent = (HWND)i;
-       }
-       else
-               *hwndParent = NULL;
+    return FALSE;
 }
 
-void Configure(void)
+// This function is only called one time before opening the configuration dialog.
+// Use it to show a message that no configuration is necesssary and return FALSE to indicate that no configuration dialog shall be opened.
+BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
 {
-       TCHAR szTitle[256];
-       TCHAR szText[256];
-
-       LoadString(hInstance,
-                  IDS_TITLE,
-                  szTitle,
-                  256);
-
-       LoadString(hInstance,
-                  IDS_TEXT,
-                  szText,
-                  256);
-
-       MessageBox(0,
-                  szText,
-                  szTitle,
-                  MB_OK | MB_ICONWARNING);
-}
-
-int CALLBACK wWinMain (HINSTANCE hInst,
-                    HINSTANCE hPrev,
-                    LPWSTR lpCmdLine,
-                    int iCmdShow)
-{
-       HWND    hwndParent;
-       UINT    nPreviousState;
-       UCHAR   chOption;
-       MSG     Message;
-
-       hInstance = hInst;
-
-       ParseCommandLine(lpCmdLine, &chOption, &hwndParent);
-
-       SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
-
-       switch (chOption)
-       {
-               case 's':
-                       InitSaver(0);
-                       break;
-
-               case 'p':
-                       InitSaver(hwndParent);
-                       break;
-
-               case 'c':
-               default:
-                       Configure();
-                       return 0;
-       }
+    TCHAR szMessage[256];
+    TCHAR szTitle[25];
 
-       while (GetMessage(&Message, 0, 0, 0))
-               DispatchMessage(&Message);
+    LoadString(hInst, IDS_TEXT, szMessage, sizeof(szMessage) / sizeof(TCHAR));
+    LoadString(hInst, IDS_DESCRIPTION, szTitle, sizeof(szTitle) / sizeof(TCHAR));
 
-       SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
+    MessageBox(NULL, szMessage, szTitle, MB_OK | MB_ICONEXCLAMATION);
 
-       return Message.wParam;
+    return FALSE;
 }
diff --git a/reactos/base/applications/screensavers/logon/logon.def b/reactos/base/applications/screensavers/logon/logon.def
new file mode 100644 (file)
index 0000000..9352bd0
--- /dev/null
@@ -0,0 +1,5 @@
+NAME   logon.scr
+
+EXPORTS
+       ScreenSaverProc
+       ScreenSaverConfigureDialog
index 8ec139e..26ddb98 100644 (file)
@@ -1,7 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
 <module name="logon" type="win32scr" installbase="system32" installname="logon.scr" unicode="true">
+       <importlibrary definition="logon.def" />
        <include base="logon">.</include>
+       <library>scrnsave</library>
        <library>kernel32</library>
        <library>user32</library>
        <library>gdi32</library>
index 43a4329..802cb0c 100644 (file)
@@ -1,4 +1,5 @@
 #include <windows.h>
+#include <scrnsave.h>
 #include "resource.h"
 
 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
index ddb0f46..5491b27 100644 (file)
@@ -1,6 +1,3 @@
-\r
-#define IDS_DESCRIPTION 1\r
-#define IDS_TITLE       2\r
 #define IDS_TEXT        3\r
 #define IDB_WORKSTATION 0x100\r
 #define IDB_SERVER      0x200\r