from ThomasLa <sikker2004(a)yahoo.com>om>:
Corrected DE.rc language controls
Modifed EN.rc
implemented part of screensaver functions
Shows Screensavers
Get Some Values from registry
get default screensaver
implemented delete screensavers
Modified: trunk/reactos/lib/cpl/desk/de.rc
Modified: trunk/reactos/lib/cpl/desk/en.rc
Modified: trunk/reactos/lib/cpl/desk/resource.h
Modified: trunk/reactos/lib/cpl/desk/screensaver.c
_____
Modified: trunk/reactos/lib/cpl/desk/de.rc
--- trunk/reactos/lib/cpl/desk/de.rc 2005-04-14 15:47:03 UTC (rev
14618)
+++ trunk/reactos/lib/cpl/desk/de.rc 2005-04-14 20:23:02 UTC (rev
14619)
@@ -9,13 +9,13 @@
150,105,WS_EX_STATICEDGE
CONTROL "",IDC_BACKGROUND_LIST,"SysListView32",LVS_REPORT
|
LVS_SINGLESEL | LVS_NOCOLUMNHEADER |
LVS_SHAREIMAGELISTS |
- WS_BORDER | WS_TABSTOP,7,139,170,71
+ WS_BORDER | WS_TABSTOP,7,139,173,71
LTEXT "Hintergrundbild:",
IDC_STATIC,8,127,180,8
- PUSHBUTTON "&Durchsuchen...",IDC_BROWSE_BUTTON,181,175,60,14
- PUSHBUTTON "&Farbe...",IDC_COLOR_BUTTON,181,195,60,14
- LTEXT "Ausrichtung:",IDC_STATIC,181,138,45,8
- COMBOBOX IDC_PLACEMENT_COMBO,181,148,60,90,CBS_DROPDOWNLIST
|
+ PUSHBUTTON "&Durchsuchen...",IDC_BROWSE_BUTTON,186,175,56,14
+ PUSHBUTTON "&Farbe...",IDC_COLOR_BUTTON,186,195,56,14
+ LTEXT "Ausrichtung:",IDC_STATIC,186,138,43,8
+ COMBOBOX IDC_PLACEMENT_COMBO,186,148,50,90,CBS_DROPDOWNLIST
|
CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
_____
Modified: trunk/reactos/lib/cpl/desk/en.rc
--- trunk/reactos/lib/cpl/desk/en.rc 2005-04-14 15:47:03 UTC (rev
14618)
+++ trunk/reactos/lib/cpl/desk/en.rc 2005-04-14 20:23:02 UTC (rev
14619)
@@ -24,8 +24,32 @@
CAPTION "Screen Saver"
FONT 8, "MS Shell Dlg"
BEGIN
- LTEXT "This space is intentionally left
blank",IDC_STATIC,66,
- 110,112,8
+ GROUPBOX "&Screen Saver",IDC_SCREENS_DUMMY, 5, 7, 238, 176
+
+ LTEXT "List of Screensavers:",IDC_STATIC,13, 24, 71, 9
+ CONTROL "",IDC_SCREENS_CHOICES,"SysListView32",LVS_REPORT
|
+ LVS_SINGLESEL | LVS_NOCOLUMNHEADER |
LVS_SHAREIMAGELISTS |
+ WS_BORDER | WS_TABSTOP,13, 34, 171, 109
+ PUSHBUTTON "&Delete",IDC_SCREENS_DELETE, 189,47,39,10
+ PUSHBUTTON "&Add",IDC_SCREENS_POWER_BUTTON, 190,34,39,10
+
+ PUSHBUTTON "Se&ttings...",IDC_SCREENS_SETTINGS,140, 164, 48,
12,WS_GROUP
+ PUSHBUTTON "Pre&view",IDC_SCREENS_TESTSC,192, 164, 43, 12
+
+ CONTROL "On Resume, &Password
Protect.",IDC_SCREENS_USEPASSCHK,"button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,13, 161, 119, 18
+
+ LTEXT "&Wait:",IDC_STATIC,13, 150, 17, 9
+ EDITTEXT IDC_SCREENS_TIMEDELAY,33, 149, 31, 12,ES_RIGHT |
WS_GROUP
+ CONTROL "",IDC_SCREENS_TIME ,UPDOWN_CLASS,UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS |
+ WS_BORDER | WS_GROUP,52, 149, 12, 12
+ LTEXT "Minutes before showing
Screensaver.",IDC_STATIC,70, 151, 147, 9
+
+ GROUPBOX "&Energy Saving features of
monitor",IDC_SCREENS_DUMMY,5, 186, 238, 35
+ LTEXT "To adjust the power settings for your monitor,
click on Power Settings.",
+ IDC_STATIC,16, 199, 155, 19
+ PUSHBUTTON "P&ower Settings",IDC_SCREENS_POWER_BUTTON,180,
202, 57, 12
END
IDD_APPEARANCE DIALOGEX DISCARDABLE 0, 0, 246, 228
_____
Modified: trunk/reactos/lib/cpl/desk/resource.h
--- trunk/reactos/lib/cpl/desk/resource.h 2005-04-14 15:47:03 UTC
(rev 14618)
+++ trunk/reactos/lib/cpl/desk/resource.h 2005-04-14 20:23:02 UTC
(rev 14619)
@@ -28,6 +28,18 @@
#define IDC_COLOR_BUTTON 1003
#define IDC_PLACEMENT_COMBO 1004
+/* Screensaver Page */
+#define IDC_SCREENS_CHOICES 1010
+#define IDC_SCREENS_PREVIEW 1011
+#define IDC_SCREENS_POWER_BUTTON 1012
+#define IDC_SCREENS_SETTINGS 1013
+#define IDC_SCREENS_TESTSC 1014
+#define IDC_SCREENS_USEPASSCHK 1015
+#define IDC_SCREENS_TIMEDELAY 1016
+#define IDC_SCREENS_TIME 1017
+#define IDC_SCREENS_DELETE 1018
+#define IDC_SCREENS_DUMMY 5000
+
#define IDS_CPLNAME 2000
#define IDS_CPLDESCRIPTION 2001
_____
Modified: trunk/reactos/lib/cpl/desk/screensaver.c
--- trunk/reactos/lib/cpl/desk/screensaver.c 2005-04-14 15:47:03 UTC
(rev 14618)
+++ trunk/reactos/lib/cpl/desk/screensaver.c 2005-04-14 20:23:02 UTC
(rev 14619)
@@ -12,23 +12,301 @@
#include <commctrl.h>
#include "resource.h"
+#include <cpl.h>
+#include <tchar.h>
+#include "desk.h"
-INT_PTR CALLBACK ScreenSaverPageProc(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
+#define MAX_SCREENSAVERS 100
+
+void AddListViewItems2();
+void CheckRegScreenSaverIsSecure();
+
+typedef struct {
+ BOOL bIsScreenSaver; /* Is this background a wallpaper */
+ TCHAR szFilename[MAX_PATH];
+ TCHAR szDisplayName[256];
+} ScreenSaverItem;
+
+int ImageListSelection = 0;
+ScreenSaverItem g_ScreenSaverItems[MAX_SCREENSAVERS];
+
+HWND g_hScreenBackgroundPage = NULL;
+HWND g_hScreengroundList = NULL;
+HWND ControlScreenSaverIsSecure = NULL;
+
+void ListViewItemAreChanged(int itemIndex)
{
- switch(uMsg)
- {
+ ScreenSaverItem *ScreenSaverItem = NULL;
+
+ ImageListSelection = itemIndex;
+ ScreenSaverItem = &g_ScreenSaverItems[ImageListSelection];
+
+ PropSheet_Changed(GetParent(g_hScreenBackgroundPage),
g_hScreenBackgroundPage);
+}
+
+INT_PTR
+CALLBACK
+ScreenSaverPageProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ g_hScreenBackgroundPage = hwndDlg;
+
+ switch(uMsg) {
case WM_INITDIALOG:
- {
- } break;
-
+ {
+ g_hScreengroundList = GetDlgItem(g_hScreenBackgroundPage,
IDC_SCREENS_CHOICES);
+ AddListViewItems2();
+ CheckRegScreenSaverIsSecure();
+ } break;
case WM_COMMAND:
- {
+ {
+ DWORD controlId = LOWORD(wParam);
+ DWORD command = HIWORD(wParam);
+
+ switch(controlId) {
+ case IDC_SCREENS_POWER_BUTTON: // Start Powercfg.Cpl
+ {
+ if(command == BN_CLICKED)
+ WinExec("rundll32 shell32.dll,Control_RunDLL
powercfg.cpl,,",SW_SHOWNORMAL);
+ } break;
+ case IDC_SCREENS_TESTSC: // Screensaver Preview
+ {
+ if(command == BN_CLICKED)
+ MessageBox(NULL, TEXT("That button doesn't do
anything yet"), TEXT("Whoops"), MB_OK);
+
+ } break;
+ case IDC_SCREENS_DELETE: // Delete Screensaver
+ {
+ if(command == BN_CLICKED) {
+ if (ImageListSelection == 0) // Can NOT delete
None sry:-)
+ return FALSE;
+
DeleteFileW(g_ScreenSaverItems[ImageListSelection].szFilename);
+ }
+ } break;
+ case IDC_SCREENS_SETTINGS: // Screensaver Settings
+ {
+ if(command == BN_CLICKED)
+ MessageBox(NULL, TEXT("That button doesn't do
anything yet"), TEXT("Whoops"), MB_OK);
+ } break;
+ case IDC_SCREENS_USEPASSCHK: // Screensaver Is Secure
+ {
+ if(command == BN_CLICKED)
+ MessageBox(NULL, TEXT("That button doesn't do
anything yet"), TEXT("Whoops"), MB_OK);
+ } break;
+ case IDC_SCREENS_TIME: // Delay before show screensaver
+ {
+ } break;
+ default:
+ break;
} break;
+ }
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnm = (LPNMHDR)lParam;
+
+ switch(lpnm->code) {
+ case PSN_APPLY:
+ {
+ return TRUE;
+ } break;
+ case LVN_ITEMCHANGED:
+ {
+ LPNMLISTVIEW nm = (LPNMLISTVIEW)lParam;
+ if((nm->uNewState & LVIS_SELECTED) == 0)
+ return FALSE;
+ ListViewItemAreChanged(nm->iItem);
+ break;
+ } break;
+ default:
+ break;
+ }
+ } break;
}
return FALSE;
}
+void CheckRegScreenSaverIsSecure()
+{
+ HKEY hKey;
+ TCHAR szBuffer[2];
+ DWORD bufferSize = sizeof(szBuffer);
+ DWORD varType = REG_SZ;
+ LONG result;
+
+ ControlScreenSaverIsSecure = GetDlgItem(g_hScreenBackgroundPage,
IDC_SCREENS_USEPASSCHK);
+
+ RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0,
KEY_ALL_ACCESS, &hKey);
+ result = RegQueryValueEx(hKey, TEXT("ScreenSaverIsSecure"), 0,
&varType, (LPBYTE)szBuffer, &bufferSize);
+ if(result == ERROR_SUCCESS)
+ if(_ttoi(szBuffer) == 1) {
+ SendMessage(ControlScreenSaverIsSecure, BM_SETCHECK,
(WPARAM)BST_CHECKED, 0);
+ goto End;
+ }
+ SendMessage(ControlScreenSaverIsSecure, BM_SETCHECK,
(WPARAM)BST_UNCHECKED, 0);
+End:
+ RegCloseKey(hKey);
+}
+
+/* Add the bitmaps in the C:\ReactOS directory and the current
wallpaper if any */
+void AddListViewItems2()
+{
+ WIN32_FIND_DATA fd;
+ HANDLE hFind;
+ TCHAR szSearchPath[MAX_PATH];
+ LV_ITEM listItem;
+ LV_COLUMN dummy;
+ RECT clientRect;
+ HKEY regKey;
+ SHFILEINFO sfi;
+ HIMAGELIST himl;
+ HIMAGELIST g_hScreenShellImageList = NULL;
+ TCHAR wallpaperFilename[MAX_PATH];
+ DWORD bufferSize = sizeof(wallpaperFilename);
+ DWORD varType = REG_SZ;
+ LONG result;
+ UINT i = 0;
+ int g_ScreenlistViewItemCount = 0;
+ ScreenSaverItem *ScreenSaverItem = NULL;
+
+ GetClientRect(g_hScreengroundList, &clientRect);
+
+ ZeroMemory(&dummy, sizeof(LV_COLUMN));
+ dummy.mask = LVCF_SUBITEM | LVCF_WIDTH;
+ dummy.iSubItem = 0;
+ dummy.cx = (clientRect.right - clientRect.left) -
GetSystemMetrics(SM_CXVSCROLL);
+
+ ListView_InsertColumn(g_hScreengroundList, 0, &dummy);
+
+ /* Add the "None" item */
+ ScreenSaverItem = &g_ScreenSaverItems[g_ScreenlistViewItemCount];
+
+ ScreenSaverItem->bIsScreenSaver = FALSE;
+
+ LoadString(hApplet,
+ IDS_NONE,
+ ScreenSaverItem->szDisplayName,
+ sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR));
+
+ ZeroMemory(&listItem, sizeof(LV_ITEM));
+ listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE |
LVIF_IMAGE;
+ listItem.state = LVIS_SELECTED;
+ listItem.pszText = ScreenSaverItem->szDisplayName;
+ listItem.iImage = -1;
+ listItem.iItem = g_ScreenlistViewItemCount;
+ listItem.lParam = g_ScreenlistViewItemCount;
+
+ ListView_InsertItem(g_hScreengroundList, &listItem);
+ ListView_SetItemState(g_hScreengroundList,
g_ScreenlistViewItemCount, LVIS_SELECTED, LVIS_SELECTED);
+
+ g_ScreenlistViewItemCount++;
+
+ /* Add current screensaver if any */
+ RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0,
KEY_ALL_ACCESS, ®Key);
+
+ result = RegQueryValueEx(regKey, TEXT("SCRNSAVE.EXE"), 0, &varType,
(LPBYTE)wallpaperFilename, &bufferSize);
+
+ if((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
+ {
+ himl = (HIMAGELIST)SHGetFileInfo(wallpaperFilename,
+ 0,
+ &sfi,
+ sizeof(sfi),
+ SHGFI_SYSICONINDEX |
SHGFI_SMALLICON |
+ SHGFI_DISPLAYNAME);
+
+ if(himl != NULL)
+ {
+ if(i++ == 0)
+ {
+ g_hScreenShellImageList = himl;
+ ListView_SetImageList(g_hScreengroundList, himl,
LVSIL_SMALL);
+ }
+
+ ScreenSaverItem =
&g_ScreenSaverItems[g_ScreenlistViewItemCount];
+
+ ScreenSaverItem->bIsScreenSaver = TRUE;
+
+ _tcscpy(ScreenSaverItem->szDisplayName, sfi.szDisplayName);
+ _tcscpy(ScreenSaverItem->szFilename, wallpaperFilename);
+
+ ZeroMemory(&listItem, sizeof(LV_ITEM));
+ listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE |
LVIF_IMAGE;
+ listItem.state = LVIS_SELECTED;
+ listItem.pszText = ScreenSaverItem->szDisplayName;
+ listItem.iImage = sfi.iIcon;
+ listItem.iItem = g_ScreenlistViewItemCount;
+ listItem.lParam = g_ScreenlistViewItemCount;
+
+ ListView_InsertItem(g_hScreengroundList, &listItem);
+ ListView_SetItemState(g_hScreengroundList,
g_ScreenlistViewItemCount, LVIS_SELECTED, LVIS_SELECTED);
+
+ g_ScreenlistViewItemCount++;
+ }
+ }
+
+ RegCloseKey(regKey);
+
+ /* Add all the screensavers in the C:\ReactOS\System32 directory.
*/
+
+ GetSystemDirectory(szSearchPath, MAX_PATH);
+ _tcscat(szSearchPath, TEXT("\\*.scr"));
+
+ hFind = FindFirstFile(szSearchPath, &fd);
+ while(hFind != INVALID_HANDLE_VALUE)
+ {
+ /* Don't add any hidden screensavers */
+ if((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)
+ {
+ TCHAR filename[MAX_PATH];
+
+ GetSystemDirectory(filename, MAX_PATH);
+
+ _tcscat(filename, TEXT("\\"));
+ _tcscat(filename, fd.cFileName);
+
+ himl = (HIMAGELIST)SHGetFileInfo(filename,
+ 0,
+ &sfi,
+ sizeof(sfi),
+ SHGFI_SYSICONINDEX |
SHGFI_SMALLICON |
+ SHGFI_DISPLAYNAME);
+
+ if(himl == NULL)
+ {
+ break;
+ }
+
+ if(i++ == 0)
+ {
+ g_hScreenShellImageList = himl;
+ ListView_SetImageList(g_hScreengroundList, himl,
LVSIL_SMALL);
+ }
+
+ ScreenSaverItem =
&g_ScreenSaverItems[g_ScreenlistViewItemCount];
+
+ ScreenSaverItem->bIsScreenSaver = TRUE;
+
+ _tcscpy(ScreenSaverItem->szDisplayName, sfi.szDisplayName);
+ _tcscpy(ScreenSaverItem->szFilename, filename);
+
+ ZeroMemory(&listItem, sizeof(LV_ITEM));
+ listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE |
LVIF_IMAGE;
+ listItem.pszText = ScreenSaverItem->szDisplayName;
+ listItem.state = 0;
+ listItem.iImage = sfi.iIcon;
+ listItem.iItem = g_ScreenlistViewItemCount;
+ listItem.lParam = g_ScreenlistViewItemCount;
+
+ ListView_InsertItem(g_hScreengroundList, &listItem);
+
+ g_ScreenlistViewItemCount++;
+ }
+
+ if(!FindNextFile(hFind, &fd))
+ hFind = INVALID_HANDLE_VALUE;
+ }
+}
+