ReactOS  0.4.13-dev-99-g7e18b6d
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  token = _tcstok(szFileTypes, separators);
207  while (token != NULL)
208  {
209  if (!PathCombine(szSearchPath, wallpaperDirectory, token))
210  {
211  HeapFree(GetProcessHeap(), 0, szFileTypes);
212  return i;
213  }
214 
215  hFind = FindFirstFile(szSearchPath, &fd);
216  while (hFind != INVALID_HANDLE_VALUE)
217  {
219 
220  if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
221  {
222  FindClose(hFind);
223  HeapFree(GetProcessHeap(), 0, szFileTypes);
224  return i;
225  }
226 
227  /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
228  if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
229  {
231  0,
232  &sfi,
233  sizeof(sfi),
236  if (himl == NULL)
237  break;
238 
239  if (i++ == 0)
240  {
241  (void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
242  }
243 
244  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
245 
246  backgroundItem->bWallpaper = TRUE;
247 
248  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
249  if (FAILED(hr))
250  {
251  FindClose(hFind);
252  HeapFree(GetProcessHeap(), 0, szFileTypes);
253  return i;
254  }
255 
256  PathRemoveExtension(backgroundItem->szDisplayName);
257 
258  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
259  if (FAILED(hr))
260  {
261  FindClose(hFind);
262  HeapFree(GetProcessHeap(), 0, szFileTypes);
263  return i;
264  }
265 
266  ZeroMemory(&listItem, sizeof(LV_ITEM));
267  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
268  listItem.pszText = backgroundItem->szDisplayName;
269  listItem.state = 0;
270  listItem.iImage = sfi.iIcon;
271  listItem.iItem = pData->listViewItemCount;
272  listItem.lParam = pData->listViewItemCount;
273 
274  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
275 
276  pData->listViewItemCount++;
277  }
278 
279  if (!FindNextFile(hFind, &fd))
280  break;
281  }
282 
283  token = _tcstok(NULL, separators);
284  FindClose(hFind);
285  }
286 
287  HeapFree(GetProcessHeap(), 0, szFileTypes);
288 
289  return i;
290 }
291 
292 
293 /* Add the images in the C:\ReactOS, the wallpaper directory and the current wallpaper if any */
294 static VOID
296 {
297  TCHAR szSearchPath[MAX_PATH];
298  LV_ITEM listItem;
300  RECT clientRect;
301  HKEY regKey;
302  SHFILEINFO sfi;
304  TCHAR wallpaperFilename[MAX_PATH];
305  TCHAR originalWallpaper[MAX_PATH];
306  DWORD bufferSize = sizeof(wallpaperFilename);
308  DWORD varType = REG_SZ;
309  LONG result;
310  UINT i = 0;
311  BackgroundItem *backgroundItem = NULL;
312  HWND hwndBackgroundList;
313  HRESULT hr;
314 
315  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
316 
317  GetClientRect(hwndBackgroundList, &clientRect);
318 
319  /* Add a new column to the list */
320  ZeroMemory(&dummy, sizeof(LV_COLUMN));
321  dummy.mask = LVCF_SUBITEM | LVCF_WIDTH;
322  dummy.iSubItem = 0;
323  dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
324  (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
325 
326  /* Add the "None" item */
327  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
328  backgroundItem->bWallpaper = FALSE;
330  IDS_NONE,
331  backgroundItem->szDisplayName,
332  sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
333 
334  ZeroMemory(&listItem, sizeof(LV_ITEM));
335  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
336  listItem.state = 0;
337  listItem.pszText = backgroundItem->szDisplayName;
338  listItem.iImage = -1;
339  listItem.iItem = pData->listViewItemCount;
340  listItem.lParam = pData->listViewItemCount;
341 
342  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
343  ListView_SetItemState(hwndBackgroundList,
344  pData->listViewItemCount,
346  LVIS_SELECTED);
347 
348  pData->listViewItemCount++;
349 
350  /* Add current wallpaper if any */
351  result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
352  if (result == ERROR_SUCCESS)
353  {
354  result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
355  if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
356  {
357  bufferSize = sizeof(originalWallpaper);
358  result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
359 
360  /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
361  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
362  {
363  bufferSize = sizeof(originalWallpaper);
364  result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
365 
366  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
367  {
368  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
369  if (FAILED(hr))
370  {
371  RegCloseKey(regKey);
372  return;
373  }
374  }
375  }
376 
377  /* Allow environment variables in file name */
378  if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
379  {
380  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
381  if (FAILED(hr))
382  {
383  RegCloseKey(regKey);
384  return;
385  }
386  }
387 
388  himl = (HIMAGELIST)SHGetFileInfo(wallpaperFilename,
389  0,
390  &sfi,
391  sizeof(sfi),
394  if (himl != NULL)
395  {
396  if (i++ == 0)
397  {
398  (void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
399  }
400 
401  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
402 
403  backgroundItem->bWallpaper = TRUE;
404 
405  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
406  if (FAILED(hr))
407  {
408  RegCloseKey(regKey);
409  return;
410  }
411 
412  PathRemoveExtension(backgroundItem->szDisplayName);
413 
414  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
415  if (FAILED(hr))
416  {
417  RegCloseKey(regKey);
418  return;
419  }
420 
421  ZeroMemory(&listItem, sizeof(LV_ITEM));
422  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
423  listItem.state = 0;
424  listItem.pszText = backgroundItem->szDisplayName;
425  listItem.iImage = sfi.iIcon;
426  listItem.iItem = pData->listViewItemCount;
427  listItem.lParam = pData->listViewItemCount;
428 
429  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
430  ListView_SetItemState(hwndBackgroundList,
431  pData->listViewItemCount,
433  LVIS_SELECTED);
434 
435  pData->listViewItemCount++;
436  }
437  }
438 
439  RegCloseKey(regKey);
440  }
441 
442  /* Add all the images in the C:\ReactOS directory. */
443  if (GetWindowsDirectory(szSearchPath, MAX_PATH))
444  {
445  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
446  }
447 
448  /* Add all the images in the wallpaper directory. */
449  if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
450  {
451  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
452  }
453 }
454 
455 
456 static VOID
458 {
459  TCHAR szString[256];
460  HKEY regKey;
461  TCHAR szBuffer[3];
462  DWORD bufferSize = sizeof(szBuffer);
463  BITMAP bitmap;
464 
465  AddListViewItems(hwndDlg, pData);
466 
467  LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
469 
470  LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
472 
473  LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
475 
476  LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
478 
479  LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
481 
483  pData->placementSelection = PLACEMENT_CENTER;
484 
486  if (pData->hBitmap != NULL)
487  {
488  GetObject(pData->hBitmap, sizeof(BITMAP), &bitmap);
489 
490  pData->cxSource = bitmap.bmWidth;
491  pData->cySource = bitmap.bmHeight;
492  }
493 
494  /* Load the default settings from the registry */
495  if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
496  {
497  return;
498  }
499 
500  if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
501  {
502  if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
503  {
505  pData->placementSelection = PLACEMENT_CENTER;
506  }
507 
508  if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
509  {
511  pData->placementSelection = PLACEMENT_STRETCH;
512  }
513 
514  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
515  {
517  pData->placementSelection = PLACEMENT_FIT;
518  }
519 
520  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
521  {
523  pData->placementSelection = PLACEMENT_FILL;
524  }
525  }
526 
527  if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
528  {
529  if (_ttoi(szBuffer) == 1)
530  {
532  pData->placementSelection = PLACEMENT_TILE;
533  }
534  }
535 
536  RegCloseKey(regKey);
537 }
538 
539 
540 static VOID
542 {
543  /* Load custom colors from Registry */
544  HKEY hKey = NULL;
546  CHOOSECOLOR cc;
547 
548  res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
550  /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
551  if (res == ERROR_SUCCESS)
552  {
553  /* Key opened */
554  DWORD dwType = REG_BINARY;
555  DWORD cbData = sizeof(pData->custom_colors);
556  res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
557  (LPBYTE)pData->custom_colors, &cbData);
558  RegCloseKey(hKey);
559  hKey = NULL;
560  }
561 
562  /* Launch ChooseColor() dialog */
563 
564  cc.lStructSize = sizeof(CHOOSECOLOR);
565  cc.hwndOwner = hwndDlg;
566  cc.hInstance = NULL;
567  cc.rgbResult = g_GlobalData.desktop_color;
568  cc.lpCustColors = pData->custom_colors;
569  cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
570  CC_FULLOPEN | /* opens dialog in full size */
571  CC_RGBINIT ; /* init chosen color by rgbResult value */
572  cc.lCustData = 0;
573  cc.lpfnHook = NULL;
574  cc.lpTemplateName = NULL;
575  if (ChooseColor(&cc))
576  {
577  /* Save selected color to var */
578  g_GlobalData.desktop_color = cc.rgbResult;
579  pData->bClrBackgroundChanged = TRUE;
580 
581  /* Apply button will be activated */
582  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
583 
584  /* Window will be updated :) */
586 
587  /* Save custom colors to reg. To this moment key must be created already. See above */
588  res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
589  KEY_SET_VALUE, &hKey);
590  if (res == ERROR_SUCCESS)
591  {
592  /* Key opened */
593  RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
594  (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
595  RegCloseKey(hKey);
596  hKey = NULL;
597  }
598  }
599 }
600 
601 
602 /*
603  * ListView_FindItem() Macro: Searches for a list-view item with the specified
604  * characteristics. Returns the index of the item if successful, or -1 otherwise
605  */
606 static BOOL
608 {
609  LVFINDINFO lvfi;
610  int retVal;
611 
612  lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
613  lvfi.psz = tszFileName; /* String to search */
614 
615  /* Other items of this structure are not valid, besacuse flags are not set. */
616  retVal = ListView_FindItem(hwndList, -1, &lvfi);
617  if (retVal != -1)
618  return TRUE; /* item found! */
619 
620  return FALSE; /* item not found. */
621 }
622 
623 
624 static VOID
626 {
629  TCHAR fileTitle[256];
630  LPTSTR filter;
631  LPTSTR extensions;
632  BackgroundItem *backgroundItem = NULL;
633  SHFILEINFO sfi;
634  LV_ITEM listItem;
635  HWND hwndBackgroundList;
636  TCHAR *p;
637  HRESULT hr;
638  TCHAR filterdesc[MAX_PATH];
639  TCHAR *c;
640  size_t sizeRemain;
641  SIZE_T buffersize;
642  BOOL success;
643 
644  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
645 
646  ZeroMemory(&ofn, sizeof(OPENFILENAME));
647 
648  ofn.lStructSize = sizeof(OPENFILENAME);
649  ofn.hwndOwner = hwndDlg;
651 
652  LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
653 
654  extensions = GdipGetSupportedFileExtensions();
655  if (!extensions)
656  {
657  return;
658  }
659 
660  buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
661 
663  if (!filter)
664  {
665  HeapFree(GetProcessHeap(), 0, extensions);
666  return;
667  }
668 
669  sizeRemain = buffersize;
670  c = filter;
671 
672  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
673  {
674  HeapFree(GetProcessHeap(), 0, extensions);
676  return;
677  }
678 
679  c++;
680  sizeRemain -= sizeof(*c);
681 
682  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
683  {
684  HeapFree(GetProcessHeap(), 0, extensions);
686  return;
687  }
688 
689  HeapFree(GetProcessHeap(), 0, extensions);
690 
691  /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
692  * use the contents of szFile to initialize itself */
693  ofn.lpstrFile[0] = TEXT('\0');
696  ofn.nFilterIndex = 0;
697  ofn.lpstrFileTitle = fileTitle;
698  ofn.nMaxFileTitle = 256;
701 
704 
705  if (success)
706  {
707  /* Check if there is already a entry that holds this filename */
708  if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
709  return;
710 
711  if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
712  return;
713 
715  0,
716  &sfi,
717  sizeof(sfi),
719 
720  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
721 
722  backgroundItem->bWallpaper = TRUE;
723 
724  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
725  if (FAILED(hr))
726  return;
727  p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
728  if (p)
729  *p = (TCHAR)0;
730  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
731  if (FAILED(hr))
732  return;
733 
734  ZeroMemory(&listItem, sizeof(LV_ITEM));
735  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
736  listItem.state = 0;
737  listItem.pszText = backgroundItem->szDisplayName;
738  listItem.iImage = sfi.iIcon;
739  listItem.iItem = pData->listViewItemCount;
740  listItem.lParam = pData->listViewItemCount;
741 
742  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
743  ListView_SetItemState(hwndBackgroundList,
744  pData->listViewItemCount,
746  LVIS_SELECTED);
747  SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
748 
749  pData->listViewItemCount++;
750  }
751 }
752 
753 
754 static VOID
756 {
757  BackgroundItem *backgroundItem = NULL;
758 
759  pData->backgroundSelection = itemIndex;
760  backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
761 
762  if (pData->pWallpaperBitmap != NULL)
763  {
764  DibFreeImage(pData->pWallpaperBitmap);
765  pData->pWallpaperBitmap = NULL;
766  }
767 
768  if (backgroundItem->bWallpaper != FALSE)
769  {
770  pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
771 
772  if (pData->pWallpaperBitmap == NULL)
773  return;
774  }
775 
776  pData->bWallpaperChanged = TRUE;
777 
779  NULL, TRUE);
780 
782  backgroundItem->bWallpaper);
783 
784  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
785 }
786 
787 
788 static VOID
790 {
791  float scaleX;
792  float scaleY;
793  int scaledWidth;
794  int scaledHeight;
795  int posX, desX;
796  int posY, desY;
797  int fitFillScaleNum, fitFillScaleDen;
798  int fitFillWidth, fitFillHeight;
799  HBRUSH hBrush;
800  int x;
801  int y;
802  HDC hDC;
803  HGDIOBJ hOldObj;
804  RECT rcItem = {
805  MONITOR_LEFT,
806  MONITOR_TOP,
809  };
810 
811  hDC = CreateCompatibleDC(draw->hDC);
812  hOldObj = SelectObject(hDC, pData->hBitmap);
813 
814  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
815  {
816  /* Update desktop background color image */
818  FillRect(hDC, &rcItem, hBrush);
819  DeleteObject(hBrush);
820  }
821  else
822  if (pData->pWallpaperBitmap != NULL)
823  {
824  scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
825  scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
826 
827  scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
828  scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
829 
831 
833 
834  switch (pData->placementSelection)
835  {
836  case PLACEMENT_CENTER:
837  posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
838  posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
839  desX = 0;
840  desY = 0;
841 
842  if (posX < 0) { desX = -posX / 2; posX = 0; }
843  if (posY < 0) { desY = -posY / 2; posY = 0; }
844 
845  if (scaledWidth > MONITOR_WIDTH)
846  scaledWidth = MONITOR_WIDTH;
847 
848  if (scaledHeight > MONITOR_HEIGHT)
849  scaledHeight = MONITOR_HEIGHT;
850 
852  MONITOR_LEFT+posX,
853  MONITOR_TOP+posY,
854  scaledWidth,
855  scaledHeight,
856  desX,
857  desY,
858  pData->pWallpaperBitmap->width - (int)(desX * scaleX),
859  pData->pWallpaperBitmap->height - (int)(desY * scaleY),
860  pData->pWallpaperBitmap->bits,
861  pData->pWallpaperBitmap->info,
863  SRCCOPY);
864  break;
865 
866  case PLACEMENT_STRETCH:
868  MONITOR_LEFT,
869  MONITOR_TOP,
872  0,
873  0,
874  pData->pWallpaperBitmap->width,
875  pData->pWallpaperBitmap->height,
876  pData->pWallpaperBitmap->bits,
877  pData->pWallpaperBitmap->info,
879  SRCCOPY);
880  break;
881 
882  case PLACEMENT_TILE:
883  for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
884  {
885  for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
886  {
887  if ((MONITOR_WIDTH-x) >= scaledWidth)
888  posX = scaledWidth;
889  else
890  posX = MONITOR_WIDTH-x;
891 
892 
893  if ((MONITOR_HEIGHT-y) >= scaledHeight)
894  posY = scaledHeight;
895  else
896  posY = MONITOR_HEIGHT-y;
897 
899  MONITOR_LEFT + x,
900  MONITOR_TOP + y,
901  posX,
902  posY,
903  0,
904  0,
905  pData->pWallpaperBitmap->width * posX / scaledWidth,
906  pData->pWallpaperBitmap->height * posY / scaledHeight,
907  pData->pWallpaperBitmap->bits,
908  pData->pWallpaperBitmap->info,
910  SRCCOPY);
911  }
912 
913  }
914 
915  break;
916 
917  case PLACEMENT_FIT:
918  if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
919  {
920  fitFillScaleNum = MONITOR_WIDTH;
921  fitFillScaleDen = scaledWidth;
922  }
923  else
924  {
925  fitFillScaleNum = MONITOR_HEIGHT;
926  fitFillScaleDen = scaledHeight;
927  }
928 
929  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
930  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
931 
932  posX = (MONITOR_WIDTH - fitFillWidth) / 2;
933  posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
934 
936  MONITOR_LEFT + posX,
937  MONITOR_TOP + posY,
938  fitFillWidth,
939  fitFillHeight,
940  0,
941  0,
942  pData->pWallpaperBitmap->width,
943  pData->pWallpaperBitmap->height,
944  pData->pWallpaperBitmap->bits,
945  pData->pWallpaperBitmap->info,
947  SRCCOPY);
948  break;
949 
950  case PLACEMENT_FILL:
951  if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
952  {
953  fitFillScaleNum = MONITOR_WIDTH;
954  fitFillScaleDen = scaledWidth;
955  }
956  else
957  {
958  fitFillScaleNum = MONITOR_HEIGHT;
959  fitFillScaleDen = scaledHeight;
960  }
961 
962  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
963  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
964 
965  desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
966  desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
967 
969  MONITOR_LEFT,
970  MONITOR_TOP,
973  desX,
974  desY,
975  (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
976  (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
977  pData->pWallpaperBitmap->bits,
978  pData->pWallpaperBitmap->info,
980  SRCCOPY);
981  break;
982  }
983  }
984 
985  GdiTransparentBlt(draw->hDC,
986  draw->rcItem.left, draw->rcItem.top,
987  draw->rcItem.right-draw->rcItem.left+1,
988  draw->rcItem.bottom-draw->rcItem.top+1,
989  hDC,
990  0, 0,
991  pData->cxSource, pData->cySource,
992  0xFF00FF);
993 
994  SelectObject(hDC, hOldObj);
995  DeleteDC(hDC);
996 }
997 
998 
999 static VOID
1001 {
1002  HKEY regKey;
1003  TCHAR szWallpaper[MAX_PATH];
1004  GpImage *image;
1005  CLSID encoderClsid;
1006  GUID guidFormat;
1007  size_t length = 0;
1008  GpStatus status;
1009 
1011  {
1012  return;
1013  }
1014 
1015  if (FAILED(StringCbCat(szWallpaper, MAX_PATH, TEXT("\\Wallpaper1.bmp"))))
1016  {
1017  return;
1018  }
1019 
1020  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1022  {
1023  return;
1024  }
1025 
1026  if (pData->placementSelection == PLACEMENT_TILE)
1027  {
1028  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1029  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1030  }
1031 
1032  if (pData->placementSelection == PLACEMENT_CENTER)
1033  {
1034  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1035  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1036  }
1037 
1038  if (pData->placementSelection == PLACEMENT_STRETCH)
1039  {
1040  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1041  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1042  }
1043 
1044  if (pData->placementSelection == PLACEMENT_FIT)
1045  {
1046  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1047  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1048  }
1049 
1050  if (pData->placementSelection == PLACEMENT_FILL)
1051  {
1052  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1053  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1054  }
1055 
1056  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1057  {
1058  GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1059  if (!image)
1060  {
1061  RegCloseKey(regKey);
1062  return;
1063  }
1064 
1065  GdipGetImageRawFormat(image, &guidFormat);
1066  if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1067  {
1069  RegCloseKey(regKey);
1070  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1071  return;
1072  }
1073 
1074  if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1075  {
1077  RegCloseKey(regKey);
1078  return;
1079  }
1080 
1081  status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1082 
1084 
1085  if (status != Ok)
1086  {
1087  RegCloseKey(regKey);
1088  return;
1089  }
1090 
1091  if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1092  {
1093  RegSetValueEx(regKey,
1094  TEXT("ConvertedWallpaper"),
1095  0,
1096  REG_SZ,
1097  (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1098  (DWORD)((length + 1) * sizeof(TCHAR)));
1099  }
1100 
1101  if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1102  {
1103  RegSetValueEx(regKey,
1104  TEXT("OriginalWallpaper"),
1105  0,
1106  REG_SZ,
1107  (LPBYTE)szWallpaper,
1108  (DWORD)((length + 1) * sizeof(TCHAR)));
1109  }
1110 
1112  }
1113  else
1114  {
1116  }
1117 
1118  RegCloseKey(regKey);
1119 }
1120 
1121 
1122 /* Change system color */
1123 static VOID
1125 {
1126  HKEY hKey;
1127  INT iElement = COLOR_BACKGROUND;
1128  TCHAR clText[16];
1129  BYTE red, green, blue;
1130 
1131  if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1132  {
1133  /* FIXME: these error texts can need internationalization? */
1134  MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1135  TEXT("Error!"), MB_ICONSTOP );
1136  }
1137 
1138  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1140  {
1141  return;
1142  }
1143 
1147 
1148  /* Format string to be set to registry */
1149  StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1150  RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1151  (wcslen(clText) + 1) * sizeof(TCHAR));
1152 
1153  RegCloseKey(hKey);
1154 }
1155 
1158  UINT uMsg,
1159  WPARAM wParam,
1160  LPARAM lParam)
1161 {
1163  struct GdiplusStartupInput gdipStartup;
1164 
1166 
1167  switch (uMsg)
1168  {
1169  case WM_INITDIALOG:
1172  gdipStartup.GdiplusVersion = 1;
1173  gdipStartup.DebugEventCallback = NULL;
1174  gdipStartup.SuppressBackgroundThread = FALSE;
1175  gdipStartup.SuppressExternalCodecs = FALSE;
1176  GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1177  InitBackgroundDialog(hwndDlg, pData);
1178  break;
1179 
1180  case WM_COMMAND:
1181  {
1182  DWORD controlId = LOWORD(wParam);
1184 
1185  switch (controlId)
1186  {
1187  case IDC_COLOR_BUTTON:
1188  if (command == BN_CLICKED)
1189  OnColorButton(hwndDlg, pData);
1190  break;
1191 
1192  case IDC_BROWSE_BUTTON:
1193  if (command == BN_CLICKED)
1194  OnBrowseButton(hwndDlg, pData);
1195  break;
1196 
1197  case IDC_PLACEMENT_COMBO:
1198  if (command == CBN_SELCHANGE)
1199  {
1200  pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1201 
1203 
1204  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1205  }
1206  break;
1207  }
1208  } break;
1209 
1210  case WM_DRAWITEM:
1211  {
1212  LPDRAWITEMSTRUCT drawItem;
1213  drawItem = (LPDRAWITEMSTRUCT)lParam;
1214 
1215  if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1216  {
1217  DrawBackgroundPreview(drawItem, pData);
1218  }
1219 
1220  }
1221  break;
1222 
1223  case WM_NOTIFY:
1224  {
1225  LPNMHDR lpnm = (LPNMHDR)lParam;
1226 
1227  switch(lpnm->code)
1228  {
1229  case PSN_APPLY:
1230  if (pData->bWallpaperChanged)
1232  if (pData->bClrBackgroundChanged)
1233  SetDesktopBackColor(hwndDlg, pData);
1235  return TRUE;
1236 
1237  case LVN_ITEMCHANGED:
1238  {
1240 
1241  if ((nm->uNewState & LVIS_SELECTED) == 0)
1242  return FALSE;
1243 
1244  ListViewItemChanged(hwndDlg, pData, nm->iItem);
1245  }
1246  break;
1247  }
1248  }
1249  break;
1250 
1251  case WM_DESTROY:
1252  if (pData->pWallpaperBitmap != NULL)
1253  DibFreeImage(pData->pWallpaperBitmap);
1254 
1255  DeleteObject(pData->hBitmap);
1256  GdiplusShutdown(pData->gdipToken);
1257  HeapFree(GetProcessHeap(), 0, pData);
1258  break;
1259  }
1260 
1261  return FALSE;
1262 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:22
#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:2309
GLeglImageOES image
Definition: gl.h:2204
#define IDC_BROWSE_BUTTON
Definition: resource.h:23
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:55
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5021
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:169
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
HBITMAP hBitmap
Definition: background.c:77
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:1000
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:2559
PLACEMENT_VALUE
Definition: background.c:31
#define LVSIL_SMALL
Definition: commctrl.h:2271
#define CC_ANYCOLOR
Definition: commdlg.h:58
#define ERROR_SUCCESS
Definition: deptool.c:10
UINT uNewState
Definition: commctrl.h:3008
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:2519
COLORREF desktop_color
Definition: desk.h:106
struct _BACKGROUND_DATA * PBACKGROUND_DATA
#define IDS_NONE
Definition: resource.h:122
#define ExpandEnvironmentStrings
Definition: winbase.h:3588
#define LVN_ITEMCHANGED
Definition: commctrl.h:3103
struct _BACKGROUND_DATA BACKGROUND_DATA
#define SHGetFolderPath
Definition: shlobj.h:2001
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
#define GetRValue(rgb)
Definition: wingdi.h:2913
#define SystemParametersInfo
Definition: winuser.h:5724
LONG top
Definition: windef.h:292
OPENFILENAME ofn
Definition: main.cpp:37
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1635
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
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:5708
#define MB_ICONSTOP
Definition: winuser.h:797
#define PSN_APPLY
Definition: prsht.h:117
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
LONG left
Definition: windef.h:291
HRESULT GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
Definition: background.c:88
int32_t INT_PTR
Definition: typedefs.h:62
#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:293
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:51
int32_t INT
Definition: typedefs.h:56
int placementSelection
Definition: background.c:70
#define IDS_FILL
Definition: resource.h:52
#define SetWindowLongPtr
Definition: treelist.c:70
#define GetOpenFileName
Definition: commdlg.h:665
#define CB_GETCURSEL
Definition: winuser.h:1904
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
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define LVIF_TEXT
Definition: commctrl.h:2281
#define LVCF_SUBITEM
Definition: commctrl.h:2561
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4946
#define IDS_CENTER
Definition: resource.h:48
UINT code
Definition: winuser.h:3112
#define GetGValue(rgb)
Definition: wingdi.h:2914
#define SM_CXSCREEN
Definition: winuser.h:949
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:541
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:2608
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:607
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2645
unsigned int BOOL
Definition: ntddk_ex.h:94
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
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define CB_INSERTSTRING
Definition: winuser.h:1918
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2276
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
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:21
PLACEMENT
Definition: background.c:18
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define FindFirstFile
Definition: winbase.h:3596
GLclampf GLclampf blue
Definition: gl.h:1740
#define IDS_TILE
Definition: resource.h:50
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_COLOR_BUTTON
Definition: resource.h:24
#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:395
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
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define FindNextFile
Definition: winbase.h:3602
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:129
DWORD COLORREF
Definition: windef.h:285
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2030
#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:2282
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:20
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:1886
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
#define GetObject
Definition: wingdi.h:4446
#define IDS_BACKGROUND_COMDLG_FILTER
Definition: resource.h:26
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
struct _IMAGELIST * HIMAGELIST
Definition: commctrl.h:309
#define DWLP_USER
Definition: winuser.h:866
static VOID ListViewItemChanged(HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
Definition: background.c:755
BOOL bWallpaperChanged
Definition: background.c:63
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:5688
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define CB_SETCURSEL
Definition: winuser.h:1922
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:4997
#define WM_COMMAND
Definition: winuser.h:1716
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1124
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:78
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
struct tagNMLISTVIEW * LPNMLISTVIEW
unsigned char dummy
Definition: maze.c:118
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define MONITOR_LEFT
Definition: background.c:44
Definition: bl.h:1331
static VOID InitBackgroundDialog(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:457
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:625
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:789
__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:4021
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:2435
#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:1940
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
#define LVFI_STRING
Definition: commctrl.h:2409
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2442
#define SendMessage
Definition: winuser.h:5709
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define LVIF_PARAM
Definition: commctrl.h:2283
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
#define IDC_PLACEMENT_COMBO
Definition: resource.h:25
#define HIWORD(l)
Definition: typedefs.h:246
#define IDS_STRETCH
Definition: resource.h:49
LONG bottom
Definition: windef.h:294
#define GetBValue(rgb)
Definition: wingdi.h:2915
#define LoadImage
Definition: winuser.h:5681
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 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:2284
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
HBRUSH WINAPI GetSysColorBrush(_In_ int)
GLuint64EXT * result
Definition: glext.h:11304
#define HWND_BROADCAST
Definition: winuser.h:1190
#define GetWindowsDirectory
Definition: winbase.h:3671
static SERVICE_STATUS status
Definition: service.c:31
#define WM_INITDIALOG
Definition: winuser.h:1715
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
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#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:5685
_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:295
#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:1720
INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: background.c:1157
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