ReactOS 0.4.16-dev-980-g00983aa
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
16#define MAX_BACKGROUNDS 100
17
18typedef enum
19{
26
27/* The tile placement is stored in different registry
28 * key, but due to a condition in win32k it needs to be
29 * zero when stored in the same key as others.
30 */
31typedef enum
32{
39
40typedef struct
41{
42 BOOL bWallpaper; /* Is this background a wallpaper */
43
44 TCHAR szFilename[MAX_PATH];
45 TCHAR szDisplayName[256];
46
48
49typedef struct _BACKGROUND_DATA
50{
53
55
57
60
62
64
66
69
71
72
75{
76 UINT num;
77 UINT size;
78 UINT i;
79 ImageCodecInfo *codecInfo;
80
82 size == 0)
83 {
84 return E_FAIL;
85 }
86
87 codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
88 if (!codecInfo)
89 {
90 return E_OUTOFMEMORY;
91 }
92
93 if (GdipGetImageEncoders(num, size, codecInfo) != Ok)
94 {
95 HeapFree(GetProcessHeap(), 0, codecInfo);
96 return E_FAIL;
97 }
98
99 for (i = 0; i < num; i++)
100 {
101 if (!_wcsicmp(codecInfo[i].MimeType, MimeType))
102 {
103 *pClsid = codecInfo[i].Clsid;
104 HeapFree(GetProcessHeap(), 0, codecInfo);
105 return S_OK;
106 }
107 }
108
109 HeapFree(GetProcessHeap(), 0, codecInfo);
110 return E_FAIL;
111}
112
113
114LPWSTR
116{
117 ImageCodecInfo *codecInfo;
118 UINT num;
119 UINT size;
120 UINT i;
122
123 if (GdipGetImageDecodersSize(&num, &size) != Ok ||
124 size == 0)
125 {
126 return NULL;
127 }
128
129 codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
130 if (!codecInfo)
131 {
132 return NULL;
133 }
134
135 if (GdipGetImageDecoders(num, size, codecInfo) != Ok)
136 {
137 HeapFree(GetProcessHeap(), 0, codecInfo);
138 return NULL;
139 }
140
141 size = 0;
142 for (i = 0; i < num; ++i)
143 {
144 size = size + (UINT)wcslen(codecInfo[i].FilenameExtension) + 1;
145 }
146
147 size = (size + 1) * sizeof(WCHAR);
148
150 if (!lpBuffer)
151 {
152 HeapFree(GetProcessHeap(), 0, codecInfo);
153 return NULL;
154 }
155
156 for (i = 0; i < num; ++i)
157 {
158 if (!lstrcmpiW(codecInfo[i].FilenameExtension, L"*.ico"))
159 continue;
160
161 StringCbCatW(lpBuffer, size, codecInfo[i].FilenameExtension);
162 if (i < (num - 1))
163 {
165 }
166 }
167
168 HeapFree(GetProcessHeap(), 0, codecInfo);
169
170 return lpBuffer;
171}
172
173
174static UINT
175AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
176{
178 HANDLE hFind;
179 TCHAR szSearchPath[MAX_PATH];
180 LPTSTR szFileTypes = NULL;
181 TCHAR separators[] = TEXT(";");
182 TCHAR *token;
183 HRESULT hr;
184 SHFILEINFO sfi;
185 UINT i = uCounter;
186 LV_ITEM listItem;
188
189 szFileTypes = GdipGetSupportedFileExtensions();
190 if (!szFileTypes)
191 {
192 return i;
193 }
194
195 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
196
197 token = _tcstok(szFileTypes, separators);
198 while (token != NULL)
199 {
200 if (!PathCombine(szSearchPath, wallpaperDirectory, token))
201 {
202 HeapFree(GetProcessHeap(), 0, szFileTypes);
203 return i;
204 }
205
206 hFind = FindFirstFile(szSearchPath, &fd);
207 while (hFind != INVALID_HANDLE_VALUE)
208 {
210
211 if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
212 {
213 FindClose(hFind);
214 HeapFree(GetProcessHeap(), 0, szFileTypes);
215 return i;
216 }
217
218 /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
219 if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
220 {
222 0,
223 &sfi,
224 sizeof(sfi),
226 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
227 i++;
228
229 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
230
231 backgroundItem->bWallpaper = TRUE;
232
233 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
234 if (FAILED(hr))
235 {
236 FindClose(hFind);
237 HeapFree(GetProcessHeap(), 0, szFileTypes);
238 return i;
239 }
240
241 PathRemoveExtension(backgroundItem->szDisplayName);
242
243 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
244 if (FAILED(hr))
245 {
246 FindClose(hFind);
247 HeapFree(GetProcessHeap(), 0, szFileTypes);
248 return i;
249 }
250
251 ZeroMemory(&listItem, sizeof(LV_ITEM));
252 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
253 listItem.pszText = backgroundItem->szDisplayName;
254 listItem.state = 0;
255 listItem.iImage = sfi.iIcon;
256 listItem.iItem = pData->listViewItemCount;
257 listItem.lParam = pData->listViewItemCount;
258
259 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
260
261 pData->listViewItemCount++;
262 }
263
264 if (!FindNextFile(hFind, &fd))
265 break;
266 }
267
268 token = _tcstok(NULL, separators);
269 FindClose(hFind);
270 }
271
272 HeapFree(GetProcessHeap(), 0, szFileTypes);
273
274 return i;
275}
276
277
278/* Add the images in the C:\ReactOS, the wallpaper directory and the current wallpaper if any */
279static VOID
281{
282 TCHAR szSearchPath[MAX_PATH];
283 LV_ITEM listItem;
285 RECT clientRect;
286 HKEY regKey;
287 SHFILEINFO sfi;
289 TCHAR wallpaperFilename[MAX_PATH];
290 TCHAR originalWallpaper[MAX_PATH];
291 DWORD bufferSize = sizeof(wallpaperFilename);
293 DWORD varType = REG_SZ;
294 LONG result;
295 UINT i = 0;
296 BackgroundItem *backgroundItem = NULL;
297 HWND hwndBackgroundList;
298 HRESULT hr;
299 HICON hIcon;
300 INT cx, cy;
302
303 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
304
305 GetClientRect(hwndBackgroundList, &clientRect);
306
310
311 /* Load (None) icon */
312#define IDI_SHELL_NO 200
313 hShell32 = GetModuleHandleW(L"shell32.dll");
315#undef IDI_SHELL_NO
316
317 ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
318
319 /* Add a new column to the list */
320 ZeroMemory(&dummy, sizeof(LV_COLUMN));
322 dummy.iSubItem = 0;
323 dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
324 (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
325
326 /* Add the "None" item */
327 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
328 backgroundItem->bWallpaper = FALSE;
330 IDS_NONE,
331 backgroundItem->szDisplayName,
332 sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
333
334 ZeroMemory(&listItem, sizeof(LV_ITEM));
335 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
336 listItem.state = 0;
337 listItem.pszText = backgroundItem->szDisplayName;
338 listItem.iImage = ImageList_AddIcon(himl, hIcon);
339 listItem.iItem = pData->listViewItemCount;
340 listItem.lParam = pData->listViewItemCount;
341 hIcon = NULL;
342
343 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
344 ListView_SetItemState(hwndBackgroundList,
345 pData->listViewItemCount,
348
349 pData->listViewItemCount++;
350
351 /* Add current wallpaper if any */
352 result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
353 if (result == ERROR_SUCCESS)
354 {
355 result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
356 if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
357 {
358 bufferSize = sizeof(originalWallpaper);
359 result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
360
361 /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
362 if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
363 {
364 bufferSize = sizeof(originalWallpaper);
365 result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
366
367 if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
368 {
369 hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
370 if (FAILED(hr))
371 {
372 RegCloseKey(regKey);
373 return;
374 }
375 }
376 }
377
378 /* Allow environment variables in file name */
379 if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
380 {
381 hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
382 if (FAILED(hr))
383 {
384 RegCloseKey(regKey);
385 return;
386 }
387 }
388
389 SHGetFileInfoW(wallpaperFilename,
390 0,
391 &sfi,
392 sizeof(sfi),
395 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
396
397 i++;
398
399 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
400
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(LV_ITEM));
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
427 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
428 ListView_SetItemState(hwndBackgroundList,
429 pData->listViewItemCount,
432
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 :) */
573
574 /* Save custom colors to reg. To this moment key must be created already. See above */
575 res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
577 if (res == ERROR_SUCCESS)
578 {
579 /* Key opened */
580 RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
581 (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
583 hKey = NULL;
584 }
585 }
586}
587
588
589/*
590 * ListView_FindItem() Macro: Searches for a list-view item with the specified
591 * characteristics. Returns the index of the item if successful, or -1 otherwise
592 */
593static BOOL
595{
596 LVFINDINFO lvfi;
597 int retVal;
598
599 lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
600 lvfi.psz = tszFileName; /* String to search */
601
602 /* Other items of this structure are not valid, besacuse flags are not set. */
603 retVal = ListView_FindItem(hwndList, -1, &lvfi);
604 if (retVal != -1)
605 return TRUE; /* item found! */
606
607 return FALSE; /* item not found. */
608}
609
610
611static VOID
613{
616 TCHAR fileTitle[256];
617 TCHAR initialDir[MAX_PATH];
619 LPTSTR extensions;
620 BackgroundItem *backgroundItem = NULL;
621 SHFILEINFO sfi;
622 LV_ITEM listItem;
623 HWND hwndBackgroundList;
624 TCHAR *p;
625 HRESULT hr;
626 TCHAR filterdesc[MAX_PATH];
627 TCHAR *c;
628 size_t sizeRemain;
629 SIZE_T buffersize;
632
633 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
634 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
635 SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
636
637 ZeroMemory(&ofn, sizeof(OPENFILENAME));
638
639 ofn.lStructSize = sizeof(OPENFILENAME);
640 ofn.hwndOwner = hwndDlg;
642
643 LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
644
645 extensions = GdipGetSupportedFileExtensions();
646 if (!extensions)
647 {
648 return;
649 }
650
651 buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
652
654 if (!filter)
655 {
656 HeapFree(GetProcessHeap(), 0, extensions);
657 return;
658 }
659
660 sizeRemain = buffersize;
661 c = filter;
662
663 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
664 {
665 HeapFree(GetProcessHeap(), 0, extensions);
667 return;
668 }
669
670 c++;
671 sizeRemain -= sizeof(*c);
672
673 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
674 {
675 HeapFree(GetProcessHeap(), 0, extensions);
677 return;
678 }
679
680 HeapFree(GetProcessHeap(), 0, extensions);
681
682 /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
683 * use the contents of szFile to initialize itself */
684 ofn.lpstrFile[0] = TEXT('\0');
687 ofn.nFilterIndex = 0;
688 ofn.lpstrFileTitle = fileTitle;
689 ofn.nMaxFileTitle = 256;
690 ofn.lpstrInitialDir = initialDir;
692
695
696 if (success)
697 {
698 /* Check if there is already a entry that holds this filename */
699 if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
700 return;
701
702 if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
703 return;
704
706 0,
707 &sfi,
708 sizeof(sfi),
710 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
711
712 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
713
714 backgroundItem->bWallpaper = TRUE;
715
716 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
717 if (FAILED(hr))
718 return;
719 p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
720 if (p)
721 *p = (TCHAR)0;
722 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
723 if (FAILED(hr))
724 return;
725
726 ZeroMemory(&listItem, sizeof(LV_ITEM));
727 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
728 listItem.state = 0;
729 listItem.pszText = backgroundItem->szDisplayName;
730 listItem.iImage = sfi.iIcon;
731 listItem.iItem = pData->listViewItemCount;
732 listItem.lParam = pData->listViewItemCount;
733
734 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
735 ListView_SetItemState(hwndBackgroundList,
736 pData->listViewItemCount,
739 SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
740
741 pData->listViewItemCount++;
742 }
743}
744
745
746static VOID
748{
749 BackgroundItem *backgroundItem = NULL;
750
751 pData->backgroundSelection = itemIndex;
752 backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
753
754 if (pData->pWallpaperBitmap != NULL)
755 {
756 DibFreeImage(pData->pWallpaperBitmap);
757 pData->pWallpaperBitmap = NULL;
758 }
759
760 if (backgroundItem->bWallpaper != FALSE)
761 {
762 pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
763
764 if (pData->pWallpaperBitmap == NULL)
765 return;
766 }
767
768 pData->bWallpaperChanged = TRUE;
769
771 NULL, TRUE);
772
774 backgroundItem->bWallpaper);
775
776 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
777}
778
779
780static VOID
782{
783 float scaleX;
784 float scaleY;
785 int scaledWidth;
786 int scaledHeight;
787 int posX, desX;
788 int posY, desY;
789 int fitFillScaleNum, fitFillScaleDen;
790 int fitFillWidth, fitFillHeight;
791 HBRUSH hBrush;
792 int x;
793 int y;
794 HDC hDC;
795 HGDIOBJ hOldObj;
796 RECT rcItem = {
801 };
802
803 hDC = CreateCompatibleDC(draw->hDC);
805
806 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
807 {
808 /* Update desktop background color image */
810 FillRect(hDC, &rcItem, hBrush);
811 DeleteObject(hBrush);
812 }
813 else
814 if (pData->pWallpaperBitmap != NULL)
815 {
816 scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
817 scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
818
819 scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
820 scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
821
823
825
826 switch (pData->placementSelection)
827 {
828 case PLACEMENT_CENTER:
829 posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
830 posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
831 desX = 0;
832 desY = 0;
833
834 if (posX < 0) { desX = -posX / 2; posX = 0; }
835 if (posY < 0) { desY = -posY / 2; posY = 0; }
836
837 if (scaledWidth > MONITOR_WIDTH)
838 scaledWidth = MONITOR_WIDTH;
839
840 if (scaledHeight > MONITOR_HEIGHT)
841 scaledHeight = MONITOR_HEIGHT;
842
844 MONITOR_LEFT+posX,
845 MONITOR_TOP+posY,
846 scaledWidth,
847 scaledHeight,
848 desX,
849 desY,
850 pData->pWallpaperBitmap->width - (int)(desX * scaleX),
851 pData->pWallpaperBitmap->height - (int)(desY * scaleY),
852 pData->pWallpaperBitmap->bits,
853 pData->pWallpaperBitmap->info,
855 SRCCOPY);
856 break;
857
864 0,
865 0,
866 pData->pWallpaperBitmap->width,
867 pData->pWallpaperBitmap->height,
868 pData->pWallpaperBitmap->bits,
869 pData->pWallpaperBitmap->info,
871 SRCCOPY);
872 break;
873
874 case PLACEMENT_TILE:
875 for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
876 {
877 for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
878 {
879 if ((MONITOR_WIDTH-x) >= scaledWidth)
880 posX = scaledWidth;
881 else
882 posX = MONITOR_WIDTH-x;
883
884
885 if ((MONITOR_HEIGHT-y) >= scaledHeight)
886 posY = scaledHeight;
887 else
888 posY = MONITOR_HEIGHT-y;
889
891 MONITOR_LEFT + x,
892 MONITOR_TOP + y,
893 posX,
894 posY,
895 0,
896 0,
897 pData->pWallpaperBitmap->width * posX / scaledWidth,
898 pData->pWallpaperBitmap->height * posY / scaledHeight,
899 pData->pWallpaperBitmap->bits,
900 pData->pWallpaperBitmap->info,
902 SRCCOPY);
903 }
904
905 }
906
907 break;
908
909 case PLACEMENT_FIT:
910 if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
911 {
912 fitFillScaleNum = MONITOR_WIDTH;
913 fitFillScaleDen = scaledWidth;
914 }
915 else
916 {
917 fitFillScaleNum = MONITOR_HEIGHT;
918 fitFillScaleDen = scaledHeight;
919 }
920
921 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
922 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
923
924 posX = (MONITOR_WIDTH - fitFillWidth) / 2;
925 posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
926
928 MONITOR_LEFT + posX,
929 MONITOR_TOP + posY,
930 fitFillWidth,
931 fitFillHeight,
932 0,
933 0,
934 pData->pWallpaperBitmap->width,
935 pData->pWallpaperBitmap->height,
936 pData->pWallpaperBitmap->bits,
937 pData->pWallpaperBitmap->info,
939 SRCCOPY);
940 break;
941
942 case PLACEMENT_FILL:
943 if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
944 {
945 fitFillScaleNum = MONITOR_WIDTH;
946 fitFillScaleDen = scaledWidth;
947 }
948 else
949 {
950 fitFillScaleNum = MONITOR_HEIGHT;
951 fitFillScaleDen = scaledHeight;
952 }
953
954 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
955 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
956
957 desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
958 desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
959
965 desX,
966 desY,
967 (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
968 (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
969 pData->pWallpaperBitmap->bits,
970 pData->pWallpaperBitmap->info,
972 SRCCOPY);
973 break;
974 }
975 }
976
978 draw->rcItem.left, draw->rcItem.top,
979 draw->rcItem.right - draw->rcItem.left + 1,
980 draw->rcItem.bottom - draw->rcItem.top + 1,
981 hDC,
982 0, 0,
985
986 SelectObject(hDC, hOldObj);
987 DeleteDC(hDC);
988}
989
990
991static VOID
993{
994 HKEY regKey;
995 TCHAR szWallpaper[MAX_PATH];
996 GpImage *image;
997 CLSID encoderClsid;
998 GUID guidFormat;
999 size_t length = 0;
1001
1003 {
1004 return;
1005 }
1006
1007 if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1008 {
1009 return;
1010 }
1011
1012 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1014 {
1015 return;
1016 }
1017
1018 if (pData->placementSelection == PLACEMENT_TILE)
1019 {
1020 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1021 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1022 }
1023
1024 if (pData->placementSelection == PLACEMENT_CENTER)
1025 {
1026 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1027 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1028 }
1029
1030 if (pData->placementSelection == PLACEMENT_STRETCH)
1031 {
1032 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1033 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1034 }
1035
1036 if (pData->placementSelection == PLACEMENT_FIT)
1037 {
1038 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1039 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1040 }
1041
1042 if (pData->placementSelection == PLACEMENT_FILL)
1043 {
1044 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1045 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1046 }
1047
1048 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1049 {
1050 GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1051 if (!image)
1052 {
1053 RegCloseKey(regKey);
1054 return;
1055 }
1056
1057 GdipGetImageRawFormat(image, &guidFormat);
1058 if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1059 {
1061 RegCloseKey(regKey);
1062 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1063 return;
1064 }
1065
1066 if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1067 {
1069 RegCloseKey(regKey);
1070 return;
1071 }
1072
1073 status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1074
1076
1077 if (status != Ok)
1078 {
1079 RegCloseKey(regKey);
1080 return;
1081 }
1082
1083 if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1084 {
1085 RegSetValueEx(regKey,
1086 TEXT("ConvertedWallpaper"),
1087 0,
1088 REG_SZ,
1089 (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1090 (DWORD)((length + 1) * sizeof(TCHAR)));
1091 }
1092
1093 if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1094 {
1095 RegSetValueEx(regKey,
1096 TEXT("OriginalWallpaper"),
1097 0,
1098 REG_SZ,
1099 (LPBYTE)szWallpaper,
1100 (DWORD)((length + 1) * sizeof(TCHAR)));
1101 }
1102
1104 }
1105 else
1106 {
1108 }
1109
1110 RegCloseKey(regKey);
1111}
1112
1113
1114/* Change system color */
1115static VOID
1117{
1118 HKEY hKey;
1119 INT iElement = COLOR_BACKGROUND;
1120 TCHAR clText[16];
1121 BYTE red, green, blue;
1122
1123 if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1124 {
1125 /* FIXME: these error texts can need internationalization? */
1126 MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1127 TEXT("Error!"), MB_ICONSTOP );
1128 }
1129
1130 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1132 {
1133 return;
1134 }
1135
1139
1140 /* Format string to be set to registry */
1141 StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1142 RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1143 (wcslen(clText) + 1) * sizeof(TCHAR));
1144
1146}
1147
1148static VOID
1150{
1151 HPROPSHEETPAGE hpsp[1] = {0};
1152 PROPSHEETHEADER psh = {sizeof(psh)};
1153 PROPSHEETPAGE psp = {sizeof(psp)};
1154
1155 psh.dwFlags = PSH_NOAPPLYNOW;
1156 psh.hwndParent = GetParent(hwndDlg);
1157 psh.hInstance = hApplet;
1158 psh.pszCaption = MAKEINTRESOURCE(IDS_DESKTOP_ITEMS);
1159 psh.phpage = hpsp;
1160
1161 psp.dwFlags = PSP_DEFAULT;
1162 psp.hInstance = hApplet;
1163 psp.pszTemplate = MAKEINTRESOURCE(IDD_DESKTOP_GENERAL);
1164 psp.pfnDlgProc = DesktopPageProc;
1165 psp.lParam = (LPARAM)&pData->desktopData;
1166
1167 hpsp[0] = CreatePropertySheetPage(&psp);
1168 if (!hpsp[0])
1169 return;
1170
1171 psh.nPages++;
1172
1173 if (PropertySheet(&psh) > 0)
1174 {
1175 if (SaveDesktopSettings(&pData->desktopData))
1176 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1177 }
1178}
1179
1180
1183 UINT uMsg,
1184 WPARAM wParam,
1185 LPARAM lParam)
1186{
1188 struct GdiplusStartupInput gdipStartup;
1189
1191
1192 switch (uMsg)
1193 {
1194 case WM_INITDIALOG:
1197 gdipStartup.GdiplusVersion = 1;
1198 gdipStartup.DebugEventCallback = NULL;
1199 gdipStartup.SuppressBackgroundThread = FALSE;
1200 gdipStartup.SuppressExternalCodecs = FALSE;
1201 GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1202 InitBackgroundDialog(hwndDlg, pData);
1203 InitDesktopSettings(&pData->desktopData);
1204 break;
1205
1206 case WM_COMMAND:
1207 {
1208 DWORD controlId = LOWORD(wParam);
1210
1211 switch (controlId)
1212 {
1213 case IDC_COLOR_BUTTON:
1214 if (command == BN_CLICKED)
1215 OnColorButton(hwndDlg, pData);
1216 break;
1217
1218 case IDC_BROWSE_BUTTON:
1219 if (command == BN_CLICKED)
1220 OnBrowseButton(hwndDlg, pData);
1221 break;
1222
1224 if (command == CBN_SELCHANGE)
1225 {
1226 pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1227
1229
1230 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1231 }
1232 break;
1233
1234 case IDC_DESKTOP_CUSTOM:
1235 if (command == BN_CLICKED)
1236 OnCustomButton(hwndDlg, pData);
1237 break;
1238 }
1239 } break;
1240
1241 case WM_DRAWITEM:
1242 {
1243 LPDRAWITEMSTRUCT drawItem;
1244 drawItem = (LPDRAWITEMSTRUCT)lParam;
1245
1246 if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1247 {
1248 DrawBackgroundPreview(drawItem, pData);
1249 }
1250
1251 }
1252 break;
1253
1254 case WM_NOTIFY:
1255 {
1256 LPNMHDR lpnm = (LPNMHDR)lParam;
1257
1258 switch(lpnm->code)
1259 {
1260 case PSN_APPLY:
1261 if (pData->bWallpaperChanged)
1263 if (pData->bClrBackgroundChanged)
1264 SetDesktopBackColor(hwndDlg, pData);
1265 if (pData->desktopData.bSettingsChanged)
1266 SetDesktopSettings(&pData->desktopData);
1268 return TRUE;
1269
1270 case LVN_ITEMCHANGED:
1271 {
1273
1274 if ((nm->uNewState & LVIS_SELECTED) == 0)
1275 return FALSE;
1276
1277 ListViewItemChanged(hwndDlg, pData, nm->iItem);
1278 }
1279 break;
1280 }
1281 }
1282 break;
1283
1284 case WM_DESTROY:
1285 if (pData->pWallpaperBitmap != NULL)
1286 DibFreeImage(pData->pWallpaperBitmap);
1287
1288 GdiplusShutdown(pData->gdipToken);
1290 break;
1291 }
1292
1293 return FALSE;
1294}
static HDC hDC
Definition: 3dtext.c:33
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:612
PLACEMENT
Definition: background.c:19
@ PLACEMENT_STRETCH
Definition: background.c:21
@ PLACEMENT_TILE
Definition: background.c:22
@ PLACEMENT_FIT
Definition: background.c:23
@ PLACEMENT_FILL
Definition: background.c:24
@ PLACEMENT_CENTER
Definition: background.c:20
#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:992
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:280
struct _BACKGROUND_DATA BACKGROUND_DATA
HRESULT GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
Definition: background.c:74
PLACEMENT_VALUE
Definition: background.c:32
@ PLACEMENT_VALUE_FILL
Definition: background.c:37
@ PLACEMENT_VALUE_CENTER
Definition: background.c:33
@ PLACEMENT_VALUE_FIT
Definition: background.c:36
@ PLACEMENT_VALUE_STRETCH
Definition: background.c:34
@ PLACEMENT_VALUE_TILE
Definition: background.c:35
static UINT AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
Definition: background.c:175
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:781
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:594
#define MAX_BACKGROUNDS
Definition: background.c:16
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:115
INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: background.c:1182
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:747
GLOBAL_DATA g_GlobalData
Definition: background.c:70
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1116
static VOID OnCustomButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1149
#define IDS_NONE
Definition: resource.h:135
#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:77
#define MONITOR_BOTTOM
Definition: desk.h:74
#define MONITOR_LEFT
Definition: desk.h:71
INT_PTR CALLBACK DesktopPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define MONITOR_ALPHA
Definition: desk.h:79
VOID SetDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:181
#define MONITOR_TOP
Definition: desk.h:72
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
#define MONITOR_WIDTH
Definition: desk.h:76
PDIBITMAP DibLoadImage(LPTSTR lpFilename)
Definition: dibitmap.c:13
#define MONITOR_RIGHT
Definition: desk.h:73
#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:2740
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 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:720
#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:44
TCHAR szDisplayName[256]
Definition: background.c:45
BOOL SuppressBackgroundThread
Definition: gdiplusinit.h:36
DebugEventProc DebugEventCallback
Definition: gdiplusinit.h:35
BOOL bClrBackgroundChanged
Definition: background.c:52
DESKTOP_DATA desktopData
Definition: background.c:67
int placementSelection
Definition: background.c:58
int backgroundSelection
Definition: background.c:59
BOOL bWallpaperChanged
Definition: background.c:51
COLORREF custom_colors[16]
Definition: background.c:61
PDIBITMAP pWallpaperBitmap
Definition: background.c:56
BackgroundItem backgroundItems[MAX_BACKGROUNDS]
Definition: background.c:54
ULONG_PTR gdipToken
Definition: background.c:65
Definition: desk.h:44
LONG bmMonHeight
Definition: desk.h:164
LONG bmMonWidth
Definition: desk.h:163
COLORREF desktop_color
Definition: desk.h:159
HBITMAP hMonitorBitmap
Definition: desk.h:162
HICON hIcon
Definition: shellapi.h:366
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:369
Definition: ps.c:97
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:3888
#define ZeroMemory
Definition: winbase.h:1743
#define ExpandEnvironmentStrings
Definition: winbase.h:3805
#define FindNextFile
Definition: winbase.h:3819
#define FindFirstFile
Definition: winbase.h:3813
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300
#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