ReactOS 0.4.16-dev-2332-g4cba65d
background.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Display Control Panel
4 * FILE: dll/cpl/desk/background.c
5 * PURPOSE: Background property page
6 *
7 * PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
8 * Alexey Minnekhanov (minlexx@rambler.ru)
9 */
10
11#include "desk.h"
12
13#include <shellapi.h>
14#include <shlwapi.h>
15#include <windowsx.h>
16
17#define MAX_BACKGROUNDS 100
18
19typedef enum
20{
27
28/* The tile placement is stored in different registry
29 * key, but due to a condition in win32k it needs to be
30 * zero when stored in the same key as others.
31 */
32typedef enum
33{
40
41typedef struct
42{
43 BOOL bWallpaper; /* Is this background a wallpaper */
44
45 TCHAR szFilename[MAX_PATH];
46 TCHAR szDisplayName[256];
47
49
50typedef struct _BACKGROUND_DATA
51{
54
56
58
61
63
65
67
70
72
73
76{
77 UINT num;
78 UINT size;
79 UINT i;
80 ImageCodecInfo *codecInfo;
81
83 size == 0)
84 {
85 return E_FAIL;
86 }
87
88 codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
89 if (!codecInfo)
90 {
91 return E_OUTOFMEMORY;
92 }
93
94 if (GdipGetImageEncoders(num, size, codecInfo) != Ok)
95 {
96 HeapFree(GetProcessHeap(), 0, codecInfo);
97 return E_FAIL;
98 }
99
100 for (i = 0; i < num; i++)
101 {
102 if (!_wcsicmp(codecInfo[i].MimeType, MimeType))
103 {
104 *pClsid = codecInfo[i].Clsid;
105 HeapFree(GetProcessHeap(), 0, codecInfo);
106 return S_OK;
107 }
108 }
109
110 HeapFree(GetProcessHeap(), 0, codecInfo);
111 return E_FAIL;
112}
113
114
115LPWSTR
117{
118 ImageCodecInfo *codecInfo;
119 UINT num;
120 UINT size;
121 UINT i;
123
124 if (GdipGetImageDecodersSize(&num, &size) != Ok ||
125 size == 0)
126 {
127 return NULL;
128 }
129
130 codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
131 if (!codecInfo)
132 {
133 return NULL;
134 }
135
136 if (GdipGetImageDecoders(num, size, codecInfo) != Ok)
137 {
138 HeapFree(GetProcessHeap(), 0, codecInfo);
139 return NULL;
140 }
141
142 size = 0;
143 for (i = 0; i < num; ++i)
144 {
145 size = size + (UINT)wcslen(codecInfo[i].FilenameExtension) + 1;
146 }
147
148 size = (size + 1) * sizeof(WCHAR);
149
151 if (!lpBuffer)
152 {
153 HeapFree(GetProcessHeap(), 0, codecInfo);
154 return NULL;
155 }
156
157 for (i = 0; i < num; ++i)
158 {
159 if (!lstrcmpiW(codecInfo[i].FilenameExtension, L"*.ico"))
160 continue;
161
162 StringCbCatW(lpBuffer, size, codecInfo[i].FilenameExtension);
163 if (i < (num - 1))
164 {
166 }
167 }
168
169 HeapFree(GetProcessHeap(), 0, codecInfo);
170
171 return lpBuffer;
172}
173
174
175static UINT
176AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
177{
179 HANDLE hFind;
180 TCHAR szSearchPath[MAX_PATH];
181 LPTSTR szFileTypes = NULL;
182 TCHAR separators[] = TEXT(";");
183 TCHAR *token;
184 HRESULT hr;
185 SHFILEINFO sfi;
186 UINT i = uCounter;
187 LV_ITEM listItem;
189
190 szFileTypes = GdipGetSupportedFileExtensions();
191 if (!szFileTypes)
192 {
193 return i;
194 }
195
196 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
197
198 token = _tcstok(szFileTypes, separators);
199 while (token != NULL)
200 {
201 if (!PathCombine(szSearchPath, wallpaperDirectory, token))
202 {
203 HeapFree(GetProcessHeap(), 0, szFileTypes);
204 return i;
205 }
206
207 hFind = FindFirstFile(szSearchPath, &fd);
208 while (hFind != INVALID_HANDLE_VALUE)
209 {
211
212 if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
213 {
214 FindClose(hFind);
215 HeapFree(GetProcessHeap(), 0, szFileTypes);
216 return i;
217 }
218
219 /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
220 if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
221 {
223 0,
224 &sfi,
225 sizeof(sfi),
227 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
228 i++;
229
230 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
231
232 backgroundItem->bWallpaper = TRUE;
233
234 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
235 if (FAILED(hr))
236 {
237 FindClose(hFind);
238 HeapFree(GetProcessHeap(), 0, szFileTypes);
239 return i;
240 }
241
242 PathRemoveExtension(backgroundItem->szDisplayName);
243
244 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
245 if (FAILED(hr))
246 {
247 FindClose(hFind);
248 HeapFree(GetProcessHeap(), 0, szFileTypes);
249 return i;
250 }
251
252 ZeroMemory(&listItem, sizeof(LV_ITEM));
253 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
254 listItem.pszText = backgroundItem->szDisplayName;
255 listItem.state = 0;
256 listItem.iImage = sfi.iIcon;
257 listItem.iItem = pData->listViewItemCount;
258 listItem.lParam = pData->listViewItemCount;
259
260 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
261
262 pData->listViewItemCount++;
263 }
264
265 if (!FindNextFile(hFind, &fd))
266 break;
267 }
268
269 token = _tcstok(NULL, separators);
270 FindClose(hFind);
271 }
272
273 HeapFree(GetProcessHeap(), 0, szFileTypes);
274
275 return i;
276}
277
278
279/* Add the images in the C:\ReactOS, the wallpaper directory and the current wallpaper if any */
280static VOID
282{
283 TCHAR szSearchPath[MAX_PATH];
284 LV_ITEM listItem;
286 RECT clientRect;
287 HKEY regKey;
288 SHFILEINFO sfi;
290 TCHAR wallpaperFilename[MAX_PATH];
291 TCHAR originalWallpaper[MAX_PATH];
292 DWORD bufferSize = sizeof(wallpaperFilename);
294 DWORD varType = REG_SZ;
295 LONG result;
296 UINT i = 0;
297 BackgroundItem *backgroundItem = NULL;
298 HWND hwndBackgroundList;
299 HRESULT hr;
300 HICON hIcon;
301 INT cx, cy;
303
304 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
305
306 GetClientRect(hwndBackgroundList, &clientRect);
307
311
312 /* Load (None) icon */
313#define IDI_SHELL_NO 200
314 hShell32 = GetModuleHandleW(L"shell32.dll");
316#undef IDI_SHELL_NO
317
318 ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
319
320 /* Add a new column to the list */
321 ZeroMemory(&dummy, sizeof(LV_COLUMN));
323 dummy.iSubItem = 0;
324 dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
325 (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
326
327 /* Add the "None" item */
328 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
329 backgroundItem->bWallpaper = FALSE;
331 IDS_NONE,
332 backgroundItem->szDisplayName,
333 sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
334
335 ZeroMemory(&listItem, sizeof(LV_ITEM));
336 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
337 listItem.state = 0;
338 listItem.pszText = backgroundItem->szDisplayName;
339 listItem.iImage = ImageList_AddIcon(himl, hIcon);
340 listItem.iItem = pData->listViewItemCount;
341 listItem.lParam = pData->listViewItemCount;
342 hIcon = NULL;
343
344 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
345 ListView_SetItemState(hwndBackgroundList,
346 pData->listViewItemCount,
349
350 pData->listViewItemCount++;
351
352 /* Add current wallpaper if any */
353 result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
354 if (result == ERROR_SUCCESS)
355 {
356 result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
357 if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
358 {
359 bufferSize = sizeof(originalWallpaper);
360 result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
361
362 /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
363 if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
364 {
365 bufferSize = sizeof(originalWallpaper);
366 result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
367
368 if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
369 {
370 hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
371 if (FAILED(hr))
372 {
373 RegCloseKey(regKey);
374 return;
375 }
376 }
377 }
378
379 /* Allow environment variables in file name */
380 if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
381 {
382 hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
383 if (FAILED(hr))
384 {
385 RegCloseKey(regKey);
386 return;
387 }
388 }
389
390 if (!SHGetFileInfoW(wallpaperFilename, 0, &sfi, sizeof(sfi),
392 {
393 RegCloseKey(regKey);
394 return;
395 }
396
397 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
398 DestroyIcon(sfi.hIcon);
399
400 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
401 backgroundItem->bWallpaper = TRUE;
402
403 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
404 if (FAILED(hr))
405 {
406 RegCloseKey(regKey);
407 return;
408 }
409
410 PathRemoveExtension(backgroundItem->szDisplayName);
411
412 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
413 if (FAILED(hr))
414 {
415 RegCloseKey(regKey);
416 return;
417 }
418
419 ZeroMemory(&listItem, sizeof(listItem));
420 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
421 listItem.state = 0;
422 listItem.pszText = backgroundItem->szDisplayName;
423 listItem.iImage = sfi.iIcon;
424 listItem.iItem = pData->listViewItemCount;
425 listItem.lParam = pData->listViewItemCount;
426 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
427
428 ListView_SetItemState(hwndBackgroundList,
429 pData->listViewItemCount,
432 i++;
433 pData->listViewItemCount++;
434 }
435
436 RegCloseKey(regKey);
437 }
438
439 /* Add all the images in the C:\ReactOS directory. */
440 if (GetWindowsDirectory(szSearchPath, MAX_PATH))
441 {
442 i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
443 }
444
445 /* Add all the images in the wallpaper directory. */
446 if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
447 {
448 i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
449 }
450}
451
452
453static VOID
455{
456 TCHAR szString[256];
457 HKEY regKey;
458 TCHAR szBuffer[3];
459 DWORD bufferSize = sizeof(szBuffer);
460
461 AddListViewItems(hwndDlg, pData);
462
463 LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
465
466 LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
468
469 LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
471
472 LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
474
475 LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
477
479 pData->placementSelection = PLACEMENT_CENTER;
480
481 /* Load the default settings from the registry */
482 if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
483 {
484 return;
485 }
486
487 if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
488 {
489 if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
490 {
492 pData->placementSelection = PLACEMENT_CENTER;
493 }
494
495 if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
496 {
498 pData->placementSelection = PLACEMENT_STRETCH;
499 }
500
501 if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
502 {
504 pData->placementSelection = PLACEMENT_FIT;
505 }
506
507 if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
508 {
510 pData->placementSelection = PLACEMENT_FILL;
511 }
512 }
513
514 if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
515 {
516 if (_ttoi(szBuffer) == 1)
517 {
519 pData->placementSelection = PLACEMENT_TILE;
520 }
521 }
522
523 RegCloseKey(regKey);
524}
525
526
527static VOID
529{
530 /* Load custom colors from Registry */
531 HKEY hKey = NULL;
534
535 res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
537 /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
538 if (res == ERROR_SUCCESS)
539 {
540 /* Key opened */
541 DWORD dwType = REG_BINARY;
542 DWORD cbData = sizeof(pData->custom_colors);
543 res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
544 (LPBYTE)pData->custom_colors, &cbData);
546 hKey = NULL;
547 }
548
549 /* Launch ChooseColor() dialog */
550
551 cc.lStructSize = sizeof(CHOOSECOLOR);
552 cc.hwndOwner = hwndDlg;
553 cc.hInstance = NULL;
554 cc.rgbResult = g_GlobalData.desktop_color;
555 cc.lpCustColors = pData->custom_colors;
556 cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
557 CC_FULLOPEN | /* opens dialog in full size */
558 CC_RGBINIT ; /* init chosen color by rgbResult value */
559 cc.lCustData = 0;
560 cc.lpfnHook = NULL;
561 cc.lpTemplateName = NULL;
562 if (ChooseColor(&cc))
563 {
564 /* Save selected color to var */
565 g_GlobalData.desktop_color = cc.rgbResult;
566 pData->bClrBackgroundChanged = TRUE;
567
568 /* Apply button will be activated */
569 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
570
571 /* Window will be updated :) */
574
575 /* Save custom colors to reg. To this moment key must be created already. See above */
576 res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
578 if (res == ERROR_SUCCESS)
579 {
580 /* Key opened */
581 RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
582 (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
584 hKey = NULL;
585 }
586 }
587}
588
589
590/*
591 * ListView_FindItem() Macro: Searches for a list-view item with the specified
592 * characteristics. Returns the index of the item if successful, or -1 otherwise
593 */
594static BOOL
596{
597 LVFINDINFO lvfi;
598 int retVal;
599
600 lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
601 lvfi.psz = tszFileName; /* String to search */
602
603 /* Other items of this structure are not valid, besacuse flags are not set. */
604 retVal = ListView_FindItem(hwndList, -1, &lvfi);
605 if (retVal != -1)
606 return TRUE; /* item found! */
607
608 return FALSE; /* item not found. */
609}
610
611
612static VOID
614{
617 TCHAR fileTitle[256];
618 TCHAR initialDir[MAX_PATH];
620 LPTSTR extensions;
621 BackgroundItem *backgroundItem = NULL;
622 SHFILEINFO sfi;
623 LV_ITEM listItem;
624 HWND hwndBackgroundList;
625 TCHAR *p;
626 HRESULT hr;
627 TCHAR filterdesc[MAX_PATH];
628 TCHAR *c;
629 size_t sizeRemain;
630 SIZE_T buffersize;
633
634 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
635 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
636 SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
637
638 ZeroMemory(&ofn, sizeof(OPENFILENAME));
639
640 ofn.lStructSize = sizeof(OPENFILENAME);
641 ofn.hwndOwner = hwndDlg;
643
644 LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
645
646 extensions = GdipGetSupportedFileExtensions();
647 if (!extensions)
648 {
649 return;
650 }
651
652 buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
653
655 if (!filter)
656 {
657 HeapFree(GetProcessHeap(), 0, extensions);
658 return;
659 }
660
661 sizeRemain = buffersize;
662 c = filter;
663
664 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
665 {
666 HeapFree(GetProcessHeap(), 0, extensions);
668 return;
669 }
670
671 c++;
672 sizeRemain -= sizeof(*c);
673
674 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
675 {
676 HeapFree(GetProcessHeap(), 0, extensions);
678 return;
679 }
680
681 HeapFree(GetProcessHeap(), 0, extensions);
682
683 /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
684 * use the contents of szFile to initialize itself */
685 ofn.lpstrFile[0] = TEXT('\0');
688 ofn.nFilterIndex = 0;
689 ofn.lpstrFileTitle = fileTitle;
690 ofn.nMaxFileTitle = 256;
691 ofn.lpstrInitialDir = initialDir;
693
696
697 if (success)
698 {
699 /* Check if there is already a entry that holds this filename */
700 if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
701 return;
702
703 if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
704 return;
705
707 0,
708 &sfi,
709 sizeof(sfi),
711 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
712
713 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
714
715 backgroundItem->bWallpaper = TRUE;
716
717 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
718 if (FAILED(hr))
719 return;
720 p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
721 if (p)
722 *p = (TCHAR)0;
723 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
724 if (FAILED(hr))
725 return;
726
727 ZeroMemory(&listItem, sizeof(LV_ITEM));
728 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
729 listItem.state = 0;
730 listItem.pszText = backgroundItem->szDisplayName;
731 listItem.iImage = sfi.iIcon;
732 listItem.iItem = pData->listViewItemCount;
733 listItem.lParam = pData->listViewItemCount;
734
735 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
736 ListView_SetItemState(hwndBackgroundList,
737 pData->listViewItemCount,
740 SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
741
742 pData->listViewItemCount++;
743 }
744}
745
746
747static VOID
749{
750 BackgroundItem *backgroundItem = NULL;
751
752 pData->backgroundSelection = itemIndex;
753 backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
754
755 if (pData->pWallpaperBitmap != NULL)
756 {
757 DibFreeImage(pData->pWallpaperBitmap);
758 pData->pWallpaperBitmap = NULL;
759 }
760
761 if (backgroundItem->bWallpaper != FALSE)
762 {
763 pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
764
765 if (pData->pWallpaperBitmap == NULL)
766 return;
767 }
768
769 pData->bWallpaperChanged = TRUE;
770
772 NULL, TRUE);
773
775 backgroundItem->bWallpaper);
776
777 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
778}
779
780
781static VOID
783{
784 float scaleX;
785 float scaleY;
786 int scaledWidth;
787 int scaledHeight;
788 int posX, desX;
789 int posY, desY;
790 int fitFillScaleNum, fitFillScaleDen;
791 int fitFillWidth, fitFillHeight;
792 HBRUSH hBrush;
793 int x;
794 int y;
795 HDC hDC;
796 HGDIOBJ hOldObj;
797 RECT rcItem = {
802 };
803
804 hDC = CreateCompatibleDC(draw->hDC);
806
807 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
808 {
809 /* Update desktop background color image */
811 FillRect(hDC, &rcItem, hBrush);
812 DeleteObject(hBrush);
813 }
814 else
815 if (pData->pWallpaperBitmap != NULL)
816 {
817 scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
818 scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
819
820 scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
821 scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
822
824
826
827 switch (pData->placementSelection)
828 {
829 case PLACEMENT_CENTER:
830 posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
831 posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
832 desX = 0;
833 desY = 0;
834
835 if (posX < 0) { desX = -posX / 2; posX = 0; }
836 if (posY < 0) { desY = -posY / 2; posY = 0; }
837
838 if (scaledWidth > MONITOR_WIDTH)
839 scaledWidth = MONITOR_WIDTH;
840
841 if (scaledHeight > MONITOR_HEIGHT)
842 scaledHeight = MONITOR_HEIGHT;
843
845 MONITOR_LEFT+posX,
846 MONITOR_TOP+posY,
847 scaledWidth,
848 scaledHeight,
849 desX,
850 desY,
851 pData->pWallpaperBitmap->width - (int)(desX * scaleX),
852 pData->pWallpaperBitmap->height - (int)(desY * scaleY),
853 pData->pWallpaperBitmap->bits,
854 pData->pWallpaperBitmap->info,
856 SRCCOPY);
857 break;
858
865 0,
866 0,
867 pData->pWallpaperBitmap->width,
868 pData->pWallpaperBitmap->height,
869 pData->pWallpaperBitmap->bits,
870 pData->pWallpaperBitmap->info,
872 SRCCOPY);
873 break;
874
875 case PLACEMENT_TILE:
876 for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
877 {
878 for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
879 {
880 if ((MONITOR_WIDTH-x) >= scaledWidth)
881 posX = scaledWidth;
882 else
883 posX = MONITOR_WIDTH-x;
884
885
886 if ((MONITOR_HEIGHT-y) >= scaledHeight)
887 posY = scaledHeight;
888 else
889 posY = MONITOR_HEIGHT-y;
890
892 MONITOR_LEFT + x,
893 MONITOR_TOP + y,
894 posX,
895 posY,
896 0,
897 0,
898 pData->pWallpaperBitmap->width * posX / scaledWidth,
899 pData->pWallpaperBitmap->height * posY / scaledHeight,
900 pData->pWallpaperBitmap->bits,
901 pData->pWallpaperBitmap->info,
903 SRCCOPY);
904 }
905
906 }
907
908 break;
909
910 case PLACEMENT_FIT:
911 if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
912 {
913 fitFillScaleNum = MONITOR_WIDTH;
914 fitFillScaleDen = scaledWidth;
915 }
916 else
917 {
918 fitFillScaleNum = MONITOR_HEIGHT;
919 fitFillScaleDen = scaledHeight;
920 }
921
922 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
923 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
924
925 posX = (MONITOR_WIDTH - fitFillWidth) / 2;
926 posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
927
929 MONITOR_LEFT + posX,
930 MONITOR_TOP + posY,
931 fitFillWidth,
932 fitFillHeight,
933 0,
934 0,
935 pData->pWallpaperBitmap->width,
936 pData->pWallpaperBitmap->height,
937 pData->pWallpaperBitmap->bits,
938 pData->pWallpaperBitmap->info,
940 SRCCOPY);
941 break;
942
943 case PLACEMENT_FILL:
944 if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
945 {
946 fitFillScaleNum = MONITOR_WIDTH;
947 fitFillScaleDen = scaledWidth;
948 }
949 else
950 {
951 fitFillScaleNum = MONITOR_HEIGHT;
952 fitFillScaleDen = scaledHeight;
953 }
954
955 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
956 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
957
958 desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
959 desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
960
966 desX,
967 desY,
968 (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
969 (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
970 pData->pWallpaperBitmap->bits,
971 pData->pWallpaperBitmap->info,
973 SRCCOPY);
974 break;
975 }
976 }
977
979 draw->rcItem.left, draw->rcItem.top,
980 draw->rcItem.right - draw->rcItem.left + 1,
981 draw->rcItem.bottom - draw->rcItem.top + 1,
982 hDC,
983 0, 0,
986
987 SelectObject(hDC, hOldObj);
988 DeleteDC(hDC);
989}
990
991
992static VOID
994{
995 HKEY regKey;
996 TCHAR szWallpaper[MAX_PATH];
997 GpImage *image;
998 CLSID encoderClsid;
999 GUID guidFormat;
1000 size_t length = 0;
1002
1004 {
1005 return;
1006 }
1007
1008 if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1009 {
1010 return;
1011 }
1012
1013 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1015 {
1016 return;
1017 }
1018
1019 if (pData->placementSelection == PLACEMENT_TILE)
1020 {
1021 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1022 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1023 }
1024
1025 if (pData->placementSelection == PLACEMENT_CENTER)
1026 {
1027 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1028 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1029 }
1030
1031 if (pData->placementSelection == PLACEMENT_STRETCH)
1032 {
1033 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1034 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1035 }
1036
1037 if (pData->placementSelection == PLACEMENT_FIT)
1038 {
1039 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1040 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1041 }
1042
1043 if (pData->placementSelection == PLACEMENT_FILL)
1044 {
1045 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1046 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1047 }
1048
1049 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1050 {
1051 GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1052 if (!image)
1053 {
1054 RegCloseKey(regKey);
1055 return;
1056 }
1057
1058 GdipGetImageRawFormat(image, &guidFormat);
1059 if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1060 {
1062 RegCloseKey(regKey);
1063 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1064 return;
1065 }
1066
1067 if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1068 {
1070 RegCloseKey(regKey);
1071 return;
1072 }
1073
1074 status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1075
1077
1078 if (status != Ok)
1079 {
1080 RegCloseKey(regKey);
1081 return;
1082 }
1083
1084 if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1085 {
1086 RegSetValueEx(regKey,
1087 TEXT("ConvertedWallpaper"),
1088 0,
1089 REG_SZ,
1090 (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1091 (DWORD)((length + 1) * sizeof(TCHAR)));
1092 }
1093
1094 if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1095 {
1096 RegSetValueEx(regKey,
1097 TEXT("OriginalWallpaper"),
1098 0,
1099 REG_SZ,
1100 (LPBYTE)szWallpaper,
1101 (DWORD)((length + 1) * sizeof(TCHAR)));
1102 }
1103
1105 }
1106 else
1107 {
1109 }
1110
1111 RegCloseKey(regKey);
1112}
1113
1114
1115/* Change system color */
1116static VOID
1118{
1119 HKEY hKey;
1120 INT iElement = COLOR_BACKGROUND;
1121 TCHAR clText[16];
1122 BYTE red, green, blue;
1123
1124 if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1125 {
1126 /* FIXME: these error texts can need internationalization? */
1127 MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1128 TEXT("Error!"), MB_ICONSTOP );
1129 }
1130
1131 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1133 {
1134 return;
1135 }
1136
1140
1141 /* Format string to be set to registry */
1142 StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1143 RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1144 (wcslen(clText) + 1) * sizeof(TCHAR));
1145
1147}
1148
1149static VOID
1151{
1152 HPROPSHEETPAGE hpsp[1] = {0};
1153 PROPSHEETHEADER psh = {sizeof(psh)};
1154 PROPSHEETPAGE psp = {sizeof(psp)};
1155
1156 psh.dwFlags = PSH_NOAPPLYNOW;
1157 psh.hwndParent = GetParent(hwndDlg);
1158 psh.hInstance = hApplet;
1159 psh.pszCaption = MAKEINTRESOURCE(IDS_DESKTOP_ITEMS);
1160 psh.phpage = hpsp;
1161
1162 psp.dwFlags = PSP_DEFAULT;
1163 psp.hInstance = hApplet;
1164 psp.pszTemplate = MAKEINTRESOURCE(IDD_DESKTOP_GENERAL);
1165 psp.pfnDlgProc = DesktopPageProc;
1166 psp.lParam = (LPARAM)&pData->desktopData;
1167
1168 hpsp[0] = CreatePropertySheetPage(&psp);
1169 if (!hpsp[0])
1170 return;
1171
1172 psh.nPages++;
1173
1174 if (PropertySheet(&psh) > 0)
1175 {
1176 if (SaveDesktopSettings(&pData->desktopData))
1177 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1178 }
1179}
1180
1181
1184 UINT uMsg,
1185 WPARAM wParam,
1186 LPARAM lParam)
1187{
1189 struct GdiplusStartupInput gdipStartup;
1190
1192
1193 switch (uMsg)
1194 {
1195 case WM_INITDIALOG:
1198 gdipStartup.GdiplusVersion = 1;
1199 gdipStartup.DebugEventCallback = NULL;
1200 gdipStartup.SuppressBackgroundThread = FALSE;
1201 gdipStartup.SuppressExternalCodecs = FALSE;
1202 GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1203 InitBackgroundDialog(hwndDlg, pData);
1204 InitDesktopSettings(&pData->desktopData);
1205 break;
1206
1207 case WM_COMMAND:
1208 {
1209 DWORD controlId = LOWORD(wParam);
1211
1212 switch (controlId)
1213 {
1214 case IDC_COLOR_BUTTON:
1215 if (command == BN_CLICKED)
1216 OnColorButton(hwndDlg, pData);
1217 break;
1218
1219 case IDC_BROWSE_BUTTON:
1220 if (command == BN_CLICKED)
1221 OnBrowseButton(hwndDlg, pData);
1222 break;
1223
1225 if (command == CBN_SELCHANGE)
1226 {
1227 pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1228
1230
1231 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1232 }
1233 break;
1234
1235 case IDC_DESKTOP_CUSTOM:
1236 if (command == BN_CLICKED)
1237 OnCustomButton(hwndDlg, pData);
1238 break;
1239 }
1240 } break;
1241
1242 case WM_DRAWITEM:
1243 {
1245
1246 if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1247 DrawBackgroundPreview(drawItem, pData);
1248 }
1249 break;
1250
1251 case WM_NOTIFY:
1252 {
1253 LPNMHDR lpnm = (LPNMHDR)lParam;
1254
1255 switch(lpnm->code)
1256 {
1257 case PSN_APPLY:
1258 if (pData->bWallpaperChanged)
1260 if (pData->bClrBackgroundChanged)
1261 SetDesktopBackColor(hwndDlg, pData);
1262 if (pData->desktopData.bSettingsChanged)
1263 SetDesktopSettings(&pData->desktopData);
1265 return TRUE;
1266
1267 case LVN_ITEMCHANGED:
1268 {
1270
1271 if ((nm->uNewState & LVIS_SELECTED) == 0)
1272 return FALSE;
1273
1274 ListViewItemChanged(hwndDlg, pData, nm->iItem);
1275 }
1276 break;
1277
1278 case NM_CUSTOMDRAW:
1279 if (lpnm->idFrom == IDC_COLOR_BUTTON)
1280 {
1281 return SetDlgMsgResult(hwndDlg, 0, ClrBtn_CustomDraw((NMCUSTOMDRAW*)lpnm,
1283 }
1284 break;
1285 }
1286 }
1287 break;
1288
1289 case WM_DESTROY:
1290 if (pData->pWallpaperBitmap != NULL)
1291 DibFreeImage(pData->pWallpaperBitmap);
1292
1293 GdiplusShutdown(pData->gdipToken);
1295 break;
1296 }
1297
1298 return FALSE;
1299}
static HDC hDC
Definition: 3dtext.c:33
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:613
PLACEMENT
Definition: background.c:20
@ PLACEMENT_STRETCH
Definition: background.c:22
@ PLACEMENT_TILE
Definition: background.c:23
@ PLACEMENT_FIT
Definition: background.c:24
@ PLACEMENT_FILL
Definition: background.c:25
@ PLACEMENT_CENTER
Definition: background.c:21
#define IDI_SHELL_NO
static VOID InitBackgroundDialog(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:454
struct _BACKGROUND_DATA * PBACKGROUND_DATA
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:993
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:281
struct _BACKGROUND_DATA BACKGROUND_DATA
HRESULT GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
Definition: background.c:75
PLACEMENT_VALUE
Definition: background.c:33
@ PLACEMENT_VALUE_FILL
Definition: background.c:38
@ PLACEMENT_VALUE_CENTER
Definition: background.c:34
@ PLACEMENT_VALUE_FIT
Definition: background.c:37
@ PLACEMENT_VALUE_STRETCH
Definition: background.c:35
@ PLACEMENT_VALUE_TILE
Definition: background.c:36
static UINT AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
Definition: background.c:176
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:782
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:595
#define MAX_BACKGROUNDS
Definition: background.c:17
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:116
INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: background.c:1183
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:528
static VOID ListViewItemChanged(HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
Definition: background.c:748
GLOBAL_DATA g_GlobalData
Definition: background.c:71
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1117
static VOID OnCustomButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1150
#define IDS_NONE
Definition: resource.h:144
#define RegCloseKey(hKey)
Definition: registry.h:49
HIMAGELIST himl
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define OFN_EXPLORER
Definition: commdlg.h:104
CHOOSECOLORA CHOOSECOLOR
Definition: commdlg.h:654
#define CC_RGBINIT
Definition: commdlg.h:50
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define ChooseColor
Definition: commdlg.h:661
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define CC_FULLOPEN
Definition: commdlg.h:51
#define GetOpenFileName
Definition: commdlg.h:665
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define CC_ANYCOLOR
Definition: commdlg.h:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID InitDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:63
BOOL SaveDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:127
#define MONITOR_HEIGHT
Definition: desk.h:81
#define MONITOR_BOTTOM
Definition: desk.h:78
#define MONITOR_LEFT
Definition: desk.h:75
INT_PTR CALLBACK DesktopPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define MONITOR_ALPHA
Definition: desk.h:83
VOID SetDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:181
UINT ClrBtn_CustomDraw(NMCUSTOMDRAW *pCD, COLORREF Color)
Definition: misc.c:83
#define MONITOR_TOP
Definition: desk.h:76
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
#define MONITOR_WIDTH
Definition: desk.h:80
PDIBITMAP DibLoadImage(LPTSTR lpFilename)
Definition: dibitmap.c:13
#define MONITOR_RIGHT
Definition: desk.h:77
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HINSTANCE hApplet
Definition: access.c:17
#define IDC_BACKGROUND_LIST
Definition: resource.h:28
#define IDS_TILE
Definition: resource.h:60
#define IDS_STRETCH
Definition: resource.h:59
#define IDD_DESKTOP_GENERAL
Definition: resource.h:17
#define IDC_COLOR_BUTTON
Definition: resource.h:32
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:30
#define IDS_BACKGROUND_COMDLG_FILTER
Definition: resource.h:34
#define IDC_DESKTOP_CUSTOM
Definition: resource.h:36
#define IDS_DESKTOP_ITEMS
Definition: resource.h:184
#define IDC_PLACEMENT_COMBO
Definition: resource.h:33
#define IDS_CENTER
Definition: resource.h:58
#define IDS_FIT
Definition: resource.h:61
#define IDS_FILL
Definition: resource.h:62
#define IDC_BROWSE_BUTTON
Definition: resource.h:31
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
#define GetProcessHeap()
Definition: compat.h:736
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
Definition: image.c:2354
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:5049
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4998
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
Definition: image.c:4476
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155
GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR *filename, GpImage **image)
Definition: image.c:2976
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5073
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:5022
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2716
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define GetBValue(quad)
Definition: precomp.h:71
#define GetGValue(quad)
Definition: precomp.h:70
#define GetRValue(quad)
Definition: precomp.h:69
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
pKey DeleteObject()
size_t bufferSize
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
void WINAPI GdiplusShutdown(ULONG_PTR)
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
GLclampf green
Definition: gl.h:1740
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLeglImageOES image
Definition: gl.h:2204
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLclampf GLclampf blue
Definition: gl.h:1740
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define _tcstok
Definition: tchar.h:1416
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
uint32_t cc
Definition: isohybrid.c:75
#define TEXT(s)
Definition: k32.h:28
#define c
Definition: ke_i.h:80
#define REG_SZ
Definition: layer.c:22
#define red
Definition: linetest.c:67
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
#define _tcsrchr
Definition: utility.h:116
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static float(__cdecl *square_half_float)(float x
static HMODULE hShell32
Definition: string.c:34
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
unsigned int UINT
Definition: ndis.h:50
_Out_ LPWSTR lpBuffer
Definition: netsh.h:68
#define REG_BINARY
Definition: nt_native.h:1499
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_SET_VALUE
Definition: nt_native.h:1020
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define PathCombine
Definition: pathcch.h:316
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_DEFAULT
Definition: prsht.h:22
#define PSN_APPLY
Definition: prsht.h:117
#define PropertySheet
Definition: prsht.h:400
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
#define PROPSHEETPAGE
Definition: prsht.h:389
#define LVSIL_SMALL
Definition: commctrl.h:2304
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2413
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2678
#define LVFINDINFO
Definition: commctrl.h:2468
#define LVFI_STRING
Definition: commctrl.h:2442
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2641
#define LVIF_STATE
Definition: commctrl.h:2317
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2309
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2301
_Out_opt_ int * cx
Definition: commctrl.h:585
#define ILC_COLOR32
Definition: commctrl.h:358
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define LVIF_PARAM
Definition: commctrl.h:2316
#define LV_ITEM
Definition: commctrl.h:2342
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVIF_TEXT
Definition: commctrl.h:2314
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define ILC_MASK
Definition: commctrl.h:351
#define LVIF_IMAGE
Definition: commctrl.h:2315
#define LVN_ITEMCHANGED
Definition: commctrl.h:3136
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2475
#define LV_COLUMN
Definition: commctrl.h:2552
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define PathRemoveExtension
Definition: shlwapi.h:503
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
#define SHRegGetPath
Definition: shlwapi.h:846
#define WM_NOTIFY
Definition: richedit.h:61
static int fd
Definition: io.c:51
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:430
#define SHGetFileInfo
Definition: shellapi.h:736
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
#define SHGFI_ICON
Definition: shellapi.h:164
#define SHGFI_SMALLICON
Definition: shellapi.h:176
#define CSIDL_FLAG_CREATE
HRESULT hr
Definition: shlfolder.c:183
#define SHGetFolderPath
Definition: shlobj.h:2179
#define CSIDL_MYPICTURES
Definition: shlobj.h:2219
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2208
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define StringCbCat
Definition: strsafe.h:334
#define StringCbPrintfEx
Definition: strsafe.h:600
#define StringCbCopy
Definition: strsafe.h:155
#define StringCchLength
Definition: strsafe.h:829
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define StringCbPrintf
Definition: strsafe.h:544
TCHAR szFilename[MAX_PATH]
Definition: background.c:45
TCHAR szDisplayName[256]
Definition: background.c:46
BOOL SuppressBackgroundThread
Definition: gdiplusinit.h:36
DebugEventProc DebugEventCallback
Definition: gdiplusinit.h:35
BOOL bClrBackgroundChanged
Definition: background.c:53
DESKTOP_DATA desktopData
Definition: background.c:68
int placementSelection
Definition: background.c:59
int backgroundSelection
Definition: background.c:60
BOOL bWallpaperChanged
Definition: background.c:52
COLORREF custom_colors[16]
Definition: background.c:62
PDIBITMAP pWallpaperBitmap
Definition: background.c:57
BackgroundItem backgroundItems[MAX_BACKGROUNDS]
Definition: background.c:55
ULONG_PTR gdipToken
Definition: background.c:66
Definition: desk.h:44
LONG bmMonHeight
Definition: desk.h:168
LONG bmMonWidth
Definition: desk.h:167
COLORREF desktop_color
Definition: desk.h:163
HBITMAP hMonitorBitmap
Definition: desk.h:166
HICON hIcon
Definition: shellapi.h:377
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:380
Definition: ps.c:97
UINT_PTR idFrom
Definition: winuser.h:3260
UINT code
Definition: winuser.h:3261
UINT uNewState
Definition: commctrl.h:3041
LPSTR lpstrFileTitle
Definition: commdlg.h:338
DWORD nFilterIndex
Definition: commdlg.h:335
HWND hwndOwner
Definition: commdlg.h:330
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define HIWORD(l)
Definition: typedefs.h:247
BOOL WINAPI GdiTransparentBlt(HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, UINT crTransparent)
#define _T(x)
Definition: vfdio.h:22
#define success(from, fromstr, to, tostr)
#define GetWindowsDirectory
Definition: winbase.h:3606
#define ExpandEnvironmentStrings
Definition: winbase.h:3523
#define FindNextFile
Definition: winbase.h:3537
#define FindFirstFile
Definition: winbase.h:3531
DWORD COLORREF
Definition: windef.h:100
#define SetDlgMsgResult(hwnd, msg, result)
Definition: windowsx.h:518
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define COLORONCOLOR
Definition: wingdi.h:954
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1373
int WINAPI StretchDIBits(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ const VOID *, _In_ const BITMAPINFO *, _In_ UINT, _In_ DWORD)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegOpenKeyEx
Definition: winreg.h:552
#define RegSetValueEx
Definition: winreg.h:565
#define RegCreateKeyEx
Definition: winreg.h:532
#define RegQueryValueEx
Definition: winreg.h:556
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define DWLP_USER
Definition: winuser.h:883
#define SM_CYSCREEN
Definition: winuser.h:971
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1380
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_VSCROLL
Definition: winuser.h:1772
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define SM_CXVSCROLL
Definition: winuser.h:972
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define HWND_BROADCAST
Definition: winuser.h:1215
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_COMMAND
Definition: winuser.h:1768
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2572
#define CB_SETCURSEL
Definition: winuser.h:1990
#define SM_CYSMICON
Definition: winuser.h:1024
#define WM_INITDIALOG
Definition: winuser.h:1767
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1673
#define CBN_SELCHANGE
Definition: winuser.h:2008
#define WM_SETTINGCHANGE
Definition: winuser.h:1657
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1599
#define SM_CXSMICON
Definition: winuser.h:1023
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5954
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
#define LoadString
Definition: winuser.h:5930
#define MessageBox
Definition: winuser.h:5933
#define MB_ICONSTOP
Definition: winuser.h:814
#define BN_CLICKED
Definition: winuser.h:1954
#define WM_DESTROY
Definition: winuser.h:1637
#define SM_CXSCREEN
Definition: winuser.h:970
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_INSERTSTRING
Definition: winuser.h:1986
#define SystemParametersInfo
Definition: winuser.h:5969
#define CB_GETCURSEL
Definition: winuser.h:1972
#define SendDlgItemMessage
Definition: winuser.h:5953
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BACKGROUND
Definition: winuser.h:924
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422
char TCHAR
Definition: xmlstorage.h:189
#define _ttoi
Definition: xmlstorage.h:195
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcslen
Definition: xmlstorage.h:198
#define _tcsicmp
Definition: xmlstorage.h:205
unsigned char BYTE
Definition: xxhash.c:193