Index: include/reactos/dll/desk/deskcplx.h =================================================================== --- include/reactos/dll/desk/deskcplx.h (revision 48415) +++ include/reactos/dll/desk/deskcplx.h (working copy) @@ -107,7 +107,7 @@ #ifdef UNICODE wcscpy(lpStr, lpRecvBuffer); #else - WideCharToMultiByte(CP_APC, 0, lpRecvBuffer, -1, lpStr, BufLen, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, lpRecvBuffer, -1, lpStr, BufLen, NULL, NULL); #endif } Index: dll/cpl/desk/lang/it-IT.rc =================================================================== --- dll/cpl/desk/lang/it-IT.rc (revision 48415) +++ dll/cpl/desk/lang/it-IT.rc (working copy) @@ -6,7 +6,7 @@ FONT 8, "MS Shell Dlg" BEGIN CONTROL "", IDC_BACKGROUND_PREVIEW, "Static", SS_OWNERDRAW, - 70, 10, 105, 70, WS_EX_STATICEDGE + 70, 10, 105, 80, 0 CONTROL "", IDC_BACKGROUND_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 8, 122, 174, 78 @@ -16,7 +16,7 @@ PUSHBUTTON "&Colore...", IDC_COLOR_BUTTON, 188, 185, 50, 15 LTEXT "Posizione:", IDC_STATIC, 188, 146, 36, 9 COMBOBOX IDC_PLACEMENT_COMBO, 188, 157, 50, 54, - CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END IDD_SCREENSAVER DIALOGEX 0, 0, 246, 204 @@ -201,8 +201,8 @@ IDS_CPLDESCRIPTION "Adatta la visualizzazione del desktop e dello screen saver." IDS_NONE "(Niente)" IDS_CENTER "Al centro" - IDS_STRETCH "Affiancata" - IDS_TILE "Estesa" + IDS_STRETCH "Estesa" + IDS_TILE "Affiancata" END STRINGTABLE DISCARDABLE Index: dll/cpl/desk/devsett.c =================================================================== --- dll/cpl/desk/devsett.c (revision 48415) +++ dll/cpl/desk/devsett.c (working copy) @@ -86,7 +86,7 @@ wcscpy(str, pszSrc); #else - MultiByteToWideChar(CP_APC, + MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, Index: dll/cpl/desk/background.c =================================================================== --- dll/cpl/desk/background.c (revision 48415) +++ dll/cpl/desk/background.c (working copy) @@ -17,6 +17,18 @@ #define PLACEMENT_STRETCH 1 #define PLACEMENT_TILE 2 +/* The values in these macros are dependant on the + * layout of the monitor image and they must be adjusted + * if that image will be changed. + */ +#define MONITOR_LEFT 18 +#define MONITOR_TOP 18 +#define MONITOR_RIGHT 168 +#define MONITOR_BOTTOM 128 + +#define MONITOR_WIDTH (MONITOR_RIGHT-MONITOR_LEFT) +#define MONITOR_HEIGHT (MONITOR_BOTTOM-MONITOR_TOP) + typedef struct { BOOL bWallpaper; /* Is this background a wallpaper */ @@ -305,7 +317,7 @@ RegCloseKey(regKey); - pGlobalData->hBitmap = (HBITMAP) LoadImage(hApplet, MAKEINTRESOURCE(IDC_MONITOR), IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT); + pGlobalData->hBitmap = (HBITMAP) LoadImage(hApplet, MAKEINTRESOURCE(IDC_MONITOR), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); if (pGlobalData->hBitmap != NULL) { GetObject(pGlobalData->hBitmap, sizeof(BITMAP), &bitmap); @@ -517,93 +529,138 @@ float scaleY; int scaledWidth; int scaledHeight; - int posX; - int posY; + int posX, desX; + int posY, desY; HBRUSH hBrush; int x; int y; + HDC hDC; + HGDIOBJ hOldObj; + RECT rcItem = { + MONITOR_LEFT, + MONITOR_TOP, + MONITOR_RIGHT, + MONITOR_BOTTOM + }; + hDC = CreateCompatibleDC(draw->hDC); + hOldObj = SelectObject(hDC, pGlobalData->hBitmap); + if (pGlobalData->backgroundItems[pGlobalData->backgroundSelection].bWallpaper == FALSE) { /* update desktop background color image */ hBrush = CreateSolidBrush(pGlobalData->backgroundDesktopColor); - FillRect(draw->hDC, &draw->rcItem, hBrush); + FillRect(hDC, &rcItem, hBrush); DeleteObject(hBrush); - return; } + else + if (pGlobalData->pWallpaperBitmap != NULL) + { + scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH; + scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT; - if (pGlobalData->pWallpaperBitmap == NULL) - return; + scaledWidth = (int)(pGlobalData->pWallpaperBitmap->width / scaleX); + scaledHeight = (int)(pGlobalData->pWallpaperBitmap->height / scaleY); - scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)draw->rcItem.right; - scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)draw->rcItem.bottom; + FillRect(hDC, &rcItem, GetSysColorBrush(COLOR_BACKGROUND)); - scaledWidth = pGlobalData->pWallpaperBitmap->width / scaleX; - scaledHeight = pGlobalData->pWallpaperBitmap->height / scaleY; + SetStretchBltMode(hDC, COLORONCOLOR); - posX = (draw->rcItem.right / 2) - (scaledWidth / 2); - posY = (draw->rcItem.bottom / 2) - (scaledHeight / 2); + switch (pGlobalData->placementSelection) + { + case PLACEMENT_CENTER: + posX = (MONITOR_WIDTH - scaledWidth + 1) / 2; + posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2; + desX = 0; + desY = 0; - FillRect(draw->hDC, &draw->rcItem, GetSysColorBrush(COLOR_BACKGROUND)); + if (posX < 0) { desX = -posX / 2; posX = 0; } + if (posY < 0) { desY = -posY / 2; posY = 0; } - SetStretchBltMode(draw->hDC, COLORONCOLOR); + if (scaledWidth > MONITOR_WIDTH) + scaledWidth = MONITOR_WIDTH; - switch (pGlobalData->placementSelection) - { - case PLACEMENT_CENTER: - StretchDIBits(draw->hDC, - posX, - posY, - scaledWidth, - scaledHeight, - 0, - 0, - pGlobalData->pWallpaperBitmap->width, - pGlobalData->pWallpaperBitmap->height, - pGlobalData->pWallpaperBitmap->bits, - pGlobalData->pWallpaperBitmap->info, - DIB_RGB_COLORS, - SRCCOPY); - break; + if (scaledHeight > MONITOR_HEIGHT) + scaledHeight = MONITOR_HEIGHT; - case PLACEMENT_STRETCH: - StretchDIBits(draw->hDC, - 0, - 0, - draw->rcItem.right, - draw->rcItem.bottom, - 0, - 0, - pGlobalData->pWallpaperBitmap->width, - pGlobalData->pWallpaperBitmap->height, - pGlobalData->pWallpaperBitmap->bits, - pGlobalData->pWallpaperBitmap->info, - DIB_RGB_COLORS, - SRCCOPY); - break; + StretchDIBits(hDC, + MONITOR_LEFT+posX, + MONITOR_TOP+posY, + scaledWidth, + scaledHeight, + desX, + desY, + pGlobalData->pWallpaperBitmap->width - (int)(desX * scaleX), + pGlobalData->pWallpaperBitmap->height - (int)(desY * scaleY), + pGlobalData->pWallpaperBitmap->bits, + pGlobalData->pWallpaperBitmap->info, + DIB_RGB_COLORS, + SRCCOPY); + break; - case PLACEMENT_TILE: - for (y = 0; y < draw->rcItem.bottom; y += scaledHeight) - { - for (x = 0; x < draw->rcItem.right; x += scaledWidth) + case PLACEMENT_STRETCH: + StretchDIBits(hDC, + MONITOR_LEFT, + MONITOR_TOP, + MONITOR_WIDTH, + MONITOR_HEIGHT, + 0, + 0, + pGlobalData->pWallpaperBitmap->width, + pGlobalData->pWallpaperBitmap->height, + pGlobalData->pWallpaperBitmap->bits, + pGlobalData->pWallpaperBitmap->info, + DIB_RGB_COLORS, + SRCCOPY); + break; + + case PLACEMENT_TILE: + for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight) { - StretchDIBits(draw->hDC, - x, - y, - scaledWidth, - scaledHeight, - 0, - 0, - pGlobalData->pWallpaperBitmap->width, - pGlobalData->pWallpaperBitmap->height, - pGlobalData->pWallpaperBitmap->bits, - pGlobalData->pWallpaperBitmap->info, - DIB_RGB_COLORS, - SRCCOPY); + for (x = 0; x < MONITOR_WIDTH; x += scaledWidth) + { + if ((MONITOR_WIDTH-x) >= scaledWidth) + posX = scaledWidth; + else + posX = MONITOR_WIDTH-x; + + + if ((MONITOR_HEIGHT-y) >= scaledHeight) + posY = scaledHeight; + else + posY = MONITOR_HEIGHT-y; + + StretchDIBits(hDC, + MONITOR_LEFT + x, + MONITOR_TOP + y, + posX, + posY, + 0, + 0, + pGlobalData->pWallpaperBitmap->width * posX / scaledWidth, + pGlobalData->pWallpaperBitmap->height * posY / scaledHeight, + pGlobalData->pWallpaperBitmap->bits, + pGlobalData->pWallpaperBitmap->info, + DIB_RGB_COLORS, + SRCCOPY); + } } - } - break; + + break; + } } + + TransparentBlt(draw->hDC, + draw->rcItem.left, draw->rcItem.top, + draw->rcItem.right-draw->rcItem.left+1, + draw->rcItem.bottom-draw->rcItem.top+1, + hDC, + 0, 0, + pGlobalData->cxSource, pGlobalData->cySource, + 0xFF00FF); + + SelectObject(hDC, hOldObj); + DeleteDC(hDC); } @@ -731,25 +788,6 @@ } } break; - case WM_PAINT: - { - PAINTSTRUCT ps; - HDC hdc, hdcMem; - - hdc = BeginPaint(hwndDlg, &ps); - - hdcMem = CreateCompatibleDC(hdc); - SelectObject(hdcMem, pGlobalData->hBitmap); -/* - TransparentBlt(hdc, 98, 0, - pGlobalData->cxSource, pGlobalData->cySource, hdcMem, 0, 0, - pGlobalData->cxSource, pGlobalData->cySource, 0xFF80FF); -*/ - DeleteDC(hdcMem); - EndPaint(hwndDlg, &ps); - } - break; - case WM_DRAWITEM: { LPDRAWITEMSTRUCT drawItem; Index: dll/cpl/desk/screensaver.c =================================================================== --- dll/cpl/desk/screensaver.c (revision 48415) +++ dll/cpl/desk/screensaver.c (working copy) @@ -22,9 +22,10 @@ typedef struct _GLOBAL_DATA { - ScreenSaverItem ScreenSaverItems[MAX_SCREENSAVERS]; + ScreenSaverItem ScreenSaverItems[MAX_SCREENSAVERS]; PROCESS_INFORMATION PrevWindowPi; - int Selection; + int Selection; + UINT ScreenSaverCount; } GLOBAL_DATA, *PGLOBAL_DATA; @@ -235,7 +236,7 @@ /s Run normal */ - WCHAR szCmdline[2048]; + TCHAR szCmdline[2048]; STARTUPINFO si; PROCESS_INFORMATION pi; @@ -320,61 +321,39 @@ } } - -static VOID -AddScreenSavers(HWND hwndDlg, PGLOBAL_DATA pGlobalData) +static VOID SearchScreenSavers(HWND hwndScreenSavers, + LPCTSTR pszSearchPath, + PGLOBAL_DATA pGlobalData) { - HWND hwndScreenSavers = GetDlgItem(hwndDlg, IDC_SCREENS_LIST); - WIN32_FIND_DATA fd; - HANDLE hFind; - TCHAR szSearchPath[MAX_PATH]; - INT i; - int ScreenSaverCount = 0; - ScreenSaverItem *ScreenSaverItem = NULL; - HANDLE hModule = NULL; + WIN32_FIND_DATA fd; + TCHAR szSearchPath[MAX_PATH]; + HANDLE hFind; + ScreenSaverItem *ScreenSaverItem; + HANDLE hModule; + UINT i, ScreenSaverCount; - /* Add the "None" item */ - ScreenSaverItem = &pGlobalData->ScreenSaverItems[ScreenSaverCount]; + ScreenSaverCount = pGlobalData->ScreenSaverCount; - ScreenSaverItem->bIsScreenSaver = FALSE; + _tcscpy(szSearchPath, pszSearchPath); + _tcscat(szSearchPath, TEXT("\\*.scr")); - LoadString(hApplet, - IDS_NONE, - ScreenSaverItem->szDisplayName, - sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR)); + hFind = FindFirstFile(szSearchPath, &fd); - i = SendMessage(hwndScreenSavers, - CB_ADDSTRING, - 0, - (LPARAM)ScreenSaverItem->szDisplayName); + if (hFind == INVALID_HANDLE_VALUE) + return; - SendMessage(hwndScreenSavers, - CB_SETITEMDATA, - i, - (LPARAM)ScreenSaverCount); - - ScreenSaverCount++; - - /* Add all the screensavers in the C:\ReactOS\System32 directory. */ - - GetSystemDirectory(szSearchPath, MAX_PATH); - _tcscat(szSearchPath, TEXT("\\*.scr")); - - hFind = FindFirstFile(szSearchPath, &fd); - while (ScreenSaverCount < MAX_SCREENSAVERS-1 && - hFind != INVALID_HANDLE_VALUE) + while (ScreenSaverCount < MAX_SCREENSAVERS) { /* Don't add any hidden screensavers */ if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) { TCHAR filename[MAX_PATH]; - GetSystemDirectory(filename, MAX_PATH); - - _tcscat(filename, TEXT("\\")); + _tcscpy(filename, pszSearchPath); + _tcscat(filename, _T("\\")); _tcscat(filename, fd.cFileName); - ScreenSaverItem = &pGlobalData->ScreenSaverItems[ScreenSaverCount]; + ScreenSaverItem = pGlobalData->ScreenSaverItems + ScreenSaverCount; ScreenSaverItem->bIsScreenSaver = TRUE; @@ -383,11 +362,16 @@ DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE); if (hModule) { - LoadString(hModule, + if (0 == LoadString(hModule, 1, ScreenSaverItem->szDisplayName, - sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR)); - FreeLibrary(hModule); + sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR))) + { + // If the string does not exists, copy the name of the file + _tcscpy(ScreenSaverItem->szDisplayName, fd.cFileName); + ScreenSaverItem->szDisplayName[_tcslen(fd.cFileName)-4] = '\0'; + } + FreeLibrary(hModule); } else { @@ -410,11 +394,65 @@ } if (!FindNextFile(hFind, &fd)) - hFind = INVALID_HANDLE_VALUE; + break; } + + FindClose(hFind); + + pGlobalData->ScreenSaverCount = ScreenSaverCount; } +static VOID +AddScreenSavers(HWND hwndDlg, PGLOBAL_DATA pGlobalData) +{ + HWND hwndScreenSavers = GetDlgItem(hwndDlg, IDC_SCREENS_LIST); + TCHAR szSearchPath[MAX_PATH]; + INT i; + ScreenSaverItem *ScreenSaverItem = NULL; + LPTSTR lpBackSlash; + /* Add the "None" item */ + ScreenSaverItem = pGlobalData->ScreenSaverItems; + + ScreenSaverItem->bIsScreenSaver = FALSE; + + LoadString(hApplet, + IDS_NONE, + ScreenSaverItem->szDisplayName, + sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR)); + + i = SendMessage(hwndScreenSavers, + CB_ADDSTRING, + 0, + (LPARAM)ScreenSaverItem->szDisplayName); + + SendMessage(hwndScreenSavers, + CB_SETITEMDATA, + i, + (LPARAM)0); + + // Initialize number of items into the list + pGlobalData->ScreenSaverCount = 1; + + // Add all the screensavers in the C:\ReactOS\System32 directory. + GetSystemDirectory(szSearchPath, MAX_PATH); + SearchScreenSavers(hwndScreenSavers, szSearchPath, pGlobalData); + + // Add all the screensavers in the C:\ReactOS directory. + GetWindowsDirectory(szSearchPath, MAX_PATH); + SearchScreenSavers(hwndScreenSavers, szSearchPath, pGlobalData); + + // Add all the screensavers where the applet is stored. + GetModuleFileName(hApplet, szSearchPath, MAX_PATH); + lpBackSlash = _tcsrchr(szSearchPath, _T('\\')); + if (lpBackSlash != NULL) + { + lpBackSlash = '\0'; + SearchScreenSavers(hwndScreenSavers, szSearchPath, pGlobalData); + } +} + + static VOID SetScreenSaver(HWND hwndDlg, PGLOBAL_DATA pGlobalData) {