ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

logon.c
Go to the documentation of this file.
00001 /*
00002  *  Copyright 2003 J Brown
00003  *  Copyright 2006 Eric Kohl
00004  *  Copyright 2007 Marc Piulachs (marc.piulachs@codexchange.net)
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019  */
00020 
00021 #include <windows.h>
00022 #include <scrnsave.h>
00023 #include <tchar.h>
00024 #include "resource.h"
00025 
00026 #define RANDOM( min, max ) ((rand() % (int)(((max)+1) - (min))) + (min))
00027 
00028 #define APPNAME _T("Logon")
00029 #define APP_TIMER           1
00030 #define APP_TIMER_INTERVAL  2000
00031 
00032 HBITMAP GetScreenSaverBitmap (void)
00033 {
00034     OSVERSIONINFOEX osvi;
00035 
00036     ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
00037     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
00038     GetVersionEx ((OSVERSIONINFO *) &osvi);
00039 
00040     switch(osvi.wProductType)
00041     {
00042         case VER_NT_WORKSTATION:
00043             return LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_WORKSTATION), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
00044             break;
00045         default:
00046             return LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_SERVER), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
00047             break;
00048     }
00049 }
00050 
00051 LRESULT CALLBACK
00052 ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00053 {
00054     static RECT rect;
00055     static HBITMAP bitmap;
00056 
00057     switch (message)
00058     {
00059         case WM_CREATE:
00060         {
00061             bitmap = GetScreenSaverBitmap ();
00062 
00063             if(bitmap == NULL)
00064             {
00065                 MessageBox(
00066                    hWnd,
00067                    _T("Fatal Error: Could not load bitmap"),
00068                    _T("Error"),
00069                    MB_OK | MB_ICONEXCLAMATION);
00070             }
00071 
00072             SetTimer (
00073                 hWnd,
00074                 APP_TIMER,
00075                 APP_TIMER_INTERVAL,
00076                 NULL);
00077 
00078              break;
00079          }
00080         case WM_PAINT:
00081         {
00082              BITMAP bm; /* Bitmap structure as seen in bmWidth & bmHeight */ 
00083              PAINTSTRUCT ps; 
00084              HDC hdc;
00085              HDC hdcMem;
00086              HBITMAP hbmOld;
00087 
00088              // Obtain window coordinates.
00089              GetClientRect (hWnd, &rect);
00090 
00091              hdc = BeginPaint(hWnd, &ps); 
00092              hdcMem = CreateCompatibleDC(hdc); 
00093              hbmOld = SelectObject(hdcMem, bitmap); 
00094 
00095              GetObject(bitmap, sizeof(bm), &bm);
00096 
00097              if (rect.right < bm.bmWidth ||
00098                  rect.bottom < bm.bmHeight)
00099              {
00100                 StretchBlt(
00101                     hdc,
00102                     RANDOM (0, rect.right - (bm.bmWidth /5)),
00103                     RANDOM (0, rect.bottom - (bm.bmHeight /5)),
00104                     bm.bmWidth /5,
00105                     bm.bmHeight /5,
00106                     hdcMem,
00107                     0,
00108                     0,
00109                     bm.bmWidth,
00110                     bm.bmHeight,
00111                     SRCCOPY);
00112              }
00113              else
00114              {
00115                  BitBlt(
00116                      hdc, 
00117                      RANDOM (0, rect.right - bm.bmWidth),
00118                      RANDOM (0, rect.bottom - bm.bmHeight),
00119                      bm.bmWidth, 
00120                      bm.bmHeight, 
00121                      hdcMem, 
00122                      0, 
00123                      0, 
00124                      SRCCOPY); 
00125              }
00126 
00127              SelectObject(hdcMem, hbmOld); 
00128              DeleteDC(hdcMem); 
00129 
00130              EndPaint(hWnd, &ps);
00131              break;
00132         }
00133         case WM_TIMER:
00134         {
00135           InvalidateRect(hWnd, NULL, 1);
00136           break;
00137         }
00138         case WM_DESTROY:
00139         {
00140             KillTimer (hWnd, APP_TIMER);
00141             DeleteObject(bitmap);
00142             PostQuitMessage(0);
00143             break;
00144         }
00145 
00146         default:
00147             // Pass Windows Messages to the default screensaver window procedure
00148             return DefScreenSaverProc(hWnd, message, wParam, lParam);
00149     }
00150 
00151     return 0;
00152 }
00153 
00154 BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
00155 {
00156     return FALSE;
00157 }
00158 
00159 // This function is only called one time before opening the configuration dialog.
00160 // Use it to show a message that no configuration is necesssary and return FALSE to indicate that no configuration dialog shall be opened.
00161 BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
00162 {
00163     TCHAR szMessage[256];
00164     TCHAR szTitle[25];
00165 
00166     LoadString(hInst, IDS_TEXT, szMessage, sizeof(szMessage) / sizeof(TCHAR));
00167     LoadString(hInst, IDS_DESCRIPTION, szTitle, sizeof(szTitle) / sizeof(TCHAR));
00168 
00169     MessageBox(NULL, szMessage, szTitle, MB_OK | MB_ICONEXCLAMATION);
00170 
00171     return FALSE;
00172 }

Generated on Sun May 27 2012 04:17:43 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.