ReactOS  0.4.15-dev-439-g292f67a
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 
18 typedef enum
19 {
25 } PLACEMENT;
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  */
31 typedef enum
32 {
39 
40 /* The values in these macros are dependent on the
41  * layout of the monitor image and they must be adjusted
42  * if that image will be changed.
43  */
44 #define MONITOR_LEFT 20
45 #define MONITOR_TOP 8
46 #define MONITOR_RIGHT 140
47 #define MONITOR_BOTTOM 92
48 
49 #define MONITOR_WIDTH (MONITOR_RIGHT-MONITOR_LEFT)
50 #define MONITOR_HEIGHT (MONITOR_BOTTOM-MONITOR_TOP)
51 
52 typedef struct
53 {
54  BOOL bWallpaper; /* Is this background a wallpaper */
55 
56  TCHAR szFilename[MAX_PATH];
57  TCHAR szDisplayName[256];
58 
60 
61 typedef struct _BACKGROUND_DATA
62 {
65 
67 
69 
72 
74 
76 
78  int cxSource;
79  int cySource;
80 
83 
85 
86 
87 HRESULT
88 GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
89 {
90  UINT num;
91  UINT size;
92  UINT i;
93  ImageCodecInfo *codecInfo;
94 
95  if (GdipGetImageEncodersSize(&num, &size) != Ok ||
96  size == 0)
97  {
98  return E_FAIL;
99  }
100 
101  codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
102  if (!codecInfo)
103  {
104  return E_OUTOFMEMORY;
105  }
106 
107  if (GdipGetImageEncoders(num, size, codecInfo) != Ok)
108  {
109  HeapFree(GetProcessHeap(), 0, codecInfo);
110  return E_FAIL;
111  }
112 
113  for (i = 0; i < num; i++)
114  {
115  if (!_wcsicmp(codecInfo[i].MimeType, MimeType))
116  {
117  *pClsid = codecInfo[i].Clsid;
118  HeapFree(GetProcessHeap(), 0, codecInfo);
119  return S_OK;
120  }
121  }
122 
123  HeapFree(GetProcessHeap(), 0, codecInfo);
124  return E_FAIL;
125 }
126 
127 
128 LPWSTR
130 {
131  ImageCodecInfo *codecInfo;
132  UINT num;
133  UINT size;
134  UINT i;
135  LPWSTR lpBuffer = NULL;
136 
137  if (GdipGetImageDecodersSize(&num, &size) != Ok ||
138  size == 0)
139  {
140  return NULL;
141  }
142 
143  codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
144  if (!codecInfo)
145  {
146  return NULL;
147  }
148 
149  if (GdipGetImageDecoders(num, size, codecInfo) != Ok)
150  {
151  HeapFree(GetProcessHeap(), 0, codecInfo);
152  return NULL;
153  }
154 
155  size = 0;
156  for (i = 0; i < num; ++i)
157  {
158  size = size + (UINT)wcslen(codecInfo[i].FilenameExtension) + 1;
159  }
160 
161  size = (size + 1) * sizeof(WCHAR);
162 
164  if (!lpBuffer)
165  {
166  HeapFree(GetProcessHeap(), 0, codecInfo);
167  return NULL;
168  }
169 
170  for (i = 0; i < num; ++i)
171  {
172  StringCbCatW(lpBuffer, size, codecInfo[i].FilenameExtension);
173  if (i < (num - 1))
174  {
175  StringCbCatW(lpBuffer, size, L";");
176  }
177  }
178 
179  HeapFree(GetProcessHeap(), 0, codecInfo);
180 
181  return lpBuffer;
182 }
183 
184 
185 static UINT
186 AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
187 {
189  HANDLE hFind;
190  TCHAR szSearchPath[MAX_PATH];
191  LPTSTR szFileTypes = NULL;
192  TCHAR separators[] = TEXT(";");
193  TCHAR *token;
194  HRESULT hr;
195  SHFILEINFO sfi;
196  UINT i = uCounter;
197  LV_ITEM listItem;
199 
200  szFileTypes = GdipGetSupportedFileExtensions();
201  if (!szFileTypes)
202  {
203  return i;
204  }
205 
206  himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
207 
208  token = _tcstok(szFileTypes, separators);
209  while (token != NULL)
210  {
211  if (!PathCombine(szSearchPath, wallpaperDirectory, token))
212  {
213  HeapFree(GetProcessHeap(), 0, szFileTypes);
214  return i;
215  }
216 
217  hFind = FindFirstFile(szSearchPath, &fd);
218  while (hFind != INVALID_HANDLE_VALUE)
219  {
221 
222  if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
223  {
224  FindClose(hFind);
225  HeapFree(GetProcessHeap(), 0, szFileTypes);
226  return i;
227  }
228 
229  /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
230  if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
231  {
233  0,
234  &sfi,
235  sizeof(sfi),
237  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
238  i++;
239 
240  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
241 
242  backgroundItem->bWallpaper = TRUE;
243 
244  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
245  if (FAILED(hr))
246  {
247  FindClose(hFind);
248  HeapFree(GetProcessHeap(), 0, szFileTypes);
249  return i;
250  }
251 
252  PathRemoveExtension(backgroundItem->szDisplayName);
253 
254  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
255  if (FAILED(hr))
256  {
257  FindClose(hFind);
258  HeapFree(GetProcessHeap(), 0, szFileTypes);
259  return i;
260  }
261 
262  ZeroMemory(&listItem, sizeof(LV_ITEM));
263  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
264  listItem.pszText = backgroundItem->szDisplayName;
265  listItem.state = 0;
266  listItem.iImage = sfi.iIcon;
267  listItem.iItem = pData->listViewItemCount;
268  listItem.lParam = pData->listViewItemCount;
269 
270  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
271 
272  pData->listViewItemCount++;
273  }
274 
275  if (!FindNextFile(hFind, &fd))
276  break;
277  }
278 
279  token = _tcstok(NULL, separators);
280  FindClose(hFind);
281  }
282 
283  HeapFree(GetProcessHeap(), 0, szFileTypes);
284 
285  return i;
286 }
287 
288 
289 /* Add the images in the C:\ReactOS, the wallpaper directory and the current wallpaper if any */
290 static VOID
292 {
293  TCHAR szSearchPath[MAX_PATH];
294  LV_ITEM listItem;
296  RECT clientRect;
297  HKEY regKey;
298  SHFILEINFO sfi;
300  TCHAR wallpaperFilename[MAX_PATH];
301  TCHAR originalWallpaper[MAX_PATH];
302  DWORD bufferSize = sizeof(wallpaperFilename);
304  DWORD varType = REG_SZ;
305  LONG result;
306  UINT i = 0;
307  BackgroundItem *backgroundItem = NULL;
308  HWND hwndBackgroundList;
309  HRESULT hr;
310  HICON hIcon;
311  INT cx, cy;
313 
314  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
315 
316  GetClientRect(hwndBackgroundList, &clientRect);
317 
321 
322  /* Load (None) icon */
323 #define IDI_SHELL_NO 200
324  hShell32 = GetModuleHandleW(L"shell32.dll");
326 #undef IDI_SHELL_NO
327 
328  ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
329 
330  /* Add a new column to the list */
331  ZeroMemory(&dummy, sizeof(LV_COLUMN));
332  dummy.mask = LVCF_SUBITEM | LVCF_WIDTH;
333  dummy.iSubItem = 0;
334  dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
335  (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
336 
337  /* Add the "None" item */
338  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
339  backgroundItem->bWallpaper = FALSE;
341  IDS_NONE,
342  backgroundItem->szDisplayName,
343  sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
344 
345  ZeroMemory(&listItem, sizeof(LV_ITEM));
346  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
347  listItem.state = 0;
348  listItem.pszText = backgroundItem->szDisplayName;
349  listItem.iImage = ImageList_AddIcon(himl, hIcon);
350  listItem.iItem = pData->listViewItemCount;
351  listItem.lParam = pData->listViewItemCount;
352  hIcon = NULL;
353 
354  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
355  ListView_SetItemState(hwndBackgroundList,
356  pData->listViewItemCount,
358  LVIS_SELECTED);
359 
360  pData->listViewItemCount++;
361 
362  /* Add current wallpaper if any */
363  result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
364  if (result == ERROR_SUCCESS)
365  {
366  result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
367  if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
368  {
369  bufferSize = sizeof(originalWallpaper);
370  result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
371 
372  /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
373  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
374  {
375  bufferSize = sizeof(originalWallpaper);
376  result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
377 
378  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
379  {
380  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
381  if (FAILED(hr))
382  {
383  RegCloseKey(regKey);
384  return;
385  }
386  }
387  }
388 
389  /* Allow environment variables in file name */
390  if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
391  {
392  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
393  if (FAILED(hr))
394  {
395  RegCloseKey(regKey);
396  return;
397  }
398  }
399 
400  SHGetFileInfoW(wallpaperFilename,
401  0,
402  &sfi,
403  sizeof(sfi),
406  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
407 
408  i++;
409 
410  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
411 
412  backgroundItem->bWallpaper = TRUE;
413 
414  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
415  if (FAILED(hr))
416  {
417  RegCloseKey(regKey);
418  return;
419  }
420 
421  PathRemoveExtension(backgroundItem->szDisplayName);
422 
423  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
424  if (FAILED(hr))
425  {
426  RegCloseKey(regKey);
427  return;
428  }
429 
430  ZeroMemory(&listItem, sizeof(LV_ITEM));
431  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
432  listItem.state = 0;
433  listItem.pszText = backgroundItem->szDisplayName;
434  listItem.iImage = sfi.iIcon;
435  listItem.iItem = pData->listViewItemCount;
436  listItem.lParam = pData->listViewItemCount;
437 
438  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
439  ListView_SetItemState(hwndBackgroundList,
440  pData->listViewItemCount,
442  LVIS_SELECTED);
443 
444  pData->listViewItemCount++;
445  }
446 
447  RegCloseKey(regKey);
448  }
449 
450  /* Add all the images in the C:\ReactOS directory. */
451  if (GetWindowsDirectory(szSearchPath, MAX_PATH))
452  {
453  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
454  }
455 
456  /* Add all the images in the wallpaper directory. */
457  if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
458  {
459  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
460  }
461 }
462 
463 
464 static VOID
466 {
467  TCHAR szString[256];
468  HKEY regKey;
469  TCHAR szBuffer[3];
470  DWORD bufferSize = sizeof(szBuffer);
471  BITMAP bitmap;
472 
473  AddListViewItems(hwndDlg, pData);
474 
475  LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
477 
478  LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
480 
481  LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
483 
484  LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
486 
487  LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
489 
491  pData->placementSelection = PLACEMENT_CENTER;
492 
494  if (pData->hBitmap != NULL)
495  {
496  GetObject(pData->hBitmap, sizeof(BITMAP), &bitmap);
497 
498  pData->cxSource = bitmap.bmWidth;
499  pData->cySource = bitmap.bmHeight;
500  }
501 
502  /* Load the default settings from the registry */
503  if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
504  {
505  return;
506  }
507 
508  if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
509  {
510  if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
511  {
513  pData->placementSelection = PLACEMENT_CENTER;
514  }
515 
516  if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
517  {
519  pData->placementSelection = PLACEMENT_STRETCH;
520  }
521 
522  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
523  {
525  pData->placementSelection = PLACEMENT_FIT;
526  }
527 
528  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
529  {
531  pData->placementSelection = PLACEMENT_FILL;
532  }
533  }
534 
535  if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
536  {
537  if (_ttoi(szBuffer) == 1)
538  {
540  pData->placementSelection = PLACEMENT_TILE;
541  }
542  }
543 
544  RegCloseKey(regKey);
545 }
546 
547 
548 static VOID
550 {
551  /* Load custom colors from Registry */
552  HKEY hKey = NULL;
554  CHOOSECOLOR cc;
555 
556  res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
558  /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
559  if (res == ERROR_SUCCESS)
560  {
561  /* Key opened */
562  DWORD dwType = REG_BINARY;
563  DWORD cbData = sizeof(pData->custom_colors);
564  res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
565  (LPBYTE)pData->custom_colors, &cbData);
566  RegCloseKey(hKey);
567  hKey = NULL;
568  }
569 
570  /* Launch ChooseColor() dialog */
571 
572  cc.lStructSize = sizeof(CHOOSECOLOR);
573  cc.hwndOwner = hwndDlg;
574  cc.hInstance = NULL;
575  cc.rgbResult = g_GlobalData.desktop_color;
576  cc.lpCustColors = pData->custom_colors;
577  cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
578  CC_FULLOPEN | /* opens dialog in full size */
579  CC_RGBINIT ; /* init chosen color by rgbResult value */
580  cc.lCustData = 0;
581  cc.lpfnHook = NULL;
582  cc.lpTemplateName = NULL;
583  if (ChooseColor(&cc))
584  {
585  /* Save selected color to var */
586  g_GlobalData.desktop_color = cc.rgbResult;
587  pData->bClrBackgroundChanged = TRUE;
588 
589  /* Apply button will be activated */
590  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
591 
592  /* Window will be updated :) */
594 
595  /* Save custom colors to reg. To this moment key must be created already. See above */
596  res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
597  KEY_SET_VALUE, &hKey);
598  if (res == ERROR_SUCCESS)
599  {
600  /* Key opened */
601  RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
602  (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
603  RegCloseKey(hKey);
604  hKey = NULL;
605  }
606  }
607 }
608 
609 
610 /*
611  * ListView_FindItem() Macro: Searches for a list-view item with the specified
612  * characteristics. Returns the index of the item if successful, or -1 otherwise
613  */
614 static BOOL
616 {
617  LVFINDINFO lvfi;
618  int retVal;
619 
620  lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
621  lvfi.psz = tszFileName; /* String to search */
622 
623  /* Other items of this structure are not valid, besacuse flags are not set. */
624  retVal = ListView_FindItem(hwndList, -1, &lvfi);
625  if (retVal != -1)
626  return TRUE; /* item found! */
627 
628  return FALSE; /* item not found. */
629 }
630 
631 
632 static VOID
634 {
637  TCHAR fileTitle[256];
638  TCHAR initialDir[MAX_PATH];
639  LPTSTR filter;
640  LPTSTR extensions;
641  BackgroundItem *backgroundItem = NULL;
642  SHFILEINFO sfi;
643  LV_ITEM listItem;
644  HWND hwndBackgroundList;
645  TCHAR *p;
646  HRESULT hr;
647  TCHAR filterdesc[MAX_PATH];
648  TCHAR *c;
649  size_t sizeRemain;
650  SIZE_T buffersize;
651  BOOL success;
653 
654  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
655  himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
656  SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
657 
658  ZeroMemory(&ofn, sizeof(OPENFILENAME));
659 
660  ofn.lStructSize = sizeof(OPENFILENAME);
661  ofn.hwndOwner = hwndDlg;
663 
664  LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
665 
666  extensions = GdipGetSupportedFileExtensions();
667  if (!extensions)
668  {
669  return;
670  }
671 
672  buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
673 
675  if (!filter)
676  {
677  HeapFree(GetProcessHeap(), 0, extensions);
678  return;
679  }
680 
681  sizeRemain = buffersize;
682  c = filter;
683 
684  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
685  {
686  HeapFree(GetProcessHeap(), 0, extensions);
688  return;
689  }
690 
691  c++;
692  sizeRemain -= sizeof(*c);
693 
694  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
695  {
696  HeapFree(GetProcessHeap(), 0, extensions);
698  return;
699  }
700 
701  HeapFree(GetProcessHeap(), 0, extensions);
702 
703  /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
704  * use the contents of szFile to initialize itself */
705  ofn.lpstrFile[0] = TEXT('\0');
708  ofn.nFilterIndex = 0;
709  ofn.lpstrFileTitle = fileTitle;
710  ofn.nMaxFileTitle = 256;
711  ofn.lpstrInitialDir = initialDir;
713 
716 
717  if (success)
718  {
719  /* Check if there is already a entry that holds this filename */
720  if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
721  return;
722 
723  if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
724  return;
725 
727  0,
728  &sfi,
729  sizeof(sfi),
731  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
732 
733  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
734 
735  backgroundItem->bWallpaper = TRUE;
736 
737  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
738  if (FAILED(hr))
739  return;
740  p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
741  if (p)
742  *p = (TCHAR)0;
743  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
744  if (FAILED(hr))
745  return;
746 
747  ZeroMemory(&listItem, sizeof(LV_ITEM));
748  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
749  listItem.state = 0;
750  listItem.pszText = backgroundItem->szDisplayName;
751  listItem.iImage = sfi.iIcon;
752  listItem.iItem = pData->listViewItemCount;
753  listItem.lParam = pData->listViewItemCount;
754 
755  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
756  ListView_SetItemState(hwndBackgroundList,
757  pData->listViewItemCount,
759  LVIS_SELECTED);
760  SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
761 
762  pData->listViewItemCount++;
763  }
764 }
765 
766 
767 static VOID
769 {
770  BackgroundItem *backgroundItem = NULL;
771 
772  pData->backgroundSelection = itemIndex;
773  backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
774 
775  if (pData->pWallpaperBitmap != NULL)
776  {
777  DibFreeImage(pData->pWallpaperBitmap);
778  pData->pWallpaperBitmap = NULL;
779  }
780 
781  if (backgroundItem->bWallpaper != FALSE)
782  {
783  pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
784 
785  if (pData->pWallpaperBitmap == NULL)
786  return;
787  }
788 
789  pData->bWallpaperChanged = TRUE;
790 
792  NULL, TRUE);
793 
795  backgroundItem->bWallpaper);
796 
797  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
798 }
799 
800 
801 static VOID
803 {
804  float scaleX;
805  float scaleY;
806  int scaledWidth;
807  int scaledHeight;
808  int posX, desX;
809  int posY, desY;
810  int fitFillScaleNum, fitFillScaleDen;
811  int fitFillWidth, fitFillHeight;
812  HBRUSH hBrush;
813  int x;
814  int y;
815  HDC hDC;
816  HGDIOBJ hOldObj;
817  RECT rcItem = {
818  MONITOR_LEFT,
819  MONITOR_TOP,
822  };
823 
824  hDC = CreateCompatibleDC(draw->hDC);
825  hOldObj = SelectObject(hDC, pData->hBitmap);
826 
827  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
828  {
829  /* Update desktop background color image */
831  FillRect(hDC, &rcItem, hBrush);
832  DeleteObject(hBrush);
833  }
834  else
835  if (pData->pWallpaperBitmap != NULL)
836  {
837  scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
838  scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
839 
840  scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
841  scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
842 
844 
846 
847  switch (pData->placementSelection)
848  {
849  case PLACEMENT_CENTER:
850  posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
851  posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
852  desX = 0;
853  desY = 0;
854 
855  if (posX < 0) { desX = -posX / 2; posX = 0; }
856  if (posY < 0) { desY = -posY / 2; posY = 0; }
857 
858  if (scaledWidth > MONITOR_WIDTH)
859  scaledWidth = MONITOR_WIDTH;
860 
861  if (scaledHeight > MONITOR_HEIGHT)
862  scaledHeight = MONITOR_HEIGHT;
863 
865  MONITOR_LEFT+posX,
866  MONITOR_TOP+posY,
867  scaledWidth,
868  scaledHeight,
869  desX,
870  desY,
871  pData->pWallpaperBitmap->width - (int)(desX * scaleX),
872  pData->pWallpaperBitmap->height - (int)(desY * scaleY),
873  pData->pWallpaperBitmap->bits,
874  pData->pWallpaperBitmap->info,
876  SRCCOPY);
877  break;
878 
879  case PLACEMENT_STRETCH:
881  MONITOR_LEFT,
882  MONITOR_TOP,
885  0,
886  0,
887  pData->pWallpaperBitmap->width,
888  pData->pWallpaperBitmap->height,
889  pData->pWallpaperBitmap->bits,
890  pData->pWallpaperBitmap->info,
892  SRCCOPY);
893  break;
894 
895  case PLACEMENT_TILE:
896  for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
897  {
898  for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
899  {
900  if ((MONITOR_WIDTH-x) >= scaledWidth)
901  posX = scaledWidth;
902  else
903  posX = MONITOR_WIDTH-x;
904 
905 
906  if ((MONITOR_HEIGHT-y) >= scaledHeight)
907  posY = scaledHeight;
908  else
909  posY = MONITOR_HEIGHT-y;
910 
912  MONITOR_LEFT + x,
913  MONITOR_TOP + y,
914  posX,
915  posY,
916  0,
917  0,
918  pData->pWallpaperBitmap->width * posX / scaledWidth,
919  pData->pWallpaperBitmap->height * posY / scaledHeight,
920  pData->pWallpaperBitmap->bits,
921  pData->pWallpaperBitmap->info,
923  SRCCOPY);
924  }
925 
926  }
927 
928  break;
929 
930  case PLACEMENT_FIT:
931  if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
932  {
933  fitFillScaleNum = MONITOR_WIDTH;
934  fitFillScaleDen = scaledWidth;
935  }
936  else
937  {
938  fitFillScaleNum = MONITOR_HEIGHT;
939  fitFillScaleDen = scaledHeight;
940  }
941 
942  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
943  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
944 
945  posX = (MONITOR_WIDTH - fitFillWidth) / 2;
946  posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
947 
949  MONITOR_LEFT + posX,
950  MONITOR_TOP + posY,
951  fitFillWidth,
952  fitFillHeight,
953  0,
954  0,
955  pData->pWallpaperBitmap->width,
956  pData->pWallpaperBitmap->height,
957  pData->pWallpaperBitmap->bits,
958  pData->pWallpaperBitmap->info,
960  SRCCOPY);
961  break;
962 
963  case PLACEMENT_FILL:
964  if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
965  {
966  fitFillScaleNum = MONITOR_WIDTH;
967  fitFillScaleDen = scaledWidth;
968  }
969  else
970  {
971  fitFillScaleNum = MONITOR_HEIGHT;
972  fitFillScaleDen = scaledHeight;
973  }
974 
975  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
976  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
977 
978  desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
979  desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
980 
982  MONITOR_LEFT,
983  MONITOR_TOP,
986  desX,
987  desY,
988  (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
989  (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
990  pData->pWallpaperBitmap->bits,
991  pData->pWallpaperBitmap->info,
993  SRCCOPY);
994  break;
995  }
996  }
997 
998  GdiTransparentBlt(draw->hDC,
999  draw->rcItem.left, draw->rcItem.top,
1000  draw->rcItem.right-draw->rcItem.left+1,
1001  draw->rcItem.bottom-draw->rcItem.top+1,
1002  hDC,
1003  0, 0,
1004  pData->cxSource, pData->cySource,
1005  0xFF00FF);
1006 
1007  SelectObject(hDC, hOldObj);
1008  DeleteDC(hDC);
1009 }
1010 
1011 
1012 static VOID
1014 {
1015  HKEY regKey;
1016  TCHAR szWallpaper[MAX_PATH];
1017  GpImage *image;
1018  CLSID encoderClsid;
1019  GUID guidFormat;
1020  size_t length = 0;
1021  GpStatus status;
1022 
1024  {
1025  return;
1026  }
1027 
1028  if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1029  {
1030  return;
1031  }
1032 
1033  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1035  {
1036  return;
1037  }
1038 
1039  if (pData->placementSelection == PLACEMENT_TILE)
1040  {
1041  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1042  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1043  }
1044 
1045  if (pData->placementSelection == PLACEMENT_CENTER)
1046  {
1047  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1048  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1049  }
1050 
1051  if (pData->placementSelection == PLACEMENT_STRETCH)
1052  {
1053  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1054  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1055  }
1056 
1057  if (pData->placementSelection == PLACEMENT_FIT)
1058  {
1059  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1060  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1061  }
1062 
1063  if (pData->placementSelection == PLACEMENT_FILL)
1064  {
1065  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1066  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1067  }
1068 
1069  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1070  {
1071  GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1072  if (!image)
1073  {
1074  RegCloseKey(regKey);
1075  return;
1076  }
1077 
1078  GdipGetImageRawFormat(image, &guidFormat);
1079  if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1080  {
1082  RegCloseKey(regKey);
1083  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1084  return;
1085  }
1086 
1087  if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1088  {
1090  RegCloseKey(regKey);
1091  return;
1092  }
1093 
1094  status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1095 
1097 
1098  if (status != Ok)
1099  {
1100  RegCloseKey(regKey);
1101  return;
1102  }
1103 
1104  if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1105  {
1106  RegSetValueEx(regKey,
1107  TEXT("ConvertedWallpaper"),
1108  0,
1109  REG_SZ,
1110  (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1111  (DWORD)((length + 1) * sizeof(TCHAR)));
1112  }
1113 
1114  if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1115  {
1116  RegSetValueEx(regKey,
1117  TEXT("OriginalWallpaper"),
1118  0,
1119  REG_SZ,
1120  (LPBYTE)szWallpaper,
1121  (DWORD)((length + 1) * sizeof(TCHAR)));
1122  }
1123 
1125  }
1126  else
1127  {
1129  }
1130 
1131  RegCloseKey(regKey);
1132 }
1133 
1134 
1135 /* Change system color */
1136 static VOID
1138 {
1139  HKEY hKey;
1140  INT iElement = COLOR_BACKGROUND;
1141  TCHAR clText[16];
1142  BYTE red, green, blue;
1143 
1144  if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1145  {
1146  /* FIXME: these error texts can need internationalization? */
1147  MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1148  TEXT("Error!"), MB_ICONSTOP );
1149  }
1150 
1151  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1153  {
1154  return;
1155  }
1156 
1160 
1161  /* Format string to be set to registry */
1162  StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1163  RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1164  (wcslen(clText) + 1) * sizeof(TCHAR));
1165 
1166  RegCloseKey(hKey);
1167 }
1168 
1171  UINT uMsg,
1172  WPARAM wParam,
1173  LPARAM lParam)
1174 {
1176  struct GdiplusStartupInput gdipStartup;
1177 
1179 
1180  switch (uMsg)
1181  {
1182  case WM_INITDIALOG:
1185  gdipStartup.GdiplusVersion = 1;
1186  gdipStartup.DebugEventCallback = NULL;
1187  gdipStartup.SuppressBackgroundThread = FALSE;
1188  gdipStartup.SuppressExternalCodecs = FALSE;
1189  GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1190  InitBackgroundDialog(hwndDlg, pData);
1191  break;
1192 
1193  case WM_COMMAND:
1194  {
1195  DWORD controlId = LOWORD(wParam);
1197 
1198  switch (controlId)
1199  {
1200  case IDC_COLOR_BUTTON:
1201  if (command == BN_CLICKED)
1202  OnColorButton(hwndDlg, pData);
1203  break;
1204 
1205  case IDC_BROWSE_BUTTON:
1206  if (command == BN_CLICKED)
1207  OnBrowseButton(hwndDlg, pData);
1208  break;
1209 
1210  case IDC_PLACEMENT_COMBO:
1211  if (command == CBN_SELCHANGE)
1212  {
1213  pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1214 
1216 
1217  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1218  }
1219  break;
1220  }
1221  } break;
1222 
1223  case WM_DRAWITEM:
1224  {
1225  LPDRAWITEMSTRUCT drawItem;
1226  drawItem = (LPDRAWITEMSTRUCT)lParam;
1227 
1228  if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1229  {
1230  DrawBackgroundPreview(drawItem, pData);
1231  }
1232 
1233  }
1234  break;
1235 
1236  case WM_NOTIFY:
1237  {
1238  LPNMHDR lpnm = (LPNMHDR)lParam;
1239 
1240  switch(lpnm->code)
1241  {
1242  case PSN_APPLY:
1243  if (pData->bWallpaperChanged)
1245  if (pData->bClrBackgroundChanged)
1246  SetDesktopBackColor(hwndDlg, pData);
1248  return TRUE;
1249 
1250  case LVN_ITEMCHANGED:
1251  {
1253 
1254  if ((nm->uNewState & LVIS_SELECTED) == 0)
1255  return FALSE;
1256 
1257  ListViewItemChanged(hwndDlg, pData, nm->iItem);
1258  }
1259  break;
1260  }
1261  }
1262  break;
1263 
1264  case WM_DESTROY:
1265  if (pData->pWallpaperBitmap != NULL)
1266  DibFreeImage(pData->pWallpaperBitmap);
1267 
1268  DeleteObject(pData->hBitmap);
1269  GdiplusShutdown(pData->gdipToken);
1270  HeapFree(GetProcessHeap(), 0, pData);
1271  break;
1272  }
1273 
1274  return FALSE;
1275 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:29
#define RegQueryValueEx
Definition: winreg.h:524
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
#define StringCchLength
Definition: strsafe.h:829
#define LV_ITEM
Definition: commctrl.h:2333
GLeglImageOES image
Definition: gl.h:2204
#define IDC_BROWSE_BUTTON
Definition: resource.h:30
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 MAKEINTRESOURCE
Definition: winuser.h:591
const uint16_t * PCWSTR
Definition: typedefs.h:56
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5021
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
HBITMAP hBitmap
Definition: background.c:77
#define IMAGE_ICON
Definition: winuser.h:212
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:1013
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
#define LVCF_WIDTH
Definition: commctrl.h:2583
PLACEMENT_VALUE
Definition: background.c:31
#define LVSIL_SMALL
Definition: commctrl.h:2295
#define CC_ANYCOLOR
Definition: commdlg.h:58
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT uNewState
Definition: commctrl.h:3032
HRESULT hr
Definition: shlfolder.c:183
#define KEY_SET_VALUE
Definition: nt_native.h:1017
GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR *filename, GpImage **image)
Definition: image.c:2928
LPSTR lpstrFileTitle
Definition: commdlg.h:338
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define _tcsicmp
Definition: xmlstorage.h:205
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
HWND hwndOwner
Definition: commdlg.h:330
#define ChooseColor
Definition: commdlg.h:661
#define REG_BINARY
Definition: nt_native.h:1496
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1351
CHOOSECOLORA CHOOSECOLOR
Definition: commdlg.h:654
#define PathCombine
Definition: shlwapi.h:825
#define CC_RGBINIT
Definition: commdlg.h:50
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define LV_COLUMN
Definition: commctrl.h:2543
COLORREF desktop_color
Definition: desk.h:106
struct _BACKGROUND_DATA * PBACKGROUND_DATA
#define IDS_NONE
Definition: resource.h:123
#define ExpandEnvironmentStrings
Definition: winbase.h:3614
#define LVN_ITEMCHANGED
Definition: commctrl.h:3127
struct _BACKGROUND_DATA BACKGROUND_DATA
#define SHGetFolderPath
Definition: shlobj.h:2010
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
#define SystemParametersInfo
Definition: winuser.h:5833
LONG top
Definition: windef.h:307
OPENFILENAME ofn
Definition: main.cpp:37
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
#define GetRValue(quad)
Definition: precomp.h:64
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static UINT AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
Definition: background.c:186
GLuint buffer
Definition: glext.h:5915
#define SM_CYSMICON
Definition: winuser.h:1003
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static int fd
Definition: io.c:51
HINSTANCE hApplet
Definition: access.c:17
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
UINT_PTR WPARAM
Definition: windef.h:207
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define SendDlgItemMessage
Definition: winuser.h:5817
#define MB_ICONSTOP
Definition: winuser.h:797
#define PSN_APPLY
Definition: prsht.h:117
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
LONG left
Definition: windef.h:306
HRESULT GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
Definition: background.c:88
int32_t INT_PTR
Definition: typedefs.h:63
#define COLORONCOLOR
Definition: wingdi.h:953
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
Definition: image.c:4428
const char * filename
Definition: ioapi.h:135
LONG right
Definition: windef.h:308
COLORREF custom_colors[16]
Definition: background.c:73
#define E_FAIL
Definition: ddrawi.h:102
HIMAGELIST himl
#define SHGFI_SMALLICON
Definition: shellapi.h:174
#define IDS_FIT
Definition: resource.h:58
int32_t INT
Definition: typedefs.h:57
int placementSelection
Definition: background.c:70
#define IDS_FILL
Definition: resource.h:59
#define SetWindowLongPtr
Definition: treelist.c:70
#define GetOpenFileName
Definition: commdlg.h:665
#define CB_GETCURSEL
Definition: winuser.h:1925
WPARAM wParam
Definition: combotst.c:138
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
CHAR * LPTSTR
Definition: xmlstorage.h:192
struct tagNMHDR * LPNMHDR
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
DWORD nMaxFile
Definition: commdlg.h:337
#define ILC_COLOR32
Definition: commctrl.h:354
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define LVIF_TEXT
Definition: commctrl.h:2305
#define LVCF_SUBITEM
Definition: commctrl.h:2585
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4946
#define IDS_CENTER
Definition: resource.h:55
UINT code
Definition: winuser.h:3134
#define SM_CXSCREEN
Definition: winuser.h:949
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:549
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
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
unsigned char * LPBYTE
Definition: typedefs.h:53
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2292
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:615
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2669
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
long LONG
Definition: pedump.c:60
#define StringCbPrintfEx
Definition: strsafe.h:600
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
ULONG_PTR gdipToken
Definition: background.c:81
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define CB_INSERTSTRING
Definition: winuser.h:1939
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2300
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2315
LONG_PTR LPARAM
Definition: windef.h:208
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
Definition: image.c:2306
#define GetBValue(quad)
Definition: precomp.h:66
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:4970
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
#define IDC_MONITOR
Definition: resource.h:28
PLACEMENT
Definition: background.c:18
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define FindFirstFile
Definition: winbase.h:3622
GLclampf GLclampf blue
Definition: gl.h:1740
#define GetGValue(quad)
Definition: precomp.h:65
#define IDS_TILE
Definition: resource.h:57
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_COLOR_BUTTON
Definition: resource.h:31
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
DebugEventProc DebugEventCallback
Definition: gdiplusinit.h:35
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
Definition: uimain.c:88
char TCHAR
Definition: xmlstorage.h:189
#define SM_CYSCREEN
Definition: winuser.h:950
#define _T(x)
Definition: vfdio.h:22
BOOL SuppressBackgroundThread
Definition: gdiplusinit.h:36
#define StringCbCat
Definition: strsafe.h:334
GLsizeiptr size
Definition: glext.h:5919
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:366
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PDIBITMAP DibLoadImage(LPTSTR lpFilename)
Definition: dibitmap.c:13
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:413
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
LONG HRESULT
Definition: typedefs.h:78
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define FindNextFile
Definition: winbase.h:3628
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:129
DWORD COLORREF
Definition: windef.h:300
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2039
#define MONITOR_BOTTOM
Definition: background.c:47
#define StringCbPrintf
Definition: strsafe.h:544
BOOL bClrBackgroundChanged
Definition: background.c:64
#define MAX_PATH
Definition: compat.h:26
void WINAPI GdiplusShutdown(ULONG_PTR)
DWORD lStructSize
Definition: commdlg.h:329
#define LVIF_IMAGE
Definition: commctrl.h:2306
const GLubyte * c
Definition: glext.h:8905
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define IDC_BACKGROUND_LIST
Definition: resource.h:27
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
int WINAPI GetSystemMetrics(_In_ int)
GLclampf green
Definition: gl.h:1740
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
#define MONITOR_TOP
Definition: background.c:45
BackgroundItem backgroundItems[MAX_BACKGROUNDS]
Definition: background.c:66
#define success(from, fromstr, to, tostr)
#define red
Definition: linetest.c:67
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
#define GetObject
Definition: wingdi.h:4467
#define IDS_BACKGROUND_COMDLG_FILTER
Definition: resource.h:33
#define SM_CXSMICON
Definition: winuser.h:1002
TCHAR szDisplayName[256]
Definition: background.c:57
#define StringCbCopy
Definition: strsafe.h:155
#define SHRegGetPath
Definition: shlwapi.h:196
static const WCHAR L[]
Definition: oid.c:1250
#define DWLP_USER
Definition: winuser.h:866
static VOID ListViewItemChanged(HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
Definition: background.c:768
BOOL bWallpaperChanged
Definition: background.c:63
#define ILC_MASK
Definition: commctrl.h:347
int backgroundSelection
Definition: background.c:71
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define MessageBox
Definition: winuser.h:5797
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define CB_SETCURSEL
Definition: winuser.h:1943
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:4997
#define WM_COMMAND
Definition: winuser.h:1722
unsigned char BYTE
Definition: xxhash.c:193
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1137
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1324
Status
Definition: gdiplustypes.h:24
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
uint32_t cc
Definition: isohybrid.c:75
static HDC hDC
Definition: 3dtext.c:33
ULONG_PTR SIZE_T
Definition: typedefs.h:79
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define S_OK
Definition: intsafe.h:59
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
Definition: desk.h:43
PDIBITMAP pWallpaperBitmap
Definition: background.c:68
BOOL WINAPI DeleteDC(_In_ HDC)
LPSTR lpstrFile
Definition: commdlg.h:336
static float(__cdecl *square_half_float)(float x
struct tagNMLISTVIEW * LPNMLISTVIEW
HICON hIcon
Definition: msconfig.c:44
unsigned char dummy
Definition: maze.c:118
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define MONITOR_LEFT
Definition: background.c:44
#define IDI_SHELL_NO
Definition: bl.h:1331
static VOID InitBackgroundDialog(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:465
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:633
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:802
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
LPCSTR lpstrFilter
Definition: commdlg.h:332
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define SB_BOTTOM
Definition: winuser.h:577
#define CSIDL_FLAG_CREATE
#define _tcstok
Definition: tchar.h:1416
#define LVFINDINFO
Definition: commctrl.h:2459
#define IMAGE_BITMAP
Definition: winuser.h:211
#define SM_CXVSCROLL
Definition: winuser.h:951
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CBN_SELCHANGE
Definition: winuser.h:1961
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
#define WM_DRAWITEM
Definition: winuser.h:1627
_Out_opt_ int * cx
Definition: commctrl.h:581
#define LVFI_STRING
Definition: commctrl.h:2433
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2466
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2208
#define SendMessage
Definition: winuser.h:5818
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define LVIF_PARAM
Definition: commctrl.h:2307
GLuint res
Definition: glext.h:9613
#define SHGetFileInfo
Definition: shellapi.h:693
GLOBAL_DATA g_GlobalData
Definition: background.c:84
#define c
Definition: ke_i.h:80
HICON hIcon
Definition: shellapi.h:363
#define IDC_PLACEMENT_COMBO
Definition: resource.h:32
#define HIWORD(l)
Definition: typedefs.h:246
#define IDS_STRETCH
Definition: resource.h:56
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
LONG bottom
Definition: windef.h:309
#define LoadImage
Definition: winuser.h:5790
static HBITMAP bitmap
Definition: clipboard.c:1344
#define MONITOR_RIGHT
Definition: background.c:46
#define COLOR_BACKGROUND
Definition: hardware.h:164
static HBITMAP
Definition: button.c:44
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
#define MONITOR_HEIGHT
Definition: background.c:50
DWORD nFilterIndex
Definition: commdlg.h:335
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define LVIF_STATE
Definition: commctrl.h:2308
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define MONITOR_WIDTH
Definition: background.c:49
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
#define SHGFI_ICON
Definition: shellapi.h:162
HBRUSH WINAPI GetSysColorBrush(_In_ int)
GLuint64EXT * result
Definition: glext.h:11304
#define HWND_BROADCAST
Definition: winuser.h:1190
#define GetWindowsDirectory
Definition: winbase.h:3697
static SERVICE_STATUS status
Definition: service.c:31
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define LOWORD(l)
Definition: pedump.c:82
static HMODULE hShell32
Definition: string.c:34
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:403
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define SRCCOPY
Definition: wingdi.h:332
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define LoadString
Definition: winuser.h:5794
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:291
#define MAX_BACKGROUNDS
Definition: background.c:16
#define WM_NOTIFY
Definition: richedit.h:61
#define CC_FULLOPEN
Definition: commdlg.h:51
#define SUCCEEDED(hr)
Definition: intsafe.h:57
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 WM_VSCROLL
Definition: winuser.h:1726
INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: background.c:1170
DWORD nMaxFileTitle
Definition: commdlg.h:339
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
DWORD Flags
Definition: commdlg.h:342
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
Definition: ps.c:97