ReactOS  0.4.15-dev-1207-g698a8e6
background.c File Reference
#include "desk.h"
#include <shellapi.h>
#include <shlwapi.h>
Include dependency graph for background.c:

Go to the source code of this file.

Classes

struct  BackgroundItem
 
struct  _BACKGROUND_DATA
 

Macros

#define MAX_BACKGROUNDS   100
 
#define MONITOR_LEFT   20
 
#define MONITOR_TOP   8
 
#define MONITOR_RIGHT   140
 
#define MONITOR_BOTTOM   92
 
#define MONITOR_WIDTH   (MONITOR_RIGHT-MONITOR_LEFT)
 
#define MONITOR_HEIGHT   (MONITOR_BOTTOM-MONITOR_TOP)
 
#define IDI_SHELL_NO   200
 

Typedefs

typedef struct _BACKGROUND_DATA BACKGROUND_DATA
 
typedef struct _BACKGROUND_DATAPBACKGROUND_DATA
 

Enumerations

enum  PLACEMENT {
  PLACEMENT_CENTER = 0, PLACEMENT_STRETCH, PLACEMENT_TILE, PLACEMENT_FIT,
  PLACEMENT_FILL
}
 
enum  PLACEMENT_VALUE {
  PLACEMENT_VALUE_CENTER = 0, PLACEMENT_VALUE_STRETCH = 2, PLACEMENT_VALUE_TILE = 0, PLACEMENT_VALUE_FIT = 6,
  PLACEMENT_VALUE_FILL = 10
}
 

Functions

HRESULT GdipGetEncoderClsid (PCWSTR MimeType, CLSID *pClsid)
 
LPWSTR GdipGetSupportedFileExtensions (VOID)
 
