ReactOS 0.4.15-dev-7918-g2a2556c
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 StringCbCatW(lpBuffer, size, codecInfo[i].FilenameExtension);
159 if (i < (num - 1))
160 {
162 }
163 }
164
165 HeapFree(GetProcessHeap(), 0, codecInfo);
166
167 return lpBuffer;
168}
169
170
171static UINT
172AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
173{
175 HANDLE hFind;
176 TCHAR szSearchPath[MAX_PATH];
177 LPTSTR szFileTypes = NULL;
178 TCHAR separators[] = TEXT(";");
179 TCHAR *token;
180 HRESULT hr;
181 SHFILEINFO sfi;
182 UINT i = uCounter;
183 LV_ITEM listItem;
185
186 szFileTypes = GdipGetSupportedFileExtensions();
187 if (!szFileTypes)
188 {
189 return i;
190 }
191
192 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
193
194 token = _tcstok(szFileTypes, separators);
195 while (token != NULL)
196 {
197 if (!PathCombine(szSearchPath, wallpaperDirectory, token))
198 {
199 HeapFree(GetProcessHeap(), 0, szFileTypes);
200 return i;
201 }
202
203 hFind = FindFirstFile(szSearchPath, &fd);
204 while (hFind != INVALID_HANDLE_VALUE)
205 {
207
208 if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
209 {
210 FindClose(hFind);
211 HeapFree(GetProcessHeap(), 0, szFileTypes);
212 return i;
213 }
214
215 /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
216 if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
217 {
219 0,
220 &sfi,
221 sizeof(sfi),
223 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
224 i++;
225
226 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
227
228 backgroundItem->bWallpaper = TRUE;
229
230 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
231 if (FAILED(hr))
232 {
233 FindClose(hFind);
234 HeapFree(GetProcessHeap(), 0, szFileTypes);
235 return i;
236 }
237
238 PathRemoveExtension(backgroundItem->szDisplayName);
239
240 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
241 if (FAILED(hr))
242 {
243 FindClose(hFind);
244 HeapFree(GetProcessHeap(), 0, szFileTypes);
245 return i;
246 }
247
248 ZeroMemory(&listItem, sizeof(LV_ITEM));
249 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
250 listItem.pszText = backgroundItem->szDisplayName;
251 listItem.state = 0;
252 listItem.iImage = sfi.iIcon;
253 listItem.iItem = pData->listViewItemCount;
254 listItem.lParam = pData->listViewItemCount;
255
256 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
257
258 pData->listViewItemCount++;
259 }
260
261 if (!FindNextFile(hFind, &fd))
262 break;
263 }
264
265 token = _tcstok(NULL, separators);
266 FindClose(hFind);
267 }
268
269 HeapFree(GetProcessHeap(), 0, szFileTypes);
270
271 return i;
272}
273
274
275/* Add the images in the C:\ReactOS, the wallpaper directory and the current wallpaper if any */
276static VOID
278{
279 TCHAR szSearchPath[MAX_PATH];
280 LV_ITEM listItem;
282 RECT clientRect;
283 HKEY regKey;
284 SHFILEINFO sfi;
286 TCHAR wallpaperFilename[MAX_PATH];
287 TCHAR originalWallpaper[MAX_PATH];
288 DWORD bufferSize = sizeof(wallpaperFilename);
290 DWORD varType = REG_SZ;
291 LONG result;
292 UINT i = 0;
293 BackgroundItem *backgroundItem = NULL;
294 HWND hwndBackgroundList;
295 HRESULT hr;
296 HICON hIcon;
297 INT cx, cy;
299
300 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
301
302 GetClientRect(hwndBackgroundList, &clientRect);
303
307
308 /* Load (None) icon */
309#define IDI_SHELL_NO 200
310 hShell32 = GetModuleHandleW(L"shell32.dll");
312#undef IDI_SHELL_NO
313
314 ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
315
316 /* Add a new column to the list */
317 ZeroMemory(&dummy, sizeof(LV_COLUMN));
319 dummy.iSubItem = 0;
320 dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
321 (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
322
323 /* Add the "None" item */
324 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
325 backgroundItem->bWallpaper = FALSE;
327 IDS_NONE,
328 backgroundItem->szDisplayName,
329 sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
330
331 ZeroMemory(&listItem, sizeof(LV_ITEM));
332 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
333 listItem.state = 0;
334 listItem.pszText = backgroundItem->szDisplayName;
335 listItem.iImage = ImageList_AddIcon(himl, hIcon);
336 listItem.iItem = pData->listViewItemCount;
337 listItem.lParam = pData->listViewItemCount;
338 hIcon = NULL;
339
340 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
341 ListView_SetItemState(hwndBackgroundList,
342 pData->listViewItemCount,
345
346 pData->listViewItemCount++;
347
348 /* Add current wallpaper if any */
349 result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
350 if (result == ERROR_SUCCESS)
351 {
352 result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
353 if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
354 {
355 bufferSize = sizeof(originalWallpaper);
356 result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
357
358 /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
359 if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
360 {
361 bufferSize = sizeof(originalWallpaper);
362 result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
363
364 if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
365 {
366 hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
367 if (FAILED(hr))
368 {
369 RegCloseKey(regKey);
370 return;
371 }
372 }
373 }
374
375 /* Allow environment variables in file name */
376 if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
377 {
378 hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
379 if (FAILED(hr))
380 {
381 RegCloseKey(regKey);
382 return;
383 }
384 }
385
386 SHGetFileInfoW(wallpaperFilename,
387 0,
388 &sfi,
389 sizeof(sfi),
392 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
393
394 i++;
395
396 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
397
398 backgroundItem->bWallpaper = TRUE;
399
400 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
401 if (FAILED(hr))
402 {
403 RegCloseKey(regKey);
404 return;
405 }
406
407 PathRemoveExtension(backgroundItem->szDisplayName);
408
409 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
410 if (FAILED(hr))
411 {
412 RegCloseKey(regKey);
413 return;
414 }
415
416 ZeroMemory(&listItem, sizeof(LV_ITEM));
417 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
418 listItem.state = 0;
419 listItem.pszText = backgroundItem->szDisplayName;
420 listItem.iImage = sfi.iIcon;
421 listItem.iItem = pData->listViewItemCount;
422 listItem.lParam = pData->listViewItemCount;
423
424 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
425 ListView_SetItemState(hwndBackgroundList,
426 pData->listViewItemCount,
429
430 pData->listViewItemCount++;
431 }
432
433 RegCloseKey(regKey);
434 }
435
436 /* Add all the images in the C:\ReactOS directory. */
437 if (GetWindowsDirectory(szSearchPath, MAX_PATH))
438 {
439 i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
440 }
441
442 /* Add all the images in the wallpaper directory. */
443 if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
444 {
445 i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
446 }
447}
448
449
450static VOID
452{
453 TCHAR szString[256];
454 HKEY regKey;
455 TCHAR szBuffer[3];
456 DWORD bufferSize = sizeof(szBuffer);
457
458 AddListViewItems(hwndDlg, pData);
459
460 LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
462
463 LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
465
466 LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
468
469 LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
471
472 LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
474
476 pData->placementSelection = PLACEMENT_CENTER;
477
478 /* Load the default settings from the registry */
479 if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
480 {
481 return;
482 }
483
484 if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
485 {
486 if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
487 {
489 pData->placementSelection = PLACEMENT_CENTER;
490 }
491
492 if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
493 {
495 pData->placementSelection = PLACEMENT_STRETCH;
496 }
497
498 if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
499 {
501 pData->placementSelection = PLACEMENT_FIT;
502 }
503
504 if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
505 {
507 pData->placementSelection = PLACEMENT_FILL;
508 }
509 }
510
511 if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
512 {
513 if (_ttoi(szBuffer) == 1)
514 {
516 pData->placementSelection = PLACEMENT_TILE;
517 }
518 }
519
520 RegCloseKey(regKey);
521}
522
523
524static VOID
526{
527 /* Load custom colors from Registry */
528 HKEY hKey = NULL;
531
532 res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
534 /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
535 if (res == ERROR_SUCCESS)
536 {
537 /* Key opened */
538 DWORD dwType = REG_BINARY;
539 DWORD cbData = sizeof(pData->custom_colors);
540 res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
541 (LPBYTE)pData->custom_colors, &cbData);
543 hKey = NULL;
544 }
545
546 /* Launch ChooseColor() dialog */
547
548 cc.lStructSize = sizeof(CHOOSECOLOR);
549 cc.hwndOwner = hwndDlg;
550 cc.hInstance = NULL;
551 cc.rgbResult = g_GlobalData.desktop_color;
552 cc.lpCustColors = pData->custom_colors;
553 cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
554 CC_FULLOPEN | /* opens dialog in full size */
555 CC_RGBINIT ; /* init chosen color by rgbResult value */
556 cc.lCustData = 0;
557 cc.lpfnHook = NULL;
558 cc.lpTemplateName = NULL;
559 if (ChooseColor(&cc))
560 {
561 /* Save selected color to var */
562 g_GlobalData.desktop_color = cc.rgbResult;
563 pData->bClrBackgroundChanged = TRUE;
564
565 /* Apply button will be activated */
566 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
567
568 /* Window will be updated :) */
570
571 /* Save custom colors to reg. To this moment key must be created already. See above */
572 res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
574 if (res == ERROR_SUCCESS)
575 {
576 /* Key opened */
577 RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
578 (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
580 hKey = NULL;
581 }
582 }
583}
584
585
586/*
587 * ListView_FindItem() Macro: Searches for a list-view item with the specified
588 * characteristics. Returns the index of the item if successful, or -1 otherwise
589 */
590static BOOL
592{
593 LVFINDINFO lvfi;
594 int retVal;
595
596 lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
597 lvfi.psz = tszFileName; /* String to search */
598
599 /* Other items of this structure are not valid, besacuse flags are not set. */
600 retVal = ListView_FindItem(hwndList, -1, &lvfi);
601 if (retVal != -1)
602 return TRUE; /* item found! */
603
604 return FALSE; /* item not found. */
605}
606
607
608static VOID
610{
613 TCHAR fileTitle[256];
614 TCHAR initialDir[MAX_PATH];
616 LPTSTR extensions;
617 BackgroundItem *backgroundItem = NULL;
618 SHFILEINFO sfi;
619 LV_ITEM listItem;
620 HWND hwndBackgroundList;
621 TCHAR *p;
622 HRESULT hr;
623 TCHAR filterdesc[MAX_PATH];
624 TCHAR *c;
625 size_t sizeRemain;
626 SIZE_T buffersize;
629
630 hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
631 himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
632 SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
633
634 ZeroMemory(&ofn, sizeof(OPENFILENAME));
635
636 ofn.lStructSize = sizeof(OPENFILENAME);
637 ofn.hwndOwner = hwndDlg;
639
640 LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
641
642 extensions = GdipGetSupportedFileExtensions();
643 if (!extensions)
644 {
645 return;
646 }
647
648 buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
649
651 if (!filter)
652 {
653 HeapFree(GetProcessHeap(), 0, extensions);
654 return;
655 }
656
657 sizeRemain = buffersize;
658 c = filter;
659
660 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
661 {
662 HeapFree(GetProcessHeap(), 0, extensions);
664 return;
665 }
666
667 c++;
668 sizeRemain -= sizeof(*c);
669
670 if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
671 {
672 HeapFree(GetProcessHeap(), 0, extensions);
674 return;
675 }
676
677 HeapFree(GetProcessHeap(), 0, extensions);
678
679 /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
680 * use the contents of szFile to initialize itself */
681 ofn.lpstrFile[0] = TEXT('\0');
684 ofn.nFilterIndex = 0;
685 ofn.lpstrFileTitle = fileTitle;
686 ofn.nMaxFileTitle = 256;
687 ofn.lpstrInitialDir = initialDir;
689
692
693 if (success)
694 {
695 /* Check if there is already a entry that holds this filename */
696 if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
697 return;
698
699 if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
700 return;
701
703 0,
704 &sfi,
705 sizeof(sfi),
707 sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
708
709 backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
710
711 backgroundItem->bWallpaper = TRUE;
712
713 hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
714 if (FAILED(hr))
715 return;
716 p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
717 if (p)
718 *p = (TCHAR)0;
719 hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
720 if (FAILED(hr))
721 return;
722
723 ZeroMemory(&listItem, sizeof(LV_ITEM));
724 listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
725 listItem.state = 0;
726 listItem.pszText = backgroundItem->szDisplayName;
727 listItem.iImage = sfi.iIcon;
728 listItem.iItem = pData->listViewItemCount;
729 listItem.lParam = pData->listViewItemCount;
730
731 (void)ListView_InsertItem(hwndBackgroundList, &listItem);
732 ListView_SetItemState(hwndBackgroundList,
733 pData->listViewItemCount,
736 SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
737
738 pData->listViewItemCount++;
739 }
740}
741
742
743static VOID
745{
746 BackgroundItem *backgroundItem = NULL;
747
748 pData->backgroundSelection = itemIndex;
749 backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
750
751 if (pData->pWallpaperBitmap != NULL)
752 {
753 DibFreeImage(pData->pWallpaperBitmap);
754 pData->pWallpaperBitmap = NULL;
755 }
756
757 if (backgroundItem->bWallpaper != FALSE)
758 {
759 pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
760
761 if (pData->pWallpaperBitmap == NULL)
762 return;
763 }
764
765 pData->bWallpaperChanged = TRUE;
766
768 NULL, TRUE);
769
771 backgroundItem->bWallpaper);
772
773 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
774}
775
776
777static VOID
779{
780 float scaleX;
781 float scaleY;
782 int scaledWidth;
783 int scaledHeight;
784 int posX, desX;
785 int posY, desY;
786 int fitFillScaleNum, fitFillScaleDen;
787 int fitFillWidth, fitFillHeight;
788 HBRUSH hBrush;
789 int x;
790 int y;
791 HDC hDC;
792 HGDIOBJ hOldObj;
793 RECT rcItem = {
798 };
799
800 hDC = CreateCompatibleDC(draw->hDC);
802
803 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
804 {
805 /* Update desktop background color image */
807 FillRect(hDC, &rcItem, hBrush);
808 DeleteObject(hBrush);
809 }
810 else
811 if (pData->pWallpaperBitmap != NULL)
812 {
813 scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
814 scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
815
816 scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
817 scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
818
820
822
823 switch (pData->placementSelection)
824 {
825 case PLACEMENT_CENTER:
826 posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
827 posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
828 desX = 0;
829 desY = 0;
830
831 if (posX < 0) { desX = -posX / 2; posX = 0; }
832 if (posY < 0) { desY = -posY / 2; posY = 0; }
833
834 if (scaledWidth > MONITOR_WIDTH)
835 scaledWidth = MONITOR_WIDTH;
836
837 if (scaledHeight > MONITOR_HEIGHT)
838 scaledHeight = MONITOR_HEIGHT;
839
841 MONITOR_LEFT+posX,
842 MONITOR_TOP+posY,
843 scaledWidth,
844 scaledHeight,
845 desX,
846 desY,
847 pData->pWallpaperBitmap->width - (int)(desX * scaleX),
848 pData->pWallpaperBitmap->height - (int)(desY * scaleY),
849 pData->pWallpaperBitmap->bits,
850 pData->pWallpaperBitmap->info,
852 SRCCOPY);
853 break;
854
861 0,
862 0,
863 pData->pWallpaperBitmap->width,
864 pData->pWallpaperBitmap->height,
865 pData->pWallpaperBitmap->bits,
866 pData->pWallpaperBitmap->info,
868 SRCCOPY);
869 break;
870
871 case PLACEMENT_TILE:
872 for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
873 {
874 for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
875 {
876 if ((MONITOR_WIDTH-x) >= scaledWidth)
877 posX = scaledWidth;
878 else
879 posX = MONITOR_WIDTH-x;
880
881
882 if ((MONITOR_HEIGHT-y) >= scaledHeight)
883 posY = scaledHeight;
884 else
885 posY = MONITOR_HEIGHT-y;
886
888 MONITOR_LEFT + x,
889 MONITOR_TOP + y,
890 posX,
891 posY,
892 0,
893 0,
894 pData->pWallpaperBitmap->width * posX / scaledWidth,
895 pData->pWallpaperBitmap->height * posY / scaledHeight,
896 pData->pWallpaperBitmap->bits,
897 pData->pWallpaperBitmap->info,
899 SRCCOPY);
900 }
901
902 }
903
904 break;
905
906 case PLACEMENT_FIT:
907 if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
908 {
909 fitFillScaleNum = MONITOR_WIDTH;
910 fitFillScaleDen = scaledWidth;
911 }
912 else
913 {
914 fitFillScaleNum = MONITOR_HEIGHT;
915 fitFillScaleDen = scaledHeight;
916 }
917
918 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
919 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
920
921 posX = (MONITOR_WIDTH - fitFillWidth) / 2;
922 posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
923
925 MONITOR_LEFT + posX,
926 MONITOR_TOP + posY,
927 fitFillWidth,
928 fitFillHeight,
929 0,
930 0,
931 pData->pWallpaperBitmap->width,
932 pData->pWallpaperBitmap->height,
933 pData->pWallpaperBitmap->bits,
934 pData->pWallpaperBitmap->info,
936 SRCCOPY);
937 break;
938
939 case PLACEMENT_FILL:
940 if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
941 {
942 fitFillScaleNum = MONITOR_WIDTH;
943 fitFillScaleDen = scaledWidth;
944 }
945 else
946 {
947 fitFillScaleNum = MONITOR_HEIGHT;
948 fitFillScaleDen = scaledHeight;
949 }
950
951 fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
952 fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
953
954 desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
955 desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
956
962 desX,
963 desY,
964 (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
965 (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
966 pData->pWallpaperBitmap->bits,
967 pData->pWallpaperBitmap->info,
969 SRCCOPY);
970 break;
971 }
972 }
973
975 draw->rcItem.left, draw->rcItem.top,
976 draw->rcItem.right - draw->rcItem.left + 1,
977 draw->rcItem.bottom - draw->rcItem.top + 1,
978 hDC,
979 0, 0,
982
983 SelectObject(hDC, hOldObj);
984 DeleteDC(hDC);
985}
986
987
988static VOID
990{
991 HKEY regKey;
992 TCHAR szWallpaper[MAX_PATH];
993 GpImage *image;
994 CLSID encoderClsid;
995 GUID guidFormat;
996 size_t length = 0;
998
1000 {
1001 return;
1002 }
1003
1004 if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1005 {
1006 return;
1007 }
1008
1009 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1011 {
1012 return;
1013 }
1014
1015 if (pData->placementSelection == PLACEMENT_TILE)
1016 {
1017 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1018 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1019 }
1020
1021 if (pData->placementSelection == PLACEMENT_CENTER)
1022 {
1023 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1024 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1025 }
1026
1027 if (pData->placementSelection == PLACEMENT_STRETCH)
1028 {
1029 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1030 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1031 }
1032
1033 if (pData->placementSelection == PLACEMENT_FIT)
1034 {
1035 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1036 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1037 }
1038
1039 if (pData->placementSelection == PLACEMENT_FILL)
1040 {
1041 RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1042 RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1043 }
1044
1045 if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1046 {
1047 GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1048 if (!image)
1049 {
1050 RegCloseKey(regKey);
1051 return;
1052 }
1053
1054 GdipGetImageRawFormat(image, &guidFormat);
1055 if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1056 {
1058 RegCloseKey(regKey);
1059 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1060 return;
1061 }
1062
1063 if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1064 {
1066 RegCloseKey(regKey);
1067 return;
1068 }
1069
1070 status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1071
1073
1074 if (status != Ok)
1075 {
1076 RegCloseKey(regKey);
1077 return;
1078 }
1079
1080 if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1081 {
1082 RegSetValueEx(regKey,
1083 TEXT("ConvertedWallpaper"),
1084 0,
1085 REG_SZ,
1086 (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1087 (DWORD)((length + 1) * sizeof(TCHAR)));
1088 }
1089
1090 if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1091 {
1092 RegSetValueEx(regKey,
1093 TEXT("OriginalWallpaper"),
1094 0,
1095 REG_SZ,
1096 (LPBYTE)szWallpaper,
1097 (DWORD)((length + 1) * sizeof(TCHAR)));
1098 }
1099
1101 }
1102 else
1103 {
1105 }
1106
1107 RegCloseKey(regKey);
1108}
1109
1110
1111/* Change system color */
1112static VOID
1114{
1115 HKEY hKey;
1116 INT iElement = COLOR_BACKGROUND;
1117 TCHAR clText[16];
1118 BYTE red, green, blue;
1119
1120 if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1121 {
1122 /* FIXME: these error texts can need internationalization? */
1123 MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1124 TEXT("Error!"), MB_ICONSTOP );
1125 }
1126
1127 if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1129 {
1130 return;
1131 }
1132
1136
1137 /* Format string to be set to registry */
1138 StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1139 RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1140 (wcslen(clText) + 1) * sizeof(TCHAR));
1141
1143}
1144
1145static VOID
1147{
1148 HPROPSHEETPAGE hpsp[1] = {0};
1149 PROPSHEETHEADER psh = {sizeof(psh)};
1150 PROPSHEETPAGE psp = {sizeof(psp)};
1151
1152 psh.dwFlags = PSH_NOAPPLYNOW;
1153 psh.hwndParent = GetParent(hwndDlg);
1154 psh.hInstance = hApplet;
1155 psh.pszCaption = MAKEINTRESOURCE(IDS_DESKTOP_ITEMS);
1156 psh.phpage = hpsp;
1157
1158 psp.dwFlags = PSP_DEFAULT;
1159 psp.hInstance = hApplet;
1160 psp.pszTemplate = MAKEINTRESOURCE(IDD_DESKTOP_GENERAL);
1161 psp.pfnDlgProc = DesktopPageProc;
1162 psp.lParam = (LPARAM)&pData->desktopData;
1163
1164 hpsp[0] = CreatePropertySheetPage(&psp);
1165 if (!hpsp[0])
1166 return;
1167
1168 psh.nPages++;
1169
1170 if (PropertySheet(&psh) > 0)
1171 {
1172 if (SaveDesktopSettings(&pData->desktopData))
1173 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1174 }
1175}
1176
1177
1180 UINT uMsg,
1181 WPARAM wParam,
1182 LPARAM lParam)
1183{
1185 struct GdiplusStartupInput gdipStartup;
1186
1188
1189 switch (uMsg)
1190 {
1191 case WM_INITDIALOG:
1194 gdipStartup.GdiplusVersion = 1;
1195 gdipStartup.DebugEventCallback = NULL;
1196 gdipStartup.SuppressBackgroundThread = FALSE;
1197 gdipStartup.SuppressExternalCodecs = FALSE;
1198 GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1199 InitBackgroundDialog(hwndDlg, pData);
1200 InitDesktopSettings(&pData->desktopData);
1201 break;
1202
1203 case WM_COMMAND:
1204 {
1205 DWORD controlId = LOWORD(wParam);
1207
1208 switch (controlId)
1209 {
1210 case IDC_COLOR_BUTTON:
1211 if (command == BN_CLICKED)
1212 OnColorButton(hwndDlg, pData);
1213 break;
1214
1215 case IDC_BROWSE_BUTTON:
1216 if (command == BN_CLICKED)
1217 OnBrowseButton(hwndDlg, pData);
1218 break;
1219
1221 if (command == CBN_SELCHANGE)
1222 {
1223 pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1224
1226
1227 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1228 }
1229 break;
1230
1231 case IDC_DESKTOP_CUSTOM:
1232 if (command == BN_CLICKED)
1233 OnCustomButton(hwndDlg, pData);
1234 break;
1235 }
1236 } break;
1237
1238 case WM_DRAWITEM:
1239 {
1240 LPDRAWITEMSTRUCT drawItem;
1241 drawItem = (LPDRAWITEMSTRUCT)lParam;
1242
1243 if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1244 {
1245 DrawBackgroundPreview(drawItem, pData);
1246 }
1247
1248 }
1249 break;
1250
1251 case WM_NOTIFY:
1252 {
1253 LPNMHDR lpnm = (LPNMHDR)lParam;
1254
1255 switch(lpnm->code)
1256 {
1257 case PSN_APPLY:
1258 if (pData->bWallpaperChanged)
1260 if (pData->bClrBackgroundChanged)
1261 SetDesktopBackColor(hwndDlg, pData);
1262 if (pData->desktopData.bSettingsChanged)
1263 SetDesktopSettings(&pData->desktopData);
1265 return TRUE;
1266
1267 case LVN_ITEMCHANGED:
1268 {
1270
1271 if ((nm->uNewState & LVIS_SELECTED) == 0)
1272 return FALSE;
1273
1274 ListViewItemChanged(hwndDlg, pData, nm->iItem);
1275 }
1276 break;
1277 }
1278 }
1279 break;
1280
1281 case WM_DESTROY:
1282 if (pData->pWallpaperBitmap != NULL)
1283 DibFreeImage(pData->pWallpaperBitmap);
1284
1285 GdiplusShutdown(pData->gdipToken);
1287 break;
1288 }
1289
1290 return FALSE;
1291}
static HDC hDC
Definition: 3dtext.c:33
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:609
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:451
struct _BACKGROUND_DATA * PBACKGROUND_DATA
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:989
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:277
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:172
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:778
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:591
#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:1179
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:525
static VOID ListViewItemChanged(HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
Definition: background.c:744
GLOBAL_DATA g_GlobalData
Definition: background.c:70
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1113
static VOID OnCustomButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1146
#define IDS_NONE
Definition: resource.h:133
#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:804
#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:5045
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4994
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:5069
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:5018
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
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
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
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
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
GLuint64EXT * result
Definition: glext.h:11304
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:92
static HICON
Definition: imagelist.c:84
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 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:2299
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2673
#define LVFINDINFO
Definition: commctrl.h:2463
#define LVFI_STRING
Definition: commctrl.h:2437
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define LVIF_STATE
Definition: commctrl.h:2312
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2296
_Out_opt_ int * cx
Definition: commctrl.h:585
#define ILC_COLOR32
Definition: commctrl.h:358
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define LVIF_PARAM
Definition: commctrl.h:2311
#define LV_ITEM
Definition: commctrl.h:2337
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVIF_TEXT
Definition: commctrl.h:2309
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define ILC_MASK
Definition: commctrl.h:351
#define LVIF_IMAGE
Definition: commctrl.h:2310
#define LVN_ITEMCHANGED
Definition: commctrl.h:3131
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470
#define LV_COLUMN
Definition: commctrl.h:2547
#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:415
#define SHGetFileInfo
Definition: shellapi.h:697
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
#define SHGFI_ICON
Definition: shellapi.h:164
#define SHGFI_SMALLICON
Definition: shellapi.h:176
#define CSIDL_FLAG_CREATE
HRESULT hr
Definition: shlfolder.c:183
#define SHGetFolderPath
Definition: shlobj.h:2156
#define CSIDL_MYPICTURES
Definition: shlobj.h:2196
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2185
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define PathCombine
Definition: shlwapi.h:825
#define SHRegGetPath
Definition: shlwapi.h:196
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:365
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:368
Definition: ps.c:97
UINT code
Definition: winuser.h:3159
UINT uNewState
Definition: commctrl.h:3036
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:3857
#define ZeroMemory
Definition: winbase.h:1712
#define ExpandEnvironmentStrings
Definition: winbase.h:3774
#define FindNextFile
Definition: winbase.h:3788
#define FindFirstFile
Definition: winbase.h:3782
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:1539
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:1366
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:872
#define SM_CYSCREEN
Definition: winuser.h:960
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1369
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_VSCROLL
Definition: winuser.h:1744
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define SM_CXVSCROLL
Definition: winuser.h:961
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define HWND_BROADCAST
Definition: winuser.h:1204
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_COMMAND
Definition: winuser.h:1740
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:2203
#define CB_SETCURSEL
Definition: winuser.h:1961
#define SM_CYSMICON
Definition: winuser.h:1013
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1645
#define CBN_SELCHANGE
Definition: winuser.h:1979
#define WM_SETTINGCHANGE
Definition: winuser.h:1629
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1571
#define SM_CXSMICON
Definition: winuser.h:1012
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5843
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
#define LoadString
Definition: winuser.h:5819
#define MessageBox
Definition: winuser.h:5822
#define MB_ICONSTOP
Definition: winuser.h:803
#define BN_CLICKED
Definition: winuser.h:1925
#define WM_DESTROY
Definition: winuser.h:1609
#define SM_CXSCREEN
Definition: winuser.h:959
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_INSERTSTRING
Definition: winuser.h:1957
#define SystemParametersInfo
Definition: winuser.h:5858
#define CB_GETCURSEL
Definition: winuser.h:1943
#define SendDlgItemMessage
Definition: winuser.h:5842
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
#define COLOR_BACKGROUND
Definition: winuser.h:913
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