ReactOS 0.4.16-dev-1165-g40721f4
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 SHGetFileInfoW(wallpaperFilename,
391 0,
392 &sfi,
393 sizeof(sfi),
396 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
397
398 i++;
399
400 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
401
402 backgroundItem->bWallpaper = TRUE;
403
404 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
405 if (FAILED(hr))
406 {
407 RegCloseKey(regKey);
408 return;
409 }
410
411 PathRemoveExtension(backgroundItem->szDisplayName);
412
413 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
414 if (FAILED(hr))
415 {
416 RegCloseKey(regKey);
417 return;
418 }
419
420 ZeroMemory(&listItem, sizeof(LV_ITEM));
421 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
422 listItem.state = 0;
423 listItem.pszText = backgroundItem->szDisplayName;
424 listItem.iImage = sfi.iIcon;
425 listItem.iItem = pData->listViewItemCount;
426 listItem.lParam = pData->listViewItemCount;
427
428 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
429 ListView_SetItemState(hwndBackgroundList,
430 pData->listViewItemCount,
433
434 pData->listViewItemCount++;
435 }
436
437 RegCloseKey(regKey);
438 }
439
440 /* Add all the images in the C:\ReactOS directory. */
441 if (GetWindowsDirectory(szSearchPath, MAX_PATH))
442 {
443 i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
444 }
445
446 /* Add all the images in the wallpaper directory. */
447 if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
448 {
449 i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
450 }
451}
452
453
454static VOID
456{
457 TCHAR szString[256];
458 HKEY regKey;
459 TCHAR szBuffer[3];
460 DWORD bufferSize = sizeof(szBuffer);
461
462 AddListViewItems(hwndDlg, pData);
463
464 LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
466
467 LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
469
470 LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
472
473 LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
475
476 LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
478
480 pData->placementSelection = PLACEMENT_CENTER;
481
482 /* Load the default settings from the registry */
483 if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
484 {
485 return;
486 }
487
488 if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
489 {
490 if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
491 {
493 pData->placementSelection = PLACEMENT_CENTER;
494 }
495
496 if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
497 {
499 pData->placementSelection = PLACEMENT_STRETCH;
500 }
501
502 if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
503 {
505 pData->placementSelection = PLACEMENT_FIT;
506 }
507
508 if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
509 {
511 pData->placementSelection = PLACEMENT_FILL;
512 }
513 }
514
515 if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
516 {
517 if (_ttoi(szBuffer) == 1)
518 {
520 pData->placementSelection = PLACEMENT_TILE;
521 }
522 }
523
524 RegCloseKey(regKey);
525}
526
527
528static VOID
530{
531 /* Load custom colors from Registry */
532 HKEY hKey = NULL;
535
536 res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
538 /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
539 if (res == ERROR_SUCCESS)
540 {
541 /* Key opened */
542 DWORD dwType = REG_BINARY;
543 DWORD cbData = sizeof(pData->custom_colors);
544 res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
545 (LPBYTE)pData->custom_colors, &cbData);
547 hKey = NULL;
548 }
549
550 /* Launch ChooseColor() dialog */
551
552 cc.lStructSize = sizeof(CHOOSECOLOR);
553 cc.hwndOwner = hwndDlg;
554 cc.hInstance = NULL;
555 cc.rgbResult = g_GlobalData.desktop_color;
556 cc.lpCustColors = pData->custom_colors;
557 cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
558 CC_FULLOPEN | /* opens dialog in full size */
559 CC_RGBINIT ; /* init chosen color by rgbResult value */
560 cc.lCustData = 0;
561 cc.lpfnHook = NULL;
562 cc.lpTemplateName = NULL;
563 if (ChooseColor(&cc))
564 {
565 /* Save selected color to var */
566 g_GlobalData.desktop_color = cc.rgbResult;
567 pData->bClrBackgroundChanged = TRUE;
568
569 /* Apply button will be activated */
570 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
571
572 /* Window will be updated :) */
575
576 /* Save custom colors to reg. To this moment key must be created already. See above */
577 res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
579 if (res == ERROR_SUCCESS)
580 {
581 /* Key opened */
582 RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
583 (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
585 hKey = NULL;
586 }
587 }
588}
589
590
591/*
592 * ListView_FindItem() Macro: Searches for a list-view item with the specified
593 * characteristics. Returns the index of the item if successful, or -1 otherwise
594 */
595static BOOL
597{
598 LVFINDINFO lvfi;
599 int retVal;
600
601 lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
602 lvfi.psz = tszFileName; /* String to search */
603
604 /* Other items of this structure are not valid, besacuse flags are not set. */
605 retVal = ListView_FindItem(hwndList, -1, &lvfi);
606 if (retVal != -1)
607 return TRUE; /* item found! */
608
609 return FALSE; /* item not found. */
610}
611
612
613static VOID
615{
618 TCHAR fileTitle[256];
619 TCHAR initialDir[MAX_PATH];
621 LPTSTR extensions;
622 BackgroundItem *backgroundItem = NULL;
623 SHFILEINFO sfi;
624 LV_ITEM listItem;
625 HWND hwndBackgroundList;
626 TCHAR *p;
627 HRESULT hr;
628 TCHAR filterdesc[MAX_PATH];
629 TCHAR *c;
630 size_t sizeRemain;
631 SIZE_T buffersize;
634
635 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
636 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
637 SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
638
639 ZeroMemory(&ofn, sizeof(OPENFILENAME));
640
641 ofn.lStructSize = sizeof(OPENFILENAME);
642 ofn.hwndOwner = hwndDlg;
644
645 LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
646
647 extensions = GdipGetSupportedFileExtensions();
648 if (!extensions)
649 {
650 return;
651 }
652
653 buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
654
656 if (!filter)
657 {
658 HeapFree(GetProcessHeap(), 0, extensions);
659 return;
660 }
661
662 sizeRemain = buffersize;
663 c = filter;
664
665 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
666 {
667 HeapFree(GetProcessHeap(), 0, extensions);
669 return;
670 }
671
672 c++;
673 sizeRemain -= sizeof(*c);
674
675 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
676 {
677 HeapFree(GetProcessHeap(), 0, extensions);
679 return;
680 }
681
682 HeapFree(GetProcessHeap(), 0, extensions);
683
684 /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
685 * use the contents of szFile to initialize itself */
686 ofn.lpstrFile[0] = TEXT('\0');
689 ofn.nFilterIndex = 0;
690 ofn.lpstrFileTitle = fileTitle;
691 ofn.nMaxFileTitle = 256;
692 ofn.lpstrInitialDir = initialDir;
694
697
698 if (success)
699 {
700 /* Check if there is already a entry that holds this filename */
701 if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
702 return;
703
704 if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
705 return;
706
708 0,
709 &sfi,
710 sizeof(sfi),
712 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
713
714 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
715
716 backgroundItem->bWallpaper = TRUE;
717
718 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
719 if (FAILED(hr))
720 return;
721 p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
722 if (p)
723 *p = (TCHAR)0;
724 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
725 if (FAILED(hr))
726 return;
727
728 ZeroMemory(&listItem, sizeof(LV_ITEM));
729 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
730 listItem.state = 0;
731 listItem.pszText = backgroundItem->szDisplayName;
732 listItem.iImage = sfi.iIcon;
733 listItem.iItem = pData->listViewItemCount;
734 listItem.lParam = pData->listViewItemCount;
735
736 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
737 ListView_SetItemState(hwndBackgroundList,
738 pData->listViewItemCount,
741 SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
742
743 pData->listViewItemCount++;
744 }
745}
746
747
748static VOID
750{
751 BackgroundItem *backgroundItem = NULL;
752
753 pData->backgroundSelection = itemIndex;
754 backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
755
756 if (pData->pWallpaperBitmap != NULL)
757 {
758 DibFreeImage(pData->pWallpaperBitmap);
759 pData->pWallpaperBitmap = NULL;
760 }
761
762 if (backgroundItem->bWallpaper != FALSE)
763 {
764 pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
765
766 if (pData->pWallpaperBitmap == NULL)
767 return;
768 }
769
770 pData->bWallpaperChanged = TRUE;
771
773 NULL, TRUE);
774
776 backgroundItem->bWallpaper);
777
778 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
779}
780
781
782static VOID
784{
785 float scaleX;
786 float scaleY;
787 int scaledWidth;
788 int scaledHeight;
789 int posX, desX;
790 int posY, desY;
791 int fitFillScaleNum, fitFillScaleDen;
792 int fitFillWidth, fitFillHeight;
793 HBRUSH hBrush;
794 int x;
795 int y;
796 HDC hDC;
797 HGDIOBJ hOldObj;
798 RECT rcItem = {
803 };
804
805 hDC = CreateCompatibleDC(draw->hDC);
807
808 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
809 {
810 /* Update desktop background color image */
812 FillRect(hDC, &rcItem, hBrush);
813 DeleteObject(hBrush);
814 }
815 else
816 if (pData->pWallpaperBitmap != NULL)
817 {
818 scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
819 scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
820
821 scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
822 scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
823
825
827
828 switch (pData->placementSelection)
829 {
830 case PLACEMENT_CENTER:
831 posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
832 posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
833 desX = 0;
834 desY = 0;
835
836 if (posX < 0) { desX = -posX / 2; posX = 0; }
837 if (posY < 0) { desY = -posY / 2; posY = 0; }
838
839 if (scaledWidth > MONITOR_WIDTH)
840 scaledWidth = MONITOR_WIDTH;
841
842 if (scaledHeight > MONITOR_HEIGHT)
843 scaledHeight = MONITOR_HEIGHT;
844
846 MONITOR_LEFT+posX,
847 MONITOR_TOP+posY,
848 scaledWidth,
849 scaledHeight,
850 desX,
851 desY,
852 pData->pWallpaperBitmap->width - (int)(desX * scaleX),
853 pData->pWallpaperBitmap->height - (int)(desY * scaleY),
854 pData->pWallpaperBitmap->bits,
855 pData->pWallpaperBitmap->info,
857 SRCCOPY);
858 break;
859
866 0,
867 0,
868 pData->pWallpaperBitmap->width,
869 pData->pWallpaperBitmap->height,
870 pData->pWallpaperBitmap->bits,
871 pData->pWallpaperBitmap->info,
873 SRCCOPY);
874 break;
875
876 case PLACEMENT_TILE:
877 for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
878 {
879 for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
880 {
881 if ((MONITOR_WIDTH-x) >= scaledWidth)
882 posX = scaledWidth;
883 else
884 posX = MONITOR_WIDTH-x;
885
886
887 if ((MONITOR_HEIGHT-y) >= scaledHeight)
888 posY = scaledHeight;
889 else
890 posY = MONITOR_HEIGHT-y;
891
893 MONITOR_LEFT + x,
894 MONITOR_TOP + y,
895 posX,
896 posY,
897 0,
898 0,
899 pData->pWallpaperBitmap->width * posX / scaledWidth,
900 pData->pWallpaperBitmap->height * posY / scaledHeight,
901 pData->pWallpaperBitmap->bits,
902 pData->pWallpaperBitmap->info,
904 SRCCOPY);
905 }
906
907 }
908
909 break;
910
911 case PLACEMENT_FIT:
912 if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
913 {
914 fitFillScaleNum = MONITOR_WIDTH;
915 fitFillScaleDen = scaledWidth;
916 }
917 else
918 {
919 fitFillScaleNum = MONITOR_HEIGHT;
920 fitFillScaleDen = scaledHeight;
921 }
922
923 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
924 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
925
926 posX = (MONITOR_WIDTH - fitFillWidth) / 2;
927 posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
928
930 MONITOR_LEFT + posX,
931 MONITOR_TOP + posY,
932 fitFillWidth,
933 fitFillHeight,
934 0,
935 0,
936 pData->pWallpaperBitmap->width,
937 pData->pWallpaperBitmap->height,
938 pData->pWallpaperBitmap->bits,
939 pData->pWallpaperBitmap->info,
941 SRCCOPY);
942 break;
943
944 case PLACEMENT_FILL:
945 if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
946 {
947 fitFillScaleNum = MONITOR_WIDTH;
948 fitFillScaleDen = scaledWidth;
949 }
950 else
951 {
952 fitFillScaleNum = MONITOR_HEIGHT;
953 fitFillScaleDen = scaledHeight;
954 }
955
956 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
957 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
958
959 desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
960 desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
961
967 desX,
968 desY,
969 (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
970 (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
971 pData->pWallpaperBitmap->bits,
972 pData->pWallpaperBitmap->info,
974 SRCCOPY);
975 break;
976 }
977 }
978
980 draw->rcItem.left, draw->rcItem.top,
981 draw->rcItem.right - draw->rcItem.left + 1,
982 draw->rcItem.bottom - draw->rcItem.top + 1,
983 hDC,
984 0, 0,
987
988 SelectObject(hDC, hOldObj);
989 DeleteDC(hDC);
990}
991
992
993static VOID
995{
996 HKEY regKey;
997 TCHAR szWallpaper[MAX_PATH];
998 GpImage *image;
999 CLSID encoderClsid;
1000 GUID guidFormat;
1001 size_t length = 0;
1003
1005 {
1006 return;
1007 }
1008
1009 if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1010 {
1011 return;
1012 }
1013
1014 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1016 {
1017 return;
1018 }
1019
1020 if (pData->placementSelection == PLACEMENT_TILE)
1021 {
1022 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1023 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1024 }
1025
1026 if (pData->placementSelection == PLACEMENT_CENTER)
1027 {
1028 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1029 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1030 }
1031
1032 if (pData->placementSelection == PLACEMENT_STRETCH)
1033 {
1034 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1035 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1036 }
1037
1038 if (pData->placementSelection == PLACEMENT_FIT)
1039 {
1040 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1041 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1042 }
1043
1044 if (pData->placementSelection == PLACEMENT_FILL)
1045 {
1046 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1047 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1048 }
1049
1050 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1051 {
1052 GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1053 if (!image)
1054 {
1055 RegCloseKey(regKey);
1056 return;
1057 }
1058
1059 GdipGetImageRawFormat(image, &guidFormat);
1060 if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1061 {
1063 RegCloseKey(regKey);
1064 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1065 return;
1066 }
1067
1068 if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1069 {
1071 RegCloseKey(regKey);
1072 return;
1073 }
1074
1075 status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1076
1078
1079 if (status != Ok)
1080 {
1081 RegCloseKey(regKey);
1082 return;
1083 }
1084
1085 if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1086 {
1087 RegSetValueEx(regKey,
1088 TEXT("ConvertedWallpaper"),
1089 0,
1090 REG_SZ,
1091 (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1092 (DWORD)((length + 1) * sizeof(TCHAR)));
1093 }
1094
1095 if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1096 {
1097 RegSetValueEx(regKey,
1098 TEXT("OriginalWallpaper"),
1099 0,
1100 REG_SZ,
1101 (LPBYTE)szWallpaper,
1102 (DWORD)((length + 1) * sizeof(TCHAR)));
1103 }
1104
1106 }
1107 else
1108 {
1110 }
1111
1112 RegCloseKey(regKey);
1113}
1114
1115
1116/* Change system color */
1117static VOID
1119{
1120 HKEY hKey;
1121 INT iElement = COLOR_BACKGROUND;
1122 TCHAR clText[16];
1123 BYTE red, green, blue;
1124
1125 if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1126 {
1127 /* FIXME: these error texts can need internationalization? */
1128 MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1129 TEXT("Error!"), MB_ICONSTOP );
1130 }
1131
1132 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1134 {
1135 return;
1136 }
1137
1141
1142 /* Format string to be set to registry */
1143 StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1144 RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1145 (wcslen(clText) + 1) * sizeof(TCHAR));
1146
1148}
1149
1150static VOID
1152{
1153 HPROPSHEETPAGE hpsp[1] = {0};
1154 PROPSHEETHEADER psh = {sizeof(psh)};
1155 PROPSHEETPAGE psp = {sizeof(psp)};
1156
1157 psh.dwFlags = PSH_NOAPPLYNOW;
1158 psh.hwndParent = GetParent(hwndDlg);
1159 psh.hInstance = hApplet;
1160 psh.pszCaption = MAKEINTRESOURCE(IDS_DESKTOP_ITEMS);
1161 psh.phpage = hpsp;
1162
1163 psp.dwFlags = PSP_DEFAULT;
1164 psp.hInstance = hApplet;
1165 psp.pszTemplate = MAKEINTRESOURCE(IDD_DESKTOP_GENERAL);
1166 psp.pfnDlgProc = DesktopPageProc;
1167 psp.lParam = (LPARAM)&pData->desktopData;
1168
1169 hpsp[0] = CreatePropertySheetPage(&psp);
1170 if (!hpsp[0])
1171 return;
1172
1173 psh.nPages++;
1174
1175 if (PropertySheet(&psh) > 0)
1176 {
1177 if (SaveDesktopSettings(&pData->desktopData))
1178 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1179 }
1180}
1181
1182
1185 UINT uMsg,
1186 WPARAM wParam,
1187 LPARAM lParam)
1188{
1190 struct GdiplusStartupInput gdipStartup;
1191
1193
1194 switch (uMsg)
1195 {
1196 case WM_INITDIALOG:
1199 gdipStartup.GdiplusVersion = 1;
1200 gdipStartup.DebugEventCallback = NULL;
1201 gdipStartup.SuppressBackgroundThread = FALSE;
1202 gdipStartup.SuppressExternalCodecs = FALSE;
1203 GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1204 InitBackgroundDialog(hwndDlg, pData);
1205 InitDesktopSettings(&pData->desktopData);
1206 break;
1207
1208 case WM_COMMAND:
1209 {
1210 DWORD controlId = LOWORD(wParam);
1212
1213 switch (controlId)
1214 {
1215 case IDC_COLOR_BUTTON:
1216 if (command == BN_CLICKED)
1217 OnColorButton(hwndDlg, pData);
1218 break;
1219
1220 case IDC_BROWSE_BUTTON:
1221 if (command == BN_CLICKED)
1222 OnBrowseButton(hwndDlg, pData);
1223 break;
1224
1226 if (command == CBN_SELCHANGE)
1227 {
1228 pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1229
1231
1232 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1233 }
1234 break;
1235
1236 case IDC_DESKTOP_CUSTOM:
1237 if (command == BN_CLICKED)
1238 OnCustomButton(hwndDlg, pData);
1239 break;
1240 }
1241 } break;
1242
1243 case WM_DRAWITEM:
1244 {
1246
1247 if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1248 DrawBackgroundPreview(drawItem, pData);
1249 }
1250 break;
1251
1252 case WM_NOTIFY:
1253 {
1254 LPNMHDR lpnm = (LPNMHDR)lParam;
1255
1256 switch(lpnm->code)
1257 {
1258 case PSN_APPLY:
1259 if (pData->bWallpaperChanged)
1261 if (pData->bClrBackgroundChanged)
1262 SetDesktopBackColor(hwndDlg, pData);
1263 if (pData->desktopData.bSettingsChanged)
1264 SetDesktopSettings(&pData->desktopData);
1266 return TRUE;
1267
1268 case LVN_ITEMCHANGED:
1269 {
1271
1272 if ((nm->uNewState & LVIS_SELECTED) == 0)
1273 return FALSE;
1274
1275 ListViewItemChanged(hwndDlg, pData, nm->iItem);
1276 }
1277 break;
1278
1279 case NM_CUSTOMDRAW:
1280 if (lpnm->idFrom == IDC_COLOR_BUTTON)
1281 {
1282 return SetDlgMsgResult(hwndDlg, 0, ClrBtn_CustomDraw((NMCUSTOMDRAW*)lpnm,
1284 }
1285 break;
1286 }
1287 }
1288 break;
1289
1290 case WM_DESTROY:
1291 if (pData->pWallpaperBitmap != NULL)
1292 DibFreeImage(pData->pWallpaperBitmap);
1293
1294 GdiplusShutdown(pData->gdipToken);
1296 break;
1297 }
1298
1299 return FALSE;
1300}
static HDC hDC
Definition: 3dtext.c:33
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:614
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:455
struct _BACKGROUND_DATA * PBACKGROUND_DATA
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:994
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:783
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:596
#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:1184
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:529
static VOID ListViewItemChanged(HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
Definition: background.c:749
GLOBAL_DATA g_GlobalData
Definition: background.c:71
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1118
static VOID OnCustomButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1151
#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
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#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:4262
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:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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:26
#define c
Definition: ke_i.h:80
#define REG_SZ
Definition: layer.c:22
#define red
Definition: linetest.c:67
#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
#define REG_BINARY
Definition: nt_native.h:1496
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#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 WM_NOTIFY
Definition: richedit.h:61
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
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:737
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:167
#define SHGFI_ICON
Definition: shellapi.h:165
#define SHGFI_SMALLICON
Definition: shellapi.h:177
#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
#define PathRemoveExtension
Definition: shlwapi.h:1066
#define PathCombine
Definition: shlwapi.h:860
#define SHRegGetPath
Definition: shlwapi.h:205
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:378
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:381
Definition: ps.c:97
UINT_PTR idFrom
Definition: winuser.h:3169
UINT code
Definition: winuser.h:3170
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:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#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:3889
#define ZeroMemory
Definition: winbase.h:1744
#define ExpandEnvironmentStrings
Definition: winbase.h:3806
#define FindNextFile
Definition: winbase.h:3820
#define FindFirstFile
Definition: winbase.h:3814
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300
#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:520
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegQueryValueEx
Definition: winreg.h:524
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:1755
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:1751
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:2540
#define CB_SETCURSEL
Definition: winuser.h:1972
#define SM_CYSMICON
Definition: winuser.h:1024
#define WM_INITDIALOG
Definition: winuser.h:1750
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1656
#define CBN_SELCHANGE
Definition: winuser.h:1990
#define WM_SETTINGCHANGE
Definition: winuser.h:1640
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1582
#define SM_CXSMICON
Definition: winuser.h:1023
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5863
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
#define LoadString
Definition: winuser.h:5839
#define MessageBox
Definition: winuser.h:5842
#define MB_ICONSTOP
Definition: winuser.h:814
#define BN_CLICKED
Definition: winuser.h:1936
#define WM_DESTROY
Definition: winuser.h:1620
#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:1968
#define SystemParametersInfo
Definition: winuser.h:5878
#define CB_GETCURSEL
Definition: winuser.h:1954
#define SendDlgItemMessage
Definition: winuser.h:5862
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BACKGROUND
Definition: winuser.h:924
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