static UINT AddWallpapersFromDirectory (UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
 
static VOID AddListViewItems (HWND hwndDlg, PBACKGROUND_DATA pData)
 
static VOID InitBackgroundDialog (HWND hwndDlg, PBACKGROUND_DATA pData)
 
static VOID OnColorButton (HWND hwndDlg, PBACKGROUND_DATA pData)
 
static BOOL CheckListViewFilenameExists (HWND hwndList, LPCTSTR tszFileName)
 
static VOID OnBrowseButton (HWND hwndDlg, PBACKGROUND_DATA pData)
 
static VOID ListViewItemChanged (HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
 
static VOID DrawBackgroundPreview (LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
 
static VOID SetWallpaper (PBACKGROUND_DATA pData)
 
static VOID SetDesktopBackColor (HWND hwndDlg, PBACKGROUND_DATA pData)
 
INT_PTR CALLBACK BackgroundPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

GLOBAL_DATA g_GlobalData
 

Macro Definition Documentation

◆ IDI_SHELL_NO

#define IDI_SHELL_NO   200

◆ MAX_BACKGROUNDS

#define MAX_BACKGROUNDS   100

Definition at line 16 of file background.c.

◆ MONITOR_BOTTOM

#define MONITOR_BOTTOM   92

Definition at line 47 of file background.c.

◆ MONITOR_HEIGHT

#define MONITOR_HEIGHT   (MONITOR_BOTTOM-MONITOR_TOP)

Definition at line 50 of file background.c.

◆ MONITOR_LEFT

#define MONITOR_LEFT   20

Definition at line 44 of file background.c.

◆ MONITOR_RIGHT

#define MONITOR_RIGHT   140

Definition at line 46 of file background.c.

◆ MONITOR_TOP

#define MONITOR_TOP   8

Definition at line 45 of file background.c.

◆ MONITOR_WIDTH

#define MONITOR_WIDTH   (MONITOR_RIGHT-MONITOR_LEFT)

Definition at line 49 of file background.c.

Typedef Documentation

◆ BACKGROUND_DATA

◆ PBACKGROUND_DATA

Enumeration Type Documentation

◆ PLACEMENT

Enumerator
PLACEMENT_CENTER 
PLACEMENT_STRETCH 
PLACEMENT_TILE 
PLACEMENT_FIT 
PLACEMENT_FILL 

Definition at line 18 of file background.c.

◆ PLACEMENT_VALUE

Enumerator
PLACEMENT_VALUE_CENTER 
PLACEMENT_VALUE_STRETCH 
PLACEMENT_VALUE_TILE 
PLACEMENT_VALUE_FIT 
PLACEMENT_VALUE_FILL 

Definition at line 31 of file background.c.

Function Documentation

◆ AddListViewItems()

static VOID AddListViewItems ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 291 of file background.c.

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 }
#define RegQueryValueEx
Definition: winreg.h:524
#define LV_ITEM
Definition: commctrl.h:2333
static HICON
Definition: imagelist.c:84
#define IMAGE_ICON
Definition: winuser.h:212
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2583
#define LVSIL_SMALL
Definition: commctrl.h:2295
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define _tcsicmp
Definition: xmlstorage.h:205
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define LV_COLUMN
Definition: commctrl.h:2543
#define IDS_NONE
Definition: resource.h:123
#define ExpandEnvironmentStrings
Definition: winbase.h:3614
#define ZeroMemory
Definition: winbase.h:1648
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
HINSTANCE hApplet
Definition: access.c:17
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HIMAGELIST himl
#define SHGFI_SMALLICON
Definition: shellapi.h:174
int32_t INT
Definition: typedefs.h:58
#define ILC_COLOR32
Definition: commctrl.h:354
#define LVIF_TEXT
Definition: commctrl.h:2305
#define LVCF_SUBITEM
Definition: commctrl.h:2585
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 FALSE
Definition: types.h:117
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2669
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
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2300
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2315
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
char TCHAR
Definition: xmlstorage.h:189
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:366
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:413
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
#define LVIF_IMAGE
Definition: commctrl.h:2306
#define IDC_BACKGROUND_LIST
Definition: resource.h:27
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
#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 ILC_MASK
Definition: commctrl.h:347
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
HICON hIcon
Definition: msconfig.c:44
unsigned char dummy
Definition: maze.c:118
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define IDI_SHELL_NO
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
_Out_opt_ int * cx
Definition: commctrl.h:581
#define LVIF_PARAM
Definition: commctrl.h:2307
HICON hIcon
Definition: shellapi.h:363
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define LVIF_STATE
Definition: commctrl.h:2308
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SHGFI_ICON
Definition: shellapi.h:162
GLuint64EXT * result
Definition: glext.h:11304
#define GetWindowsDirectory
Definition: winbase.h:3697
static HMODULE hShell32
Definition: string.c:34
#define LoadString
Definition: winuser.h:5794
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by InitBackgroundDialog().

◆ AddWallpapersFromDirectory()

static UINT AddWallpapersFromDirectory ( UINT  uCounter,
HWND  hwndBackgroundList,
BackgroundItem backgroundItem,
PBACKGROUND_DATA  pData,
LPCTSTR  wallpaperFilename,
LPCTSTR  wallpaperDirectory 
)
static

Definition at line 186 of file background.c.

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 }
#define LV_ITEM
Definition: commctrl.h:2333
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVSIL_SMALL
Definition: commctrl.h:2295
HRESULT hr
Definition: shlfolder.c:183
#define _tcsicmp
Definition: xmlstorage.h:205
#define TRUE
Definition: types.h:120
#define PathCombine
Definition: shlwapi.h:825
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define ZeroMemory
Definition: winbase.h:1648
static int fd
Definition: io.c:51
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
const char * filename
Definition: ioapi.h:135
HIMAGELIST himl
#define SHGFI_SMALLICON
Definition: shellapi.h:174
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define LVIF_TEXT
Definition: commctrl.h:2305
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_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2292
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
smooth NULL
Definition: ftsmooth.c:416
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
#define FindFirstFile
Definition: winbase.h:3622
char TCHAR
Definition: xmlstorage.h:189
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:366
#define GetProcessHeap()
Definition: compat.h:595
LONG HRESULT
Definition: typedefs.h:79
#define FindNextFile
Definition: winbase.h:3628
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:129
#define MAX_PATH
Definition: compat.h:34
#define LVIF_IMAGE
Definition: commctrl.h:2306
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
TCHAR szDisplayName[256]
Definition: background.c:57
#define StringCbCopy
Definition: strsafe.h:155
#define TEXT(s)
Definition: k32.h:26
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int UINT
Definition: ndis.h:50
#define _tcstok
Definition: tchar.h:1416
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
#define LVIF_PARAM
Definition: commctrl.h:2307
#define SHGetFileInfo
Definition: shellapi.h:695
HICON hIcon
Definition: shellapi.h:363
#define LVIF_STATE
Definition: commctrl.h:2308
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SHGFI_ICON
Definition: shellapi.h:162
#define HeapFree(x, y, z)
Definition: compat.h:594
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by AddListViewItems().

◆ BackgroundPageProc()

INT_PTR CALLBACK BackgroundPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1170 of file background.c.

1174 {
1176  struct GdiplusStartupInput gdipStartup;
1177 
1179 
1180  switch (uMsg)
1181  {
1182  case WM_INITDIALOG:
1185  gdipStartup.GdiplusVersion = 1;
1186  gdipStartup.DebugEventCallback = NULL;
1187  gdipStartup.SuppressBackgroundThread = FALSE;
1188  gdipStartup.SuppressExternalCodecs = FALSE;
1189  GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1190  InitBackgroundDialog(hwndDlg, pData);
1191  break;
1192 
1193  case WM_COMMAND:
1194  {
1195  DWORD controlId = LOWORD(wParam);
1197 
1198  switch (controlId)
1199  {
1200  case IDC_COLOR_BUTTON:
1201  if (command == BN_CLICKED)
1202  OnColorButton(hwndDlg, pData);
1203  break;
1204 
1205  case IDC_BROWSE_BUTTON:
1206  if (command == BN_CLICKED)
1207  OnBrowseButton(hwndDlg, pData);
1208  break;
1209 
1210  case IDC_PLACEMENT_COMBO:
1211  if (command == CBN_SELCHANGE)
1212  {
1213  pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1214 
1216 
1217  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1218  }
1219  break;
1220  }
1221  } break;
1222 
1223  case WM_DRAWITEM:
1224  {
1225  LPDRAWITEMSTRUCT drawItem;
1226  drawItem = (LPDRAWITEMSTRUCT)lParam;
1227 
1228  if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1229  {
1230  DrawBackgroundPreview(drawItem, pData);
1231  }
1232 
1233  }
1234  break;
1235 
1236  case WM_NOTIFY:
1237  {
1238  LPNMHDR lpnm = (LPNMHDR)lParam;
1239 
1240  switch(lpnm->code)
1241  {
1242  case PSN_APPLY:
1243  if (pData->bWallpaperChanged)
1245  if (pData->bClrBackgroundChanged)
1246  SetDesktopBackColor(hwndDlg, pData);
1248  return TRUE;
1249 
1250  case LVN_ITEMCHANGED:
1251  {
1253 
1254  if ((nm->uNewState & LVIS_SELECTED) == 0)
1255  return FALSE;
1256 
1257  ListViewItemChanged(hwndDlg, pData, nm->iItem);
1258  }
1259  break;
1260  }
1261  }
1262  break;
1263 
1264  case WM_DESTROY:
1265  if (pData->pWallpaperBitmap != NULL)
1266  DibFreeImage(pData->pWallpaperBitmap);
1267 
1268  DeleteObject(pData->hBitmap);
1269  GdiplusShutdown(pData->gdipToken);
1270  HeapFree(GetProcessHeap(), 0, pData);
1271  break;
1272  }
1273 
1274  return FALSE;
1275 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:29
#define IDC_BROWSE_BUTTON
Definition: resource.h:30
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:1013
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
UINT uNewState
Definition: commctrl.h:3032
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define TRUE
Definition: types.h:120
struct _BACKGROUND_DATA * PBACKGROUND_DATA
#define LVN_ITEMCHANGED
Definition: commctrl.h:3127
struct _BACKGROUND_DATA BACKGROUND_DATA
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SendDlgItemMessage
Definition: winuser.h:5817
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1925
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
UINT code
Definition: winuser.h:3134
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:549
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2315
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_COLOR_BUTTON
Definition: resource.h:31
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
void WINAPI GdiplusShutdown(ULONG_PTR)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:81
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWLP_USER
Definition: winuser.h:866
static VOID ListViewItemChanged(HWND hwndDlg, PBACKGROUND_DATA pData, int itemIndex)
Definition: background.c:768
#define WM_COMMAND
Definition: winuser.h:1722
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1137
HWND WINAPI GetParent(_In_ HWND)
struct tagNMLISTVIEW * LPNMLISTVIEW
static VOID InitBackgroundDialog(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:465
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:633
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:802
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define CBN_SELCHANGE
Definition: winuser.h:1961
#define WM_DRAWITEM
Definition: winuser.h:1627
#define SendMessage
Definition: winuser.h:5818
#define IDC_PLACEMENT_COMBO
Definition: resource.h:32
#define HIWORD(l)
Definition: typedefs.h:247
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define HWND_BROADCAST
Definition: winuser.h:1190
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:594
#define WM_NOTIFY
Definition: richedit.h:61
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ CheckListViewFilenameExists()

static BOOL CheckListViewFilenameExists ( HWND  hwndList,
LPCTSTR  tszFileName 
)
static

Definition at line 615 of file background.c.

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 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define LVFINDINFO
Definition: commctrl.h:2459
#define LVFI_STRING
Definition: commctrl.h:2433
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2466

Referenced by OnBrowseButton().

◆ DrawBackgroundPreview()

static VOID DrawBackgroundPreview ( LPDRAWITEMSTRUCT  draw,
PBACKGROUND_DATA  pData 
)
static

Definition at line 802 of file background.c.

803 {
804  float scaleX;
805  float scaleY;
806  int scaledWidth;
807  int scaledHeight;
808  int posX, desX;
809  int posY, desY;
810  int fitFillScaleNum, fitFillScaleDen;
811  int fitFillWidth, fitFillHeight;
812  HBRUSH hBrush;
813  int x;
814  int y;
815  HDC hDC;
816  HGDIOBJ hOldObj;
817  RECT rcItem = {
818  MONITOR_LEFT,
819  MONITOR_TOP,
822  };
823 
824  hDC = CreateCompatibleDC(draw->hDC);
825  hOldObj = SelectObject(hDC, pData->hBitmap);
826 
827  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
828  {
829  /* Update desktop background color image */
831  FillRect(hDC, &rcItem, hBrush);
832  DeleteObject(hBrush);
833  }
834  else
835  if (pData->pWallpaperBitmap != NULL)
836  {
837  scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
838  scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
839 
840  scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
841  scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
842 
844 
846 
847  switch (pData->placementSelection)
848  {
849  case PLACEMENT_CENTER:
850  posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
851  posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
852  desX = 0;
853  desY = 0;
854 
855  if (posX < 0) { desX = -posX / 2; posX = 0; }
856  if (posY < 0) { desY = -posY / 2; posY = 0; }
857 
858  if (scaledWidth > MONITOR_WIDTH)
859  scaledWidth = MONITOR_WIDTH;
860 
861  if (scaledHeight > MONITOR_HEIGHT)
862  scaledHeight = MONITOR_HEIGHT;
863 
865  MONITOR_LEFT+posX,
866  MONITOR_TOP+posY,
867  scaledWidth,
868  scaledHeight,
869  desX,
870  desY,
871  pData->pWallpaperBitmap->width - (int)(desX * scaleX),
872  pData->pWallpaperBitmap->height - (int)(desY * scaleY),
873  pData->pWallpaperBitmap->bits,
874  pData->pWallpaperBitmap->info,
876  SRCCOPY);
877  break;
878 
879  case PLACEMENT_STRETCH:
881  MONITOR_LEFT,
882  MONITOR_TOP,
885  0,
886  0,
887  pData->pWallpaperBitmap->width,
888  pData->pWallpaperBitmap->height,
889  pData->pWallpaperBitmap->bits,
890  pData->pWallpaperBitmap->info,
892  SRCCOPY);
893  break;
894 
895  case PLACEMENT_TILE:
896  for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
897  {
898  for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
899  {
900  if ((MONITOR_WIDTH-x) >= scaledWidth)
901  posX = scaledWidth;
902  else
903  posX = MONITOR_WIDTH-x;
904 
905 
906  if ((MONITOR_HEIGHT-y) >= scaledHeight)
907  posY = scaledHeight;
908  else
909  posY = MONITOR_HEIGHT-y;
910 
912  MONITOR_LEFT + x,
913  MONITOR_TOP + y,
914  posX,
915  posY,
916  0,
917  0,
918  pData->pWallpaperBitmap->width * posX / scaledWidth,
919  pData->pWallpaperBitmap->height * posY / scaledHeight,
920  pData->pWallpaperBitmap->bits,
921  pData->pWallpaperBitmap->info,
923  SRCCOPY);
924  }
925 
926  }
927 
928  break;
929 
930  case PLACEMENT_FIT:
931  if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
932  {
933  fitFillScaleNum = MONITOR_WIDTH;
934  fitFillScaleDen = scaledWidth;
935  }
936  else
937  {
938  fitFillScaleNum = MONITOR_HEIGHT;
939  fitFillScaleDen = scaledHeight;
940  }
941 
942  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
943  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
944 
945  posX = (MONITOR_WIDTH - fitFillWidth) / 2;
946  posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
947 
949  MONITOR_LEFT + posX,
950  MONITOR_TOP + posY,
951  fitFillWidth,
952  fitFillHeight,
953  0,
954  0,
955  pData->pWallpaperBitmap->width,
956  pData->pWallpaperBitmap->height,
957  pData->pWallpaperBitmap->bits,
958  pData->pWallpaperBitmap->info,
960  SRCCOPY);
961  break;
962 
963  case PLACEMENT_FILL:
964  if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
965  {
966  fitFillScaleNum = MONITOR_WIDTH;
967  fitFillScaleDen = scaledWidth;
968  }
969  else
970  {
971  fitFillScaleNum = MONITOR_HEIGHT;
972  fitFillScaleDen = scaledHeight;
973  }
974 
975  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
976  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
977 
978  desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
979  desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
980 
982  MONITOR_LEFT,
983  MONITOR_TOP,
986  desX,
987  desY,
988  (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
989  (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
990  pData->pWallpaperBitmap->bits,
991  pData->pWallpaperBitmap->info,
993  SRCCOPY);
994  break;
995  }
996  }
997 
998  GdiTransparentBlt(draw->hDC,
999  draw->rcItem.left, draw->rcItem.top,
1000  draw->rcItem.right-draw->rcItem.left+1,
1001  draw->rcItem.bottom-draw->rcItem.top+1,
1002  hDC,
1003  0, 0,
1004  pData->cxSource, pData->cySource,
1005  0xFF00FF);
1006 
1007  SelectObject(hDC, hOldObj);
1008  DeleteDC(hDC);
1009 }
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)
COLORREF desktop_color
Definition: desk.h:106
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
LONG left
Definition: windef.h:306
#define COLORONCOLOR
Definition: wingdi.h:953
LONG right
Definition: windef.h:308
#define SM_CXSCREEN
Definition: winuser.h:949
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYSCREEN
Definition: winuser.h:950
#define MONITOR_BOTTOM
Definition: background.c:47
int WINAPI GetSystemMetrics(_In_ int)
#define MONITOR_TOP
Definition: background.c:45
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1326
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
static float(__cdecl *square_half_float)(float x
#define MONITOR_LEFT
Definition: background.c:44
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLOBAL_DATA g_GlobalData
Definition: background.c:84
LONG bottom
Definition: windef.h:309
#define MONITOR_RIGHT
Definition: background.c:46
#define COLOR_BACKGROUND
Definition: hardware.h:164
#define MONITOR_HEIGHT
Definition: background.c:50
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)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define SRCCOPY
Definition: wingdi.h:332
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)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by BackgroundPageProc().

