https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc794e564a5b773e3eafc…
commit cc794e564a5b773e3eafcef46f497522f42d4e8f
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Jan 28 13:41:29 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jan 28 13:41:29 2020 +0900
[CPL][DESK] Add icons to 'Background' tab (#2281)
Add icons into "Background" tab of "Properties for Display"
dialog.
CORE-16665
---
dll/cpl/desk/background.c | 119 +++++++++++++++++++++-------------------
dll/cpl/desk/desk.rc | 1 +
dll/cpl/desk/resource.h | 1 +
dll/cpl/desk/resources/none.ico | Bin 0 -> 23558 bytes
4 files changed, 64 insertions(+), 57 deletions(-)
diff --git a/dll/cpl/desk/background.c b/dll/cpl/desk/background.c
index a92f27b7185..f73cdcb9d19 100644
--- a/dll/cpl/desk/background.c
+++ b/dll/cpl/desk/background.c
@@ -203,6 +203,8 @@ AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList,
BackgroundIte
return i;
}
+ himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
+
token = _tcstok(szFileTypes, separators);
while (token != NULL)
{
@@ -227,19 +229,13 @@ AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList,
BackgroundIte
/* Don't add any hidden bitmaps. Also don't add current wallpaper
once more. */
if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) &&
(_tcsicmp(wallpaperFilename, filename) != 0))
{
- himl = (HIMAGELIST)SHGetFileInfo(filename,
- 0,
- &sfi,
- sizeof(sfi),
- SHGFI_SYSICONINDEX | SHGFI_SMALLICON |
- SHGFI_DISPLAYNAME);
- if (himl == NULL)
- break;
-
- if (i++ == 0)
- {
- (void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
- }
+ SHGetFileInfo(filename,
+ 0,
+ &sfi,
+ sizeof(sfi),
+ SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME);
+ sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
+ i++;
backgroundItem =
&pData->backgroundItems[pData->listViewItemCount];
@@ -311,11 +307,20 @@ AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
BackgroundItem *backgroundItem = NULL;
HWND hwndBackgroundList;
HRESULT hr;
+ HICON hIcon;
+ INT cx, cy;
hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
GetClientRect(hwndBackgroundList, &clientRect);
+ cx = GetSystemMetrics(SM_CXSMICON);
+ cy = GetSystemMetrics(SM_CYSMICON);
+ himl = ImageList_Create(cx, cy, ILC_COLOR32 | ILC_MASK, 0, 0);
+ hIcon = (HICON)LoadImageW(hApplet, MAKEINTRESOURCEW(IDI_NONE), IMAGE_ICON, cx, cy,
0);
+
+ ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
+
/* Add a new column to the list */
ZeroMemory(&dummy, sizeof(LV_COLUMN));
dummy.mask = LVCF_SUBITEM | LVCF_WIDTH;
@@ -335,9 +340,10 @@ AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
listItem.state = 0;
listItem.pszText = backgroundItem->szDisplayName;
- listItem.iImage = -1;
+ listItem.iImage = ImageList_AddIcon(himl, hIcon);
listItem.iItem = pData->listViewItemCount;
listItem.lParam = pData->listViewItemCount;
+ hIcon = NULL;
(void)ListView_InsertItem(hwndBackgroundList, &listItem);
ListView_SetItemState(hwndBackgroundList,
@@ -385,55 +391,51 @@ AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
}
}
- himl = (HIMAGELIST)SHGetFileInfo(wallpaperFilename,
- 0,
- &sfi,
- sizeof(sfi),
- SHGFI_SYSICONINDEX | SHGFI_SMALLICON |
- SHGFI_DISPLAYNAME);
- if (himl != NULL)
- {
- if (i++ == 0)
- {
- (void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
- }
-
- backgroundItem =
&pData->backgroundItems[pData->listViewItemCount];
+ SHGetFileInfoW(wallpaperFilename,
+ 0,
+ &sfi,
+ sizeof(sfi),
+ SHGFI_ICON | SHGFI_SMALLICON |
+ SHGFI_DISPLAYNAME);
+ sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
- backgroundItem->bWallpaper = TRUE;
+ i++;
- hr = StringCbCopy(backgroundItem->szDisplayName,
sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
- if (FAILED(hr))
- {
- RegCloseKey(regKey);
- return;
- }
+ backgroundItem =
&pData->backgroundItems[pData->listViewItemCount];
- PathRemoveExtension(backgroundItem->szDisplayName);
+ backgroundItem->bWallpaper = TRUE;
- hr = StringCbCopy(backgroundItem->szFilename,
sizeof(backgroundItem->szFilename), wallpaperFilename);
- if (FAILED(hr))
- {
- RegCloseKey(regKey);
- return;
- }
-
- ZeroMemory(&listItem, sizeof(LV_ITEM));
- listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
- listItem.state = 0;
- listItem.pszText = backgroundItem->szDisplayName;
- listItem.iImage = sfi.iIcon;
- listItem.iItem = pData->listViewItemCount;
- listItem.lParam = pData->listViewItemCount;
+ hr = StringCbCopy(backgroundItem->szDisplayName,
sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
+ if (FAILED(hr))
+ {
+ RegCloseKey(regKey);
+ return;
+ }
- (void)ListView_InsertItem(hwndBackgroundList, &listItem);
- ListView_SetItemState(hwndBackgroundList,
- pData->listViewItemCount,
- LVIS_SELECTED,
- LVIS_SELECTED);
+ PathRemoveExtension(backgroundItem->szDisplayName);
- pData->listViewItemCount++;
+ hr = StringCbCopy(backgroundItem->szFilename,
sizeof(backgroundItem->szFilename), wallpaperFilename);
+ if (FAILED(hr))
+ {
+ RegCloseKey(regKey);
+ return;
}
+
+ ZeroMemory(&listItem, sizeof(LV_ITEM));
+ listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
+ listItem.state = 0;
+ listItem.pszText = backgroundItem->szDisplayName;
+ listItem.iImage = sfi.iIcon;
+ listItem.iItem = pData->listViewItemCount;
+ listItem.lParam = pData->listViewItemCount;
+
+ (void)ListView_InsertItem(hwndBackgroundList, &listItem);
+ ListView_SetItemState(hwndBackgroundList,
+ pData->listViewItemCount,
+ LVIS_SELECTED,
+ LVIS_SELECTED);
+
+ pData->listViewItemCount++;
}
RegCloseKey(regKey);
@@ -640,8 +642,10 @@ OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
size_t sizeRemain;
SIZE_T buffersize;
BOOL success;
+ HIMAGELIST himl;
hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
+ himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
ZeroMemory(&ofn, sizeof(OPENFILENAME));
@@ -715,7 +719,8 @@ OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
0,
&sfi,
sizeof(sfi),
- SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_DISPLAYNAME);
+ SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME);
+ sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
diff --git a/dll/cpl/desk/desk.rc b/dll/cpl/desk/desk.rc
index 08301b0fee7..60352eda891 100644
--- a/dll/cpl/desk/desk.rc
+++ b/dll/cpl/desk/desk.rc
@@ -14,6 +14,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDC_DESK_ICON ICON "resources/applet.ico"
IDC_DESK_ICON2 ICON "resources/applet.ico"
+IDI_NONE ICON "resources/none.ico"
IDC_MONITOR BITMAP "resources/monitor.bmp"
diff --git a/dll/cpl/desk/resource.h b/dll/cpl/desk/resource.h
index 816ab45311f..bbe32ea6469 100644
--- a/dll/cpl/desk/resource.h
+++ b/dll/cpl/desk/resource.h
@@ -3,6 +3,7 @@
/* ids */
#define IDC_DESK_ICON 40
#define IDC_DESK_ICON2 100 /* Needed for theme compatability with Windows. */
+#define IDI_NONE 101
#define IDC_STATIC -1
diff --git a/dll/cpl/desk/resources/none.ico b/dll/cpl/desk/resources/none.ico
new file mode 100644
index 00000000000..f306984bdb4
Binary files /dev/null and b/dll/cpl/desk/resources/none.ico differ