ReactOS  0.4.14-dev-1296-g56aa513
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  LPTSTR filter;
639  LPTSTR extensions;
640  BackgroundItem *backgroundItem = NULL;
641  SHFILEINFO sfi;
642  LV_ITEM listItem;
643  HWND hwndBackgroundList;
644  TCHAR *p;
645  HRESULT hr;
646  TCHAR filterdesc[MAX_PATH];
647  TCHAR *c;
648  size_t sizeRemain;
649  SIZE_T buffersize;
650  BOOL success;
652 
653  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
654  himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
655 
656  ZeroMemory(&ofn, sizeof(OPENFILENAME));
657 
658  ofn.lStructSize = sizeof(OPENFILENAME);
659  ofn.hwndOwner = hwndDlg;
661 
662  LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
663 
664  extensions = GdipGetSupportedFileExtensions();
665  if (!extensions)
666  {
667  return;
668  }
669 
670  buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
671 
673  if (!filter)
674  {
675  HeapFree(GetProcessHeap(), 0, extensions);
676  return;
677  }
678 
679  sizeRemain = buffersize;
680  c = filter;
681 
682  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
683  {
684  HeapFree(GetProcessHeap(), 0, extensions);
686  return;
687  }
688 
689  c++;
690  sizeRemain -= sizeof(*c);
691 
692  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
693  {
694  HeapFree(GetProcessHeap(), 0, extensions);
696  return;
697  }
698 
699  HeapFree(GetProcessHeap(), 0, extensions);
700 
701  /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
702  * use the contents of szFile to initialize itself */
703  ofn.lpstrFile[0] = TEXT('\0');
706  ofn.nFilterIndex = 0;
707  ofn.lpstrFileTitle = fileTitle;
708  ofn.nMaxFileTitle = 256;
711 
714 
715  if (success)
716  {
717  /* Check if there is already a entry that holds this filename */
718  if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
719  return;
720 
721  if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
722  return;
723 
725  0,
726  &sfi,
727  sizeof(sfi),
729  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
730 
731  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
732 
733  backgroundItem->bWallpaper = TRUE;
734 
735  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
736  if (FAILED(hr))
737  return;
738  p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
739  if (p)
740  *p = (TCHAR)0;
741  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
742  if (FAILED(hr))
743  return;
744 
745  ZeroMemory(&listItem, sizeof(LV_ITEM));
746  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
747  listItem.state = 0;
748  listItem.pszText = backgroundItem->szDisplayName;
749  listItem.iImage = sfi.iIcon;
750  listItem.iItem = pData->listViewItemCount;
751  listItem.lParam = pData->listViewItemCount;
752 
753  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
754  ListView_SetItemState(hwndBackgroundList,
755  pData->listViewItemCount,
757  LVIS_SELECTED);
758  SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
759 
760  pData->listViewItemCount++;
761  }
762 }
763 
764 
765 static VOID
767 {
768  BackgroundItem *backgroundItem = NULL;
769 
770  pData->backgroundSelection = itemIndex;
771  backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
772 
773  if (pData->pWallpaperBitmap != NULL)
774  {
775  DibFreeImage(pData->pWallpaperBitmap);
776  pData->pWallpaperBitmap = NULL;
777  }
778 
779  if (backgroundItem->bWallpaper != FALSE)
780  {
781  pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
782 
783  if (pData->pWallpaperBitmap == NULL)
784  return;
785  }
786 
787  pData->bWallpaperChanged = TRUE;
788 
790  NULL, TRUE);
791 
793  backgroundItem->bWallpaper);
794 
795  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
796 }
797 
798 
799 static VOID
801 {
802  float scaleX;
803  float scaleY;
804  int scaledWidth;
805  int scaledHeight;
806  int posX, desX;
807  int posY, desY;
808  int fitFillScaleNum, fitFillScaleDen;
809  int fitFillWidth, fitFillHeight;
810  HBRUSH hBrush;
811  int x;
812  int y;
813  HDC hDC;
814  HGDIOBJ hOldObj;
815  RECT rcItem = {
816  MONITOR_LEFT,
817  MONITOR_TOP,
820  };
821 
822  hDC = CreateCompatibleDC(draw->hDC);
823  hOldObj = SelectObject(hDC, pData->hBitmap);
824 
825  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
826  {
827  /* Update desktop background color image */
829  FillRect(hDC, &rcItem, hBrush);
830  DeleteObject(hBrush);
831  }
832  else
833  if (pData->pWallpaperBitmap != NULL)
834  {
835  scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
836  scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
837 
838  scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
839  scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
840 
842 
844 
845  switch (pData->placementSelection)
846  {
847  case PLACEMENT_CENTER:
848  posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
849  posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
850  desX = 0;
851  desY = 0;
852 
853  if (posX < 0) { desX = -posX / 2; posX = 0; }
854  if (posY < 0) { desY = -posY / 2; posY = 0; }
855 
856  if (scaledWidth > MONITOR_WIDTH)
857  scaledWidth = MONITOR_WIDTH;
858 
859  if (scaledHeight > MONITOR_HEIGHT)
860  scaledHeight = MONITOR_HEIGHT;
861 
863  MONITOR_LEFT+posX,
864  MONITOR_TOP+posY,
865  scaledWidth,
866  scaledHeight,
867  desX,
868  desY,
869  pData->pWallpaperBitmap->width - (int)(desX * scaleX),
870  pData->pWallpaperBitmap->height - (int)(desY * scaleY),
871  pData->pWallpaperBitmap->bits,
872  pData->pWallpaperBitmap->info,
874  SRCCOPY);
875  break;
876 
877  case PLACEMENT_STRETCH:
879  MONITOR_LEFT,
880  MONITOR_TOP,
883  0,
884  0,
885  pData->pWallpaperBitmap->width,
886  pData->pWallpaperBitmap->height,
887  pData->pWallpaperBitmap->bits,
888  pData->pWallpaperBitmap->info,
890  SRCCOPY);
891  break;
892 
893  case PLACEMENT_TILE:
894  for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
895  {
896  for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
897  {
898  if ((MONITOR_WIDTH-x) >= scaledWidth)
899  posX = scaledWidth;
900  else
901  posX = MONITOR_WIDTH-x;
902 
903 
904  if ((MONITOR_HEIGHT-y) >= scaledHeight)
905  posY = scaledHeight;
906  else
907  posY = MONITOR_HEIGHT-y;
908 
910  MONITOR_LEFT + x,
911  MONITOR_TOP + y,
912  posX,
913  posY,
914  0,
915  0,
916  pData->pWallpaperBitmap->width * posX / scaledWidth,
917  pData->pWallpaperBitmap->height * posY / scaledHeight,
918  pData->pWallpaperBitmap->bits,
919  pData->pWallpaperBitmap->info,
921  SRCCOPY);
922  }
923 
924  }
925 
926  break;
927 
928  case PLACEMENT_FIT:
929  if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
930  {
931  fitFillScaleNum = MONITOR_WIDTH;
932  fitFillScaleDen = scaledWidth;
933  }
934  else
935  {
936  fitFillScaleNum = MONITOR_HEIGHT;
937  fitFillScaleDen = scaledHeight;
938  }
939 
940  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
941  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
942 
943  posX = (MONITOR_WIDTH - fitFillWidth) / 2;
944  posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
945 
947  MONITOR_LEFT + posX,
948  MONITOR_TOP + posY,
949  fitFillWidth,
950  fitFillHeight,
951  0,
952  0,
953  pData->pWallpaperBitmap->width,
954  pData->pWallpaperBitmap->height,
955  pData->pWallpaperBitmap->bits,
956  pData->pWallpaperBitmap->info,
958  SRCCOPY);
959  break;
960 
961  case PLACEMENT_FILL:
962  if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
963  {
964  fitFillScaleNum = MONITOR_WIDTH;
965  fitFillScaleDen = scaledWidth;
966  }
967  else
968  {
969  fitFillScaleNum = MONITOR_HEIGHT;
970  fitFillScaleDen = scaledHeight;
971  }
972 
973  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
974  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
975 
976  desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
977  desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
978 
980  MONITOR_LEFT,
981  MONITOR_TOP,
984  desX,
985  desY,
986  (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
987  (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
988  pData->pWallpaperBitmap->bits,
989  pData->pWallpaperBitmap->info,
991  SRCCOPY);
992  break;
993  }
994  }
995 
996  GdiTransparentBlt(draw->hDC,
997  draw->rcItem.left, draw->rcItem.top,
998  draw->rcItem.right-draw->rcItem.left+1,
999  draw->rcItem.bottom-draw->rcItem.top+1,
1000  hDC,
1001  0, 0,
1002  pData->cxSource, pData->cySource,
1003  0xFF00FF);
1004 
1005  SelectObject(hDC, hOldObj);
1006  DeleteDC(hDC);
1007 }
1008 
1009 
1010 static VOID
1012 {
1013  HKEY regKey;
1014  TCHAR szWallpaper[MAX_PATH];
1015  GpImage *image;
1016  CLSID encoderClsid;
1017  GUID guidFormat;
1018  size_t length = 0;
1019  GpStatus status;
1020 
1022  {
1023  return;
1024  }
1025 
1026  if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1027  {
1028  return;
1029  }
1030 
1031  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1033  {
1034  return;
1035  }
1036 
1037  if (pData->placementSelection == PLACEMENT_TILE)
1038  {
1039  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1040  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1041  }
1042 
1043  if (pData->placementSelection == PLACEMENT_CENTER)
1044  {
1045  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1046  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1047  }
1048 
1049  if (pData->placementSelection == PLACEMENT_STRETCH)
1050  {
1051  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1052  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1053  }
1054 
1055  if (pData->placementSelection == PLACEMENT_FIT)
1056  {
1057  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1058  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1059  }
1060 
1061  if (pData->placementSelection == PLACEMENT_FILL)
1062  {
1063  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1064  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1065  }
1066 
1067  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1068  {
1069  GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1070  if (!image)
1071  {
1072  RegCloseKey(regKey);
1073  return;
1074  }
1075 
1076  GdipGetImageRawFormat(image, &guidFormat);
1077  if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1078  {
1080  RegCloseKey(regKey);
1081  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1082  return;
1083  }
1084 
1085  if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1086  {
1088  RegCloseKey(regKey);
1089  return;
1090  }
1091 
1092  status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1093 
1095 
1096  if (status != Ok)
1097  {
1098  RegCloseKey(regKey);
1099  return;
1100  }
1101 
1102  if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1103  {
1104  RegSetValueEx(regKey,
1105  TEXT("ConvertedWallpaper"),
1106  0,
1107  REG_SZ,
1108  (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1109  (DWORD)((length + 1) * sizeof(TCHAR)));
1110  }
1111 
1112  if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1113  {
1114  RegSetValueEx(regKey,
1115  TEXT("OriginalWallpaper"),
1116  0,
1117  REG_SZ,
1118  (LPBYTE)szWallpaper,
1119  (DWORD)((length + 1) * sizeof(TCHAR)));
1120  }
1121 
1123  }
1124  else
1125  {
1127  }
1128 
1129  RegCloseKey(regKey);
1130 }
1131 
1132 
1133 /* Change system color */
1134 static VOID
1136 {
1137  HKEY hKey;
1138  INT iElement = COLOR_BACKGROUND;
1139  TCHAR clText[16];
1140  BYTE red, green, blue;
1141 
1142  if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1143  {
1144  /* FIXME: these error texts can need internationalization? */
1145  MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1146  TEXT("Error!"), MB_ICONSTOP );
1147  }
1148 
1149  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1151  {
1152  return;
1153  }
1154 
1158 
1159  /* Format string to be set to registry */
1160  StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1161  RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1162  (wcslen(clText) + 1) * sizeof(TCHAR));
1163 
1164  RegCloseKey(hKey);
1165 }
1166 
1169  UINT uMsg,
1170  WPARAM wParam,
1171  LPARAM lParam)
1172 {
1174  struct GdiplusStartupInput gdipStartup;
1175 
1177 
1178  switch (uMsg)
1179  {
1180  case WM_INITDIALOG:
1183  gdipStartup.GdiplusVersion = 1;
1184  gdipStartup.DebugEventCallback = NULL;
1185  gdipStartup.SuppressBackgroundThread = FALSE;
1186  gdipStartup.SuppressExternalCodecs = FALSE;
1187  GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1188  InitBackgroundDialog(hwndDlg, pData);
1189  break;
1190 
1191  case WM_COMMAND:
1192  {
1193  DWORD controlId = LOWORD(wParam);
1195 
1196  switch (controlId)
1197  {
1198  case IDC_COLOR_BUTTON:
1199  if (command == BN_CLICKED)
1200  OnColorButton(hwndDlg, pData);
1201  break;
1202 
1203  case IDC_BROWSE_BUTTON:
1204  if (command == BN_CLICKED)
1205  OnBrowseButton(hwndDlg, pData);
1206  break;
1207 
1208  case IDC_PLACEMENT_COMBO:
1209  if (command == CBN_SELCHANGE)
1210  {
1211  pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1212 
1214 
1215  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1216  }
1217  break;
1218  }
1219  } break;
1220 
1221  case WM_DRAWITEM:
1222  {
1223  LPDRAWITEMSTRUCT drawItem;
1224  drawItem = (LPDRAWITEMSTRUCT)lParam;
1225 
1226  if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1227  {
1228  DrawBackgroundPreview(drawItem, pData);
1229  }
1230 
1231  }
1232  break;
1233 
1234  case WM_NOTIFY:
1235  {
1236  LPNMHDR lpnm = (LPNMHDR)lParam;
1237 
1238  switch(lpnm->code)
1239  {
1240  case PSN_APPLY:
1241  if (pData->bWallpaperChanged)
1243  if (pData->bClrBackgroundChanged)
1244  SetDesktopBackColor(hwndDlg, pData);
1246  return TRUE;
1247 
1248  case LVN_ITEMCHANGED:
1249  {
1251 
1252  if ((nm->uNewState & LVIS_SELECTED) == 0)
1253  return FALSE;
1254 
1255  ListViewItemChanged(hwndDlg, pData, nm->iItem);
1256  }
1257  break;
1258  }
1259  }
1260  break;
1261 
1262  case WM_DESTROY:
1263  if (pData->pWallpaperBitmap != NULL)
1264  DibFreeImage(pData->pWallpaperBitmap);
1265 
1266  DeleteObject(pData->hBitmap);
1267  GdiplusShutdown(pData->gdipToken);
1268  HeapFree(GetProcessHeap(), 0, pData);
1269  break;
1270  }
1271 
1272  return FALSE;
1273 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:29
#define RegQueryValueEx
Definition: winreg.h:524
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#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:1011
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
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:122
#define ExpandEnvironmentStrings
Definition: winbase.h:3614
#define LVN_ITEMCHANGED
Definition: commctrl.h:3127
struct _BACKGROUND_DATA BACKGROUND_DATA
#define SHGetFolderPath
Definition: shlobj.h:2009
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
#define GetRValue(rgb)
Definition: wingdi.h:2934
#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:399
#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 GetGValue(rgb)
Definition: wingdi.h:2935
#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
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 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:403
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:2038
#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:766
BOOL bWallpaperChanged
Definition: background.c:63
#define ILC_MASK
Definition: commctrl.h:347
int backgroundSelection
Definition: background.c:71
unsigned char BYTE
Definition: mem.h:68
#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
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1135
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:800
__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
#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 GetBValue(rgb)
Definition: wingdi.h:2936
#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:402
#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:1168
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