◆ GdipGetEncoderClsid()

HRESULT GdipGetEncoderClsid ( PCWSTR  MimeType,
CLSID pClsid 
)

Definition at line 88 of file background.c.

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 }
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5021
#define E_FAIL
Definition: ddrawi.h:102
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 E_OUTOFMEMORY
Definition: ddrawi.h:100
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint GLuint num
Definition: glext.h:9618
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:4997
#define S_OK
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:594
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by SetWallpaper().

◆ GdipGetSupportedFileExtensions()

LPWSTR GdipGetSupportedFileExtensions ( VOID  )

Definition at line 129 of file background.c.

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 }
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
Definition: image.c:4946
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
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:4970
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint GLuint num
Definition: glext.h:9618
static const WCHAR L[]
Definition: oid.c:1250
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by AddWallpapersFromDirectory(), and OnBrowseButton().

◆ InitBackgroundDialog()

static VOID InitBackgroundDialog ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 465 of file background.c.

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 }
#define RegQueryValueEx
Definition: winreg.h:524
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HINSTANCE hApplet
Definition: access.c:17
#define SendDlgItemMessage
Definition: winuser.h:5817
#define IDS_FIT
Definition: resource.h:58
#define IDS_FILL
Definition: resource.h:59
#define IDS_CENTER
Definition: resource.h:55
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CB_INSERTSTRING
Definition: winuser.h:1939
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_MONITOR
Definition: resource.h:28
#define IDS_TILE
Definition: resource.h:57
Definition: uimain.c:88
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetObject
Definition: wingdi.h:4467
#define CB_SETCURSEL
Definition: winuser.h:1943
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
Definition: bl.h:1331
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
#define IMAGE_BITMAP
Definition: winuser.h:211
#define IDC_PLACEMENT_COMBO
Definition: resource.h:32
#define IDS_STRETCH
Definition: resource.h:56
#define LoadImage
Definition: winuser.h:5790
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
#define LoadString
Definition: winuser.h:5794
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:291

Referenced by BackgroundPageProc().

◆ ListViewItemChanged()

static VOID ListViewItemChanged ( HWND  hwndDlg,
PBACKGROUND_DATA  pData,
int  itemIndex 
)
static

Definition at line 768 of file background.c.

769 {
770  BackgroundItem *backgroundItem = NULL;
771 
772  pData->backgroundSelection = itemIndex;
773  backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
774 
775  if (pData->pWallpaperBitmap != NULL)
776  {
777  DibFreeImage(pData->pWallpaperBitmap);
778  pData->pWallpaperBitmap = NULL;
779  }
780 
781  if (backgroundItem->bWallpaper != FALSE)
782  {
783  pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
784 
785  if (pData->pWallpaperBitmap == NULL)
786  return;
787  }
788 
789  pData->bWallpaperChanged = TRUE;
790 
792  NULL, TRUE);
793 
795  backgroundItem->bWallpaper);
796 
797  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
798 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:29
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
PDIBITMAP DibLoadImage(LPTSTR lpFilename)
Definition: dibitmap.c:13
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
#define IDC_PLACEMENT_COMBO
Definition: resource.h:32
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by BackgroundPageProc().

◆ OnBrowseButton()

static VOID OnBrowseButton ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 633 of file background.c.

634 {
637  TCHAR fileTitle[256];
638  TCHAR initialDir[MAX_PATH];
639  LPTSTR filter;
640  LPTSTR extensions;
641  BackgroundItem *backgroundItem = NULL;
642  SHFILEINFO sfi;
643  LV_ITEM listItem;
644  HWND hwndBackgroundList;
645  TCHAR *p;
646  HRESULT hr;
647  TCHAR filterdesc[MAX_PATH];
648  TCHAR *c;
649  size_t sizeRemain;
650  SIZE_T buffersize;
651  BOOL success;
653 
654  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
655  himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
656  SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
657 
658  ZeroMemory(&ofn, sizeof(OPENFILENAME));
659 
660  ofn.lStructSize = sizeof(OPENFILENAME);
661  ofn.hwndOwner = hwndDlg;
663 
664  LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
665 
666  extensions = GdipGetSupportedFileExtensions();
667  if (!extensions)
668  {
669  return;
670  }
671 
672  buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
673 
675  if (!filter)
676  {
677  HeapFree(GetProcessHeap(), 0, extensions);
678  return;
679  }
680 
681  sizeRemain = buffersize;
682  c = filter;
683 
684  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
685  {
686  HeapFree(GetProcessHeap(), 0, extensions);
688  return;
689  }
690 
691  c++;
692  sizeRemain -= sizeof(*c);
693 
694  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
695  {
696  HeapFree(GetProcessHeap(), 0, extensions);
698  return;
699  }
700 
701  HeapFree(GetProcessHeap(), 0, extensions);
702 
703  /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
704  * use the contents of szFile to initialize itself */
705  ofn.lpstrFile[0] = TEXT('\0');
708  ofn.nFilterIndex = 0;
709  ofn.lpstrFileTitle = fileTitle;
710  ofn.nMaxFileTitle = 256;
711  ofn.lpstrInitialDir = initialDir;
713 
716 
717  if (success)
718  {
719  /* Check if there is already a entry that holds this filename */
720  if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
721  return;
722 
723  if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
724  return;
725 
727  0,
728  &sfi,
729  sizeof(sfi),
731  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
732 
733  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
734 
735  backgroundItem->bWallpaper = TRUE;
736 
737  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
738  if (FAILED(hr))
739  return;
740  p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
741  if (p)
742  *p = (TCHAR)0;
743  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
744  if (FAILED(hr))
745  return;
746 
747  ZeroMemory(&listItem, sizeof(LV_ITEM));
748  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
749  listItem.state = 0;
750  listItem.pszText = backgroundItem->szDisplayName;
751  listItem.iImage = sfi.iIcon;
752  listItem.iItem = pData->listViewItemCount;
753  listItem.lParam = pData->listViewItemCount;
754 
755  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
756  ListView_SetItemState(hwndBackgroundList,
757  pData->listViewItemCount,
759  LVIS_SELECTED);
760  SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
761 
762  pData->listViewItemCount++;
763  }
764 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
#define LV_ITEM
Definition: commctrl.h:2333
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVSIL_SMALL
Definition: commctrl.h:2295
HRESULT hr
Definition: shlfolder.c:183
LPSTR lpstrFileTitle
Definition: commdlg.h:338
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
HWND hwndOwner
Definition: commdlg.h:330
#define TRUE
Definition: types.h:120
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1648
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
const char * filename
Definition: ioapi.h:135
HIMAGELIST himl
#define SHGFI_SMALLICON
Definition: shellapi.h:174
#define GetOpenFileName
Definition: commdlg.h:665
CHAR * LPTSTR
Definition: xmlstorage.h:192
DWORD nMaxFile
Definition: commdlg.h:337
#define LVIF_TEXT
Definition: commctrl.h:2305
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2292
#define FALSE
Definition: types.h:117
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
#define StringCbPrintfEx
Definition: strsafe.h:600
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2315
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:366
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LONG HRESULT
Definition: typedefs.h:79
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:129
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
#define LVIF_IMAGE
Definition: commctrl.h:2306
const GLubyte * c
Definition: glext.h:8905
#define IDC_BACKGROUND_LIST
Definition: resource.h:27
#define success(from, fromstr, to, tostr)
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
#define IDS_BACKGROUND_COMDLG_FILTER
Definition: resource.h:33
TCHAR szDisplayName[256]
Definition: background.c:57
#define StringCbCopy
Definition: strsafe.h:155
static const WCHAR L[]
Definition: oid.c:1250
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define TEXT(s)
Definition: k32.h:26
LPSTR lpstrFile
Definition: commdlg.h:336
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define SB_BOTTOM
Definition: winuser.h:577
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2208
#define SendMessage
Definition: winuser.h:5818
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define LVIF_PARAM
Definition: commctrl.h:2307
#define SHGetFileInfo
Definition: shellapi.h:695
#define c
Definition: ke_i.h:80
HICON hIcon
Definition: shellapi.h:363
DWORD nFilterIndex
Definition: commdlg.h:335
GLfloat GLfloat p
Definition: glext.h:8902
#define LVIF_STATE
Definition: commctrl.h:2308
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SHGFI_ICON
Definition: shellapi.h:162
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:594
#define LoadString
Definition: winuser.h:5794
#define MAX_BACKGROUNDS
Definition: background.c:16
#define WM_VSCROLL
Definition: winuser.h:1726
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342

Referenced by BackgroundPageProc().

◆ OnColorButton()

static VOID OnColorButton ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 549 of file background.c.

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 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:29
#define RegQueryValueEx
Definition: winreg.h:524
#define CC_ANYCOLOR
Definition: commdlg.h:58
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define ChooseColor
Definition: commdlg.h:661
#define REG_BINARY
Definition: nt_native.h:1496
#define TRUE
Definition: types.h:120
CHOOSECOLORA CHOOSECOLOR
Definition: commdlg.h:654
#define CC_RGBINIT
Definition: commdlg.h:50
#define HKEY_CURRENT_USER
Definition: winreg.h:11
COLORREF desktop_color
Definition: desk.h:106
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t cc
Definition: isohybrid.c:75
HWND WINAPI GetParent(_In_ HWND)
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
GLuint res
Definition: glext.h:9613
GLOBAL_DATA g_GlobalData
Definition: background.c:84
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define CC_FULLOPEN
Definition: commdlg.h:51

Referenced by BackgroundPageProc().

◆ SetDesktopBackColor()

static VOID SetDesktopBackColor ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 1137 of file background.c.

1138 {
1139  HKEY hKey;
1140  INT iElement = COLOR_BACKGROUND;
1141  TCHAR clText[16];
1142  BYTE red, green, blue;
1143 
1144  if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1145  {
1146  /* FIXME: these error texts can need internationalization? */
1147  MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1148  TEXT("Error!"), MB_ICONSTOP );
1149  }
1150 
1151  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1153  {
1154  return;
1155  }
1156 
1160 
1161  /* Format string to be set to registry */
1162  StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1163  RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1164  (wcslen(clText) + 1) * sizeof(TCHAR));
1165 
1166  RegCloseKey(hKey);
1167 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define HKEY_CURRENT_USER
Definition: winreg.h:11
COLORREF desktop_color
Definition: desk.h:106
#define GetRValue(quad)
Definition: precomp.h:64
#define MB_ICONSTOP
Definition: winuser.h:797
int32_t INT
Definition: typedefs.h:58
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
#define GetBValue(quad)
Definition: precomp.h:66
GLclampf GLclampf blue
Definition: gl.h:1740
#define GetGValue(quad)
Definition: precomp.h:65
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
char TCHAR
Definition: xmlstorage.h:189
#define StringCbPrintf
Definition: strsafe.h:544
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
#define MessageBox
Definition: winuser.h:5797
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
unsigned char BYTE
Definition: xxhash.c:193
#define TEXT(s)
Definition: k32.h:26
GLOBAL_DATA g_GlobalData
Definition: background.c:84
#define COLOR_BACKGROUND
Definition: hardware.h:164
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define REG_SZ
Definition: layer.c:22

Referenced by BackgroundPageProc().

◆ SetWallpaper()

static VOID SetWallpaper ( PBACKGROUND_DATA  pData)
static

Definition at line 1013 of file background.c.

1014 {
1015  HKEY regKey;
1016  TCHAR szWallpaper[MAX_PATH];
1017  GpImage *image;
1018  CLSID encoderClsid;
1019  GUID guidFormat;
1020  size_t length = 0;
1021  GpStatus status;
1022 
1024  {
1025  return;
1026  }
1027 
1028  if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1029  {
1030  return;
1031  }
1032 
1033  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1035  {
1036  return;
1037  }
1038 
1039  if (pData->placementSelection == PLACEMENT_TILE)
1040  {
1041  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1042  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1043  }
1044 
1045  if (pData->placementSelection == PLACEMENT_CENTER)
1046  {
1047  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1048  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1049  }
1050 
1051  if (pData->placementSelection == PLACEMENT_STRETCH)
1052  {
1053  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1054  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1055  }
1056 
1057  if (pData->placementSelection == PLACEMENT_FIT)
1058  {
1059  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1060  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1061  }
1062 
1063  if (pData->placementSelection == PLACEMENT_FILL)
1064  {
1065  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1066  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1067  }
1068 
1069  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1070  {
1071  GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1072  if (!image)
1073  {
1074  RegCloseKey(regKey);
1075  return;
1076  }
1077 
1078  GdipGetImageRawFormat(image, &guidFormat);
1079  if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1080  {
1082  RegCloseKey(regKey);
1083  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1084  return;
1085  }
1086 
1087  if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1088  {
1090  RegCloseKey(regKey);
1091  return;
1092  }
1093 
1094  status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1095 
1097 
1098  if (status != Ok)
1099  {
1100  RegCloseKey(regKey);
1101  return;
1102  }
1103 
1104  if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1105  {
1106  RegSetValueEx(regKey,
1107  TEXT("ConvertedWallpaper"),
1108  0,
1109  REG_SZ,
1110  (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1111  (DWORD)((length + 1) * sizeof(TCHAR)));
1112  }
1113 
1114  if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1115  {
1116  RegSetValueEx(regKey,
1117  TEXT("OriginalWallpaper"),
1118  0,
1119  REG_SZ,
1120  (LPBYTE)szWallpaper,
1121  (DWORD)((length + 1) * sizeof(TCHAR)));
1122  }
1123 
1125  }
1126  else
1127  {
1129  }
1130 
1131  RegCloseKey(regKey);
1132 }
#define StringCchLength
Definition: strsafe.h:829
GLeglImageOES image
Definition: gl.h:2204
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR *filename, GpImage **image)
Definition: image.c:2928
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1351
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SHGetFolderPath
Definition: shlobj.h:2010
#define SystemParametersInfo
Definition: winuser.h:5833
HRESULT GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
Definition: background.c:88
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
Definition: image.c:4428
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
Definition: image.c:2306
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
char TCHAR
Definition: xmlstorage.h:189
#define StringCbCat
Definition: strsafe.h:334
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2039
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define TEXT(s)
Definition: k32.h:26
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define CSIDL_FLAG_CREATE
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
static SERVICE_STATUS status
Definition: service.c:31
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define SUCCEEDED(hr)
Definition: intsafe.h:49
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

Referenced by BackgroundPageProc().

Variable Documentation

◆ g_GlobalData