ReactOS  0.4.15-dev-5496-g599ba9c
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 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)
 
static VOID OnCustomButton (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.

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 277 of file background.c.

278 {
279  TCHAR szSearchPath[MAX_PATH];
280  LV_ITEM listItem;
282  RECT clientRect;
283  HKEY regKey;
284  SHFILEINFO sfi;
286  TCHAR wallpaperFilename[MAX_PATH];
287  TCHAR originalWallpaper[MAX_PATH];
288  DWORD bufferSize = sizeof(wallpaperFilename);
290  DWORD varType = REG_SZ;
291  LONG result;
292  UINT i = 0;
293  BackgroundItem *backgroundItem = NULL;
294  HWND hwndBackgroundList;
295  HRESULT hr;
296  HICON hIcon;
297  INT cx, cy;
299 
300  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
301 
302  GetClientRect(hwndBackgroundList, &clientRect);
303 
307 
308  /* Load (None) icon */
309 #define IDI_SHELL_NO 200
310  hShell32 = GetModuleHandleW(L"shell32.dll");
312 #undef IDI_SHELL_NO
313 
314  ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
315 
316  /* Add a new column to the list */
317  ZeroMemory(&dummy, sizeof(LV_COLUMN));
318  dummy.mask = LVCF_SUBITEM | LVCF_WIDTH;
319  dummy.iSubItem = 0;
320  dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
321  (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
322 
323  /* Add the "None" item */
324  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
325  backgroundItem->bWallpaper = FALSE;
327  IDS_NONE,
328  backgroundItem->szDisplayName,
329  sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
330 
331  ZeroMemory(&listItem, sizeof(LV_ITEM));
332  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
333  listItem.state = 0;
334  listItem.pszText = backgroundItem->szDisplayName;
335  listItem.iImage = ImageList_AddIcon(himl, hIcon);
336  listItem.iItem = pData->listViewItemCount;
337  listItem.lParam = pData->listViewItemCount;
338  hIcon = NULL;
339 
340  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
341  ListView_SetItemState(hwndBackgroundList,
342  pData->listViewItemCount,
344  LVIS_SELECTED);
345 
346  pData->listViewItemCount++;
347 
348  /* Add current wallpaper if any */
349  result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
350  if (result == ERROR_SUCCESS)
351  {
352  result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
353  if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
354  {
355  bufferSize = sizeof(originalWallpaper);
356  result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
357 
358  /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
359  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
360  {
361  bufferSize = sizeof(originalWallpaper);
362  result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
363 
364  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
365  {
366  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
367  if (FAILED(hr))
368  {
369  RegCloseKey(regKey);
370  return;
371  }
372  }
373  }
374 
375  /* Allow environment variables in file name */
376  if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
377  {
378  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
379  if (FAILED(hr))
380  {
381  RegCloseKey(regKey);
382  return;
383  }
384  }
385 
386  SHGetFileInfoW(wallpaperFilename,
387  0,
388  &sfi,
389  sizeof(sfi),
392  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
393 
394  i++;
395 
396  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
397 
398  backgroundItem->bWallpaper = TRUE;
399 
400  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
401  if (FAILED(hr))
402  {
403  RegCloseKey(regKey);
404  return;
405  }
406 
407  PathRemoveExtension(backgroundItem->szDisplayName);
408 
409  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
410  if (FAILED(hr))
411  {
412  RegCloseKey(regKey);
413  return;
414  }
415 
416  ZeroMemory(&listItem, sizeof(LV_ITEM));
417  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
418  listItem.state = 0;
419  listItem.pszText = backgroundItem->szDisplayName;
420  listItem.iImage = sfi.iIcon;
421  listItem.iItem = pData->listViewItemCount;
422  listItem.lParam = pData->listViewItemCount;
423 
424  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
425  ListView_SetItemState(hwndBackgroundList,
426  pData->listViewItemCount,
428  LVIS_SELECTED);
429 
430  pData->listViewItemCount++;
431  }
432 
433  RegCloseKey(regKey);
434  }
435 
436  /* Add all the images in the C:\ReactOS directory. */
437  if (GetWindowsDirectory(szSearchPath, MAX_PATH))
438  {
439  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
440  }
441 
442  /* Add all the images in the wallpaper directory. */
443  if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
444  {
445  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
446  }
447 }
#define RegQueryValueEx
Definition: winreg.h:524
#define LV_ITEM
Definition: commctrl.h:2337
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:2587
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
GLuint64EXT * result
Definition: glext.h:11304
#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:2547
#define IDS_NONE
Definition: resource.h:133
#define ExpandEnvironmentStrings
Definition: winbase.h:3645
#define ZeroMemory
Definition: winbase.h:1670
static UINT AddWallpapersFromDirectory(UINT uCounter, HWND hwndBackgroundList, BackgroundItem *backgroundItem, PBACKGROUND_DATA pData, LPCTSTR wallpaperFilename, LPCTSTR wallpaperDirectory)
Definition: background.c:172
GLuint buffer
Definition: glext.h:5915
#define SM_CYSMICON
Definition: winuser.h:1007
HINSTANCE hApplet
Definition: access.c:17
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
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:358
#define LVIF_TEXT
Definition: commctrl.h:2309
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define L(x)
Definition: ntvdm.h:50
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:2673
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:585
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#define LVIS_SELECTED
Definition: commctrl.h:2319
#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:414
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
#define LVIF_IMAGE
Definition: commctrl.h:2310
#define IDC_BACKGROUND_LIST
Definition: resource.h:28
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:1006
TCHAR szDisplayName[256]
Definition: background.c:45
#define StringCbCopy
Definition: strsafe.h:155
#define SHRegGetPath
Definition: shlwapi.h:196
size_t bufferSize
#define ILC_MASK
Definition: commctrl.h:351
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
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
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 NULL
Definition: types.h:112
#define SM_CXVSCROLL
Definition: winuser.h:955
TCHAR szFilename[MAX_PATH]
Definition: background.c:44
_Out_opt_ int * cx
Definition: commctrl.h:585
#define LVIF_PARAM
Definition: commctrl.h:2311
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:2312
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SHGFI_ICON
Definition: shellapi.h:162
#define GetWindowsDirectory
Definition: winbase.h:3728
static HMODULE hShell32
Definition: string.c:34
#define RegCloseKey(hKey)
Definition: registry.h:47
#define LoadString
Definition: winuser.h:5809
#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 172 of file background.c.

173 {
175  HANDLE hFind;
176  TCHAR szSearchPath[MAX_PATH];
177  LPTSTR szFileTypes = NULL;
178  TCHAR separators[] = TEXT(";");
179  TCHAR *token;
180  HRESULT hr;
181  SHFILEINFO sfi;
182  UINT i = uCounter;
183  LV_ITEM listItem;
185 
186  szFileTypes = GdipGetSupportedFileExtensions();
187  if (!szFileTypes)
188  {
189  return i;
190  }
191 
192  himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
193 
194  token = _tcstok(szFileTypes, separators);
195  while (token != NULL)
196  {
197  if (!PathCombine(szSearchPath, wallpaperDirectory, token))
198  {
199  HeapFree(GetProcessHeap(), 0, szFileTypes);
200  return i;
201  }
202 
203  hFind = FindFirstFile(szSearchPath, &fd);
204  while (hFind != INVALID_HANDLE_VALUE)
205  {
207 
208  if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
209  {
210  FindClose(hFind);
211  HeapFree(GetProcessHeap(), 0, szFileTypes);
212  return i;
213  }
214 
215  /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
216  if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
217  {
219  0,
220  &sfi,
221  sizeof(sfi),
223  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
224  i++;
225 
226  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
227 
228  backgroundItem->bWallpaper = TRUE;
229 
230  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
231  if (FAILED(hr))
232  {
233  FindClose(hFind);
234  HeapFree(GetProcessHeap(), 0, szFileTypes);
235  return i;
236  }
237 
238  PathRemoveExtension(backgroundItem->szDisplayName);
239 
240  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
241  if (FAILED(hr))
242  {
243  FindClose(hFind);
244  HeapFree(GetProcessHeap(), 0, szFileTypes);
245  return i;
246  }
247 
248  ZeroMemory(&listItem, sizeof(LV_ITEM));
249  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
250  listItem.pszText = backgroundItem->szDisplayName;
251  listItem.state = 0;
252  listItem.iImage = sfi.iIcon;
253  listItem.iItem = pData->listViewItemCount;
254  listItem.lParam = pData->listViewItemCount;
255 
256  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
257 
258  pData->listViewItemCount++;
259  }
260 
261  if (!FindNextFile(hFind, &fd))
262  break;
263  }
264 
265  token = _tcstok(NULL, separators);
266  FindClose(hFind);
267  }
268 
269  HeapFree(GetProcessHeap(), 0, szFileTypes);
270 
271  return i;
272 }
#define LV_ITEM
Definition: commctrl.h:2337
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:2299
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:731
#define ZeroMemory
Definition: winbase.h:1670
static int fd
Definition: io.c:51
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
const char * filename
Definition: ioapi.h:137
HIMAGELIST himl
#define SHGFI_SMALLICON
Definition: shellapi.h:174
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define LVIF_TEXT
Definition: commctrl.h:2309
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2296
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
#define FindFirstFile
Definition: winbase.h:3653
char TCHAR
Definition: xmlstorage.h:189
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:366
#define GetProcessHeap()
Definition: compat.h:736
LONG HRESULT
Definition: typedefs.h:79
#define FindNextFile
Definition: winbase.h:3659
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:115
#define MAX_PATH
Definition: compat.h:34
#define LVIF_IMAGE
Definition: commctrl.h:2310
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
TCHAR szDisplayName[256]
Definition: background.c:45
#define StringCbCopy
Definition: strsafe.h:155
#define TEXT(s)
Definition: k32.h:26
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 FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define _tcstok
Definition: tchar.h:1416
TCHAR szFilename[MAX_PATH]
Definition: background.c:44
#define LVIF_PARAM
Definition: commctrl.h:2311
#define SHGetFileInfo
Definition: shellapi.h:695
HICON hIcon
Definition: shellapi.h:363
#define LVIF_STATE
Definition: commctrl.h:2312
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:735
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 1179 of file background.c.

1183 {
1185  struct GdiplusStartupInput gdipStartup;
1186 
1188 
1189  switch (uMsg)
1190  {
1191  case WM_INITDIALOG:
1194  gdipStartup.GdiplusVersion = 1;
1195  gdipStartup.DebugEventCallback = NULL;
1196  gdipStartup.SuppressBackgroundThread = FALSE;
1197  gdipStartup.SuppressExternalCodecs = FALSE;
1198  GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1199  InitBackgroundDialog(hwndDlg, pData);
1200  InitDesktopSettings(&pData->desktopData);
1201  break;
1202 
1203  case WM_COMMAND:
1204  {
1205  DWORD controlId = LOWORD(wParam);
1207 
1208  switch (controlId)
1209  {
1210  case IDC_COLOR_BUTTON:
1211  if (command == BN_CLICKED)
1212  OnColorButton(hwndDlg, pData);
1213  break;
1214 
1215  case IDC_BROWSE_BUTTON:
1216  if (command == BN_CLICKED)
1217  OnBrowseButton(hwndDlg, pData);
1218  break;
1219 
1220  case IDC_PLACEMENT_COMBO:
1221  if (command == CBN_SELCHANGE)
1222  {
1223  pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1224 
1226 
1227  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1228  }
1229  break;
1230 
1231  case IDC_DESKTOP_CUSTOM:
1232  if (command == BN_CLICKED)
1233  OnCustomButton(hwndDlg, pData);
1234  break;
1235  }
1236  } break;
1237 
1238  case WM_DRAWITEM:
1239  {
1240  LPDRAWITEMSTRUCT drawItem;
1241  drawItem = (LPDRAWITEMSTRUCT)lParam;
1242 
1243  if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1244  {
1245  DrawBackgroundPreview(drawItem, pData);
1246  }
1247 
1248  }
1249  break;
1250 
1251  case WM_NOTIFY:
1252  {
1253  LPNMHDR lpnm = (LPNMHDR)lParam;
1254 
1255  switch(lpnm->code)
1256  {
1257  case PSN_APPLY:
1258  if (pData->bWallpaperChanged)
1260  if (pData->bClrBackgroundChanged)
1261  SetDesktopBackColor(hwndDlg, pData);
1262  if (pData->desktopData.bSettingsChanged)
1263  SetDesktopSettings(&pData->desktopData);
1265  return TRUE;
1266 
1267  case LVN_ITEMCHANGED:
1268  {
1270 
1271  if ((nm->uNewState & LVIS_SELECTED) == 0)
1272  return FALSE;
1273 
1274  ListViewItemChanged(hwndDlg, pData, nm->iItem);
1275  }
1276  break;
1277  }
1278  }
1279  break;
1280 
1281  case WM_DESTROY:
1282  if (pData->pWallpaperBitmap != NULL)
1283  DibFreeImage(pData->pWallpaperBitmap);
1284 
1285  GdiplusShutdown(pData->gdipToken);
1286  HeapFree(GetProcessHeap(), 0, pData);
1287  break;
1288  }
1289 
1290  return FALSE;
1291 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:30
VOID SetDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:181
#define IDC_BROWSE_BUTTON
Definition: resource.h:31
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:989
static VOID OnCustomButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1146
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
UINT uNewState
Definition: commctrl.h:3036
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define TRUE
Definition: types.h:120
struct _BACKGROUND_DATA * PBACKGROUND_DATA
#define LVN_ITEMCHANGED
Definition: commctrl.h:3131
struct _BACKGROUND_DATA BACKGROUND_DATA
#define SendDlgItemMessage
Definition: winuser.h:5832
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1933
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
#define WM_SETTINGCHANGE
Definition: winuser.h:1619
UINT code
Definition: winuser.h:3149
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:525
#define FALSE
Definition: types.h:117
#define LVIS_SELECTED
Definition: commctrl.h:2319
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_DESTROY
Definition: winuser.h:1599
#define IDC_COLOR_BUTTON
Definition: resource.h:32
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:736
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:1915
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:744
#define WM_COMMAND
Definition: winuser.h:1730
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1113
HWND WINAPI GetParent(_In_ HWND)
struct tagNMLISTVIEW * LPNMLISTVIEW
static VOID InitBackgroundDialog(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:451
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:609
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:778
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define CBN_SELCHANGE
Definition: winuser.h:1969
#define WM_DRAWITEM
Definition: winuser.h:1635
#define SendMessage
Definition: winuser.h:5833
VOID InitDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:63
#define IDC_PLACEMENT_COMBO
Definition: resource.h:33
#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:1194
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WM_NOTIFY
Definition: richedit.h:61
#define IDC_DESKTOP_CUSTOM
Definition: resource.h:36
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 591 of file background.c.

592 {
593  LVFINDINFO lvfi;
594  int retVal;
595 
596  lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
597  lvfi.psz = tszFileName; /* String to search */
598 
599  /* Other items of this structure are not valid, besacuse flags are not set. */
600  retVal = ListView_FindItem(hwndList, -1, &lvfi);
601  if (retVal != -1)
602  return TRUE; /* item found! */
603 
604  return FALSE; /* item not found. */
605 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define LVFINDINFO
Definition: commctrl.h:2463
#define LVFI_STRING
Definition: commctrl.h:2437
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470

Referenced by OnBrowseButton().

◆ DrawBackgroundPreview()

static VOID DrawBackgroundPreview ( LPDRAWITEMSTRUCT  draw,
PBACKGROUND_DATA  pData 
)
static

Definition at line 778 of file background.c.

779 {
780  float scaleX;
781  float scaleY;
782  int scaledWidth;
783  int scaledHeight;
784  int posX, desX;
785  int posY, desY;
786  int fitFillScaleNum, fitFillScaleDen;
787  int fitFillWidth, fitFillHeight;
788  HBRUSH hBrush;
789  int x;
790  int y;
791  HDC hDC;
792  HGDIOBJ hOldObj;
793  RECT rcItem = {
794  MONITOR_LEFT,
795  MONITOR_TOP,
798  };
799 
800  hDC = CreateCompatibleDC(draw->hDC);
802 
803  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
804  {
805  /* Update desktop background color image */
807  FillRect(hDC, &rcItem, hBrush);
808  DeleteObject(hBrush);
809  }
810  else
811  if (pData->pWallpaperBitmap != NULL)
812  {
813  scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
814  scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
815 
816  scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
817  scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
818 
820 
822 
823  switch (pData->placementSelection)
824  {
825  case PLACEMENT_CENTER:
826  posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
827  posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
828  desX = 0;
829  desY = 0;
830 
831  if (posX < 0) { desX = -posX / 2; posX = 0; }
832  if (posY < 0) { desY = -posY / 2; posY = 0; }
833 
834  if (scaledWidth > MONITOR_WIDTH)
835  scaledWidth = MONITOR_WIDTH;
836 
837  if (scaledHeight > MONITOR_HEIGHT)
838  scaledHeight = MONITOR_HEIGHT;
839 
841  MONITOR_LEFT+posX,
842  MONITOR_TOP+posY,
843  scaledWidth,
844  scaledHeight,
845  desX,
846  desY,
847  pData->pWallpaperBitmap->width - (int)(desX * scaleX),
848  pData->pWallpaperBitmap->height - (int)(desY * scaleY),
849  pData->pWallpaperBitmap->bits,
850  pData->pWallpaperBitmap->info,
852  SRCCOPY);
853  break;
854 
855  case PLACEMENT_STRETCH:
857  MONITOR_LEFT,
858  MONITOR_TOP,
861  0,
862  0,
863  pData->pWallpaperBitmap->width,
864  pData->pWallpaperBitmap->height,
865  pData->pWallpaperBitmap->bits,
866  pData->pWallpaperBitmap->info,
868  SRCCOPY);
869  break;
870 
871  case PLACEMENT_TILE:
872  for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
873  {
874  for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
875  {
876  if ((MONITOR_WIDTH-x) >= scaledWidth)
877  posX = scaledWidth;
878  else
879  posX = MONITOR_WIDTH-x;
880 
881 
882  if ((MONITOR_HEIGHT-y) >= scaledHeight)
883  posY = scaledHeight;
884  else
885  posY = MONITOR_HEIGHT-y;
886 
888  MONITOR_LEFT + x,
889  MONITOR_TOP + y,
890  posX,
891  posY,
892  0,
893  0,
894  pData->pWallpaperBitmap->width * posX / scaledWidth,
895  pData->pWallpaperBitmap->height * posY / scaledHeight,
896  pData->pWallpaperBitmap->bits,
897  pData->pWallpaperBitmap->info,
899  SRCCOPY);
900  }
901 
902  }
903 
904  break;
905 
906  case PLACEMENT_FIT:
907  if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
908  {
909  fitFillScaleNum = MONITOR_WIDTH;
910  fitFillScaleDen = scaledWidth;
911  }
912  else
913  {
914  fitFillScaleNum = MONITOR_HEIGHT;
915  fitFillScaleDen = scaledHeight;
916  }
917 
918  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
919  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
920 
921  posX = (MONITOR_WIDTH - fitFillWidth) / 2;
922  posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
923 
925  MONITOR_LEFT + posX,
926  MONITOR_TOP + posY,
927  fitFillWidth,
928  fitFillHeight,
929  0,
930  0,
931  pData->pWallpaperBitmap->width,
932  pData->pWallpaperBitmap->height,
933  pData->pWallpaperBitmap->bits,
934  pData->pWallpaperBitmap->info,
936  SRCCOPY);
937  break;
938 
939  case PLACEMENT_FILL:
940  if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
941  {
942  fitFillScaleNum = MONITOR_WIDTH;
943  fitFillScaleDen = scaledWidth;
944  }
945  else
946  {
947  fitFillScaleNum = MONITOR_HEIGHT;
948  fitFillScaleDen = scaledHeight;
949  }
950 
951  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
952  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
953 
954  desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
955  desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
956 
958  MONITOR_LEFT,
959  MONITOR_TOP,
962  desX,
963  desY,
964  (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
965  (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
966  pData->pWallpaperBitmap->bits,
967  pData->pWallpaperBitmap->info,
969  SRCCOPY);
970  break;
971  }
972  }
973 
974  GdiTransparentBlt(draw->hDC,
975  draw->rcItem.left, draw->rcItem.top,
976  draw->rcItem.right - draw->rcItem.left + 1,
977  draw->rcItem.bottom - draw->rcItem.top + 1,
978  hDC,
979  0, 0,
981  MONITOR_ALPHA);
982 
983  SelectObject(hDC, hOldObj);
984  DeleteDC(hDC);
985 }
#define MONITOR_BOTTOM
Definition: desk.h:74
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:159
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
LONG bmMonHeight
Definition: desk.h:164
LONG left
Definition: windef.h:306
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define COLORONCOLOR
Definition: wingdi.h:954
LONG right
Definition: windef.h:308
#define SM_CXSCREEN
Definition: winuser.h:953
#define FALSE
Definition: types.h:117
HBITMAP hMonitorBitmap
Definition: desk.h:162
#define SM_CYSCREEN
Definition: winuser.h:954
#define MONITOR_ALPHA
Definition: desk.h:79
int WINAPI GetSystemMetrics(_In_ int)
LONG bmMonWidth
Definition: desk.h:163
#define MONITOR_TOP
Definition: desk.h:72
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1366
#define MONITOR_WIDTH
Definition: desk.h:76
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
static float(__cdecl *square_half_float)(float x
#define MONITOR_HEIGHT
Definition: desk.h:77
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLOBAL_DATA g_GlobalData
Definition: background.c:70
LONG bottom
Definition: windef.h:309
#define COLOR_BACKGROUND
Definition: hardware.h:164
#define MONITOR_LEFT
Definition: desk.h:71
#define MONITOR_RIGHT
Definition: desk.h:73
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SRCCOPY
Definition: wingdi.h:333
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 74 of file background.c.

75 {
76  UINT num;
77  UINT size;
78  UINT i;
79  ImageCodecInfo *codecInfo;
80 
81  if (GdipGetImageEncodersSize(&num, &size) != Ok ||
82  size == 0)
83  {
84  return E_FAIL;
85  }
86 
87  codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
88  if (!codecInfo)
89  {
90  return E_OUTOFMEMORY;
91  }
92 
93  if (GdipGetImageEncoders(num, size, codecInfo) != Ok)
94  {
95  HeapFree(GetProcessHeap(), 0, codecInfo);
96  return E_FAIL;
97  }
98 
99  for (i = 0; i < num; i++)
100  {
101  if (!_wcsicmp(codecInfo[i].MimeType, MimeType))
102  {
103  *pClsid = codecInfo[i].Clsid;
104  HeapFree(GetProcessHeap(), 0, codecInfo);
105  return S_OK;
106  }
107  }
108 
109  HeapFree(GetProcessHeap(), 0, codecInfo);
110  return E_FAIL;
111 }
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
Definition: image.c:5069
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint GLuint num
Definition: glext.h:9618
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
Definition: image.c:5045
#define S_OK
Definition: intsafe.h:52
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
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:735
_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 115 of file background.c.

116 {
117  ImageCodecInfo *codecInfo;
118  UINT num;
119  UINT size;
120  UINT i;
121  LPWSTR lpBuffer = NULL;
122 
123  if (GdipGetImageDecodersSize(&num, &size) != Ok ||
124  size == 0)
125  {
126  return NULL;
127  }
128 
129  codecInfo = HeapAlloc(GetProcessHeap(), 0, size);
130  if (!codecInfo)
131  {
132  return NULL;
133  }
134 
135  if (GdipGetImageDecoders(num, size, codecInfo) != Ok)
136  {
137  HeapFree(GetProcessHeap(), 0, codecInfo);
138  return NULL;
139  }
140 
141  size = 0;
142  for (i = 0; i < num; ++i)
143  {
144  size = size + (UINT)wcslen(codecInfo[i].FilenameExtension) + 1;
145  }
146 
147  size = (size + 1) * sizeof(WCHAR);
148 
150  if (!lpBuffer)
151  {
152  HeapFree(GetProcessHeap(), 0, codecInfo);
153  return NULL;
154  }
155 
156  for (i = 0; i < num; ++i)
157  {
158  StringCbCatW(lpBuffer, size, codecInfo[i].FilenameExtension);
159  if (i < (num - 1))
160  {
161  StringCbCatW(lpBuffer, size, L";");
162  }
163  }
164 
165  HeapFree(GetProcessHeap(), 0, codecInfo);
166 
167  return lpBuffer;
168 }
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:4994
#define L(x)
Definition: ntvdm.h:50
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
Definition: image.c:5018
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint GLuint num
Definition: glext.h:9618
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
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by AddWallpapersFromDirectory(), and OnBrowseButton().

◆ InitBackgroundDialog()

static VOID InitBackgroundDialog ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 451 of file background.c.

452 {
453  TCHAR szString[256];
454  HKEY regKey;
455  TCHAR szBuffer[3];
456  DWORD bufferSize = sizeof(szBuffer);
457 
458  AddListViewItems(hwndDlg, pData);
459 
460  LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
462 
463  LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
465 
466  LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
468 
469  LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
471 
472  LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
474 
476  pData->placementSelection = PLACEMENT_CENTER;
477 
478  /* Load the default settings from the registry */
479  if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
480  {
481  return;
482  }
483 
484  if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
485  {
486  if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
487  {
489  pData->placementSelection = PLACEMENT_CENTER;
490  }
491 
492  if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
493  {
495  pData->placementSelection = PLACEMENT_STRETCH;
496  }
497 
498  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
499  {
501  pData->placementSelection = PLACEMENT_FIT;
502  }
503 
504  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
505  {
507  pData->placementSelection = PLACEMENT_FILL;
508  }
509  }
510 
511  if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
512  {
513  if (_ttoi(szBuffer) == 1)
514  {
516  pData->placementSelection = PLACEMENT_TILE;
517  }
518  }
519 
520  RegCloseKey(regKey);
521 }
#define RegQueryValueEx
Definition: winreg.h:524
#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:5832
#define IDS_FIT
Definition: resource.h:61
#define IDS_FILL
Definition: resource.h:62
#define IDS_CENTER
Definition: resource.h:58
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CB_INSERTSTRING
Definition: winuser.h:1947
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_TILE
Definition: resource.h:60
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
size_t bufferSize
#define CB_SETCURSEL
Definition: winuser.h:1951
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
#define NULL
Definition: types.h:112
#define IDC_PLACEMENT_COMBO
Definition: resource.h:33
#define IDS_STRETCH
Definition: resource.h:59
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define RegCloseKey(hKey)
Definition: registry.h:47
#define LoadString
Definition: winuser.h:5809
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:277

Referenced by BackgroundPageProc().

◆ ListViewItemChanged()

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

Definition at line 744 of file background.c.

745 {
746  BackgroundItem *backgroundItem = NULL;
747 
748  pData->backgroundSelection = itemIndex;
749  backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
750 
751  if (pData->pWallpaperBitmap != NULL)
752  {
753  DibFreeImage(pData->pWallpaperBitmap);
754  pData->pWallpaperBitmap = NULL;
755  }
756 
757  if (backgroundItem->bWallpaper != FALSE)
758  {
759  pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
760 
761  if (pData->pWallpaperBitmap == NULL)
762  return;
763  }
764 
765  pData->bWallpaperChanged = TRUE;
766 
768  NULL, TRUE);
769 
771  backgroundItem->bWallpaper);
772 
773  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
774 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:30
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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)
#define NULL
Definition: types.h:112
TCHAR szFilename[MAX_PATH]
Definition: background.c:44
#define IDC_PLACEMENT_COMBO
Definition: resource.h:33
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 609 of file background.c.

610 {
613  TCHAR fileTitle[256];
614  TCHAR initialDir[MAX_PATH];
615  LPTSTR filter;
616  LPTSTR extensions;
617  BackgroundItem *backgroundItem = NULL;
618  SHFILEINFO sfi;
619  LV_ITEM listItem;
620  HWND hwndBackgroundList;
621  TCHAR *p;
622  HRESULT hr;
623  TCHAR filterdesc[MAX_PATH];
624  TCHAR *c;
625  size_t sizeRemain;
626  SIZE_T buffersize;
627  BOOL success;
629 
630  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
631  himl = ListView_GetImageList(hwndBackgroundList, LVSIL_SMALL);
632  SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, initialDir);
633 
634  ZeroMemory(&ofn, sizeof(OPENFILENAME));
635 
636  ofn.lStructSize = sizeof(OPENFILENAME);
637  ofn.hwndOwner = hwndDlg;
639 
640  LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
641 
642  extensions = GdipGetSupportedFileExtensions();
643  if (!extensions)
644  {
645  return;
646  }
647 
648  buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
649 
651  if (!filter)
652  {
653  HeapFree(GetProcessHeap(), 0, extensions);
654  return;
655  }
656 
657  sizeRemain = buffersize;
658  c = filter;
659 
660  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
661  {
662  HeapFree(GetProcessHeap(), 0, extensions);
664  return;
665  }
666 
667  c++;
668  sizeRemain -= sizeof(*c);
669 
670  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
671  {
672  HeapFree(GetProcessHeap(), 0, extensions);
674  return;
675  }
676 
677  HeapFree(GetProcessHeap(), 0, extensions);
678 
679  /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
680  * use the contents of szFile to initialize itself */
681  ofn.lpstrFile[0] = TEXT('\0');
684  ofn.nFilterIndex = 0;
685  ofn.lpstrFileTitle = fileTitle;
686  ofn.nMaxFileTitle = 256;
687  ofn.lpstrInitialDir = initialDir;
689 
692 
693  if (success)
694  {
695  /* Check if there is already a entry that holds this filename */
696  if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
697  return;
698 
699  if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
700  return;
701 
703  0,
704  &sfi,
705  sizeof(sfi),
707  sfi.iIcon = ImageList_AddIcon(himl, sfi.hIcon);
708 
709  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
710 
711  backgroundItem->bWallpaper = TRUE;
712 
713  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
714  if (FAILED(hr))
715  return;
716  p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
717  if (p)
718  *p = (TCHAR)0;
719  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
720  if (FAILED(hr))
721  return;
722 
723  ZeroMemory(&listItem, sizeof(LV_ITEM));
724  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
725  listItem.state = 0;
726  listItem.pszText = backgroundItem->szDisplayName;
727  listItem.iImage = sfi.iIcon;
728  listItem.iItem = pData->listViewItemCount;
729  listItem.lParam = pData->listViewItemCount;
730 
731  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
732  ListView_SetItemState(hwndBackgroundList,
733  pData->listViewItemCount,
735  LVIS_SELECTED);
736  SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
737 
738  pData->listViewItemCount++;
739  }
740 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
#define LV_ITEM
Definition: commctrl.h:2337
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:2299
HRESULT hr
Definition: shlfolder.c:183
LPSTR lpstrFileTitle
Definition: commdlg.h:338
#define CSIDL_MYPICTURES
Definition: shlobj.h:2063
HWND hwndOwner
Definition: commdlg.h:330
#define TRUE
Definition: types.h:120
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1670
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
const char * filename
Definition: ioapi.h:137
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:2309
#define L(x)
Definition: ntvdm.h:50
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2296
#define FALSE
Definition: types.h:117
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:591
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2673
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
#define LVIS_SELECTED
Definition: commctrl.h:2319
#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:736
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:115
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:2310
const GLubyte * c
Definition: glext.h:8905
#define IDC_BACKGROUND_LIST
Definition: resource.h:28
#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:34
TCHAR szDisplayName[256]
Definition: background.c:45
#define StringCbCopy
Definition: strsafe.h:155
#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 NULL
Definition: types.h:112
#define SB_BOTTOM
Definition: winuser.h:577
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
TCHAR szFilename[MAX_PATH]
Definition: background.c:44
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2558
#define SendMessage
Definition: winuser.h:5833
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define LVIF_PARAM
Definition: commctrl.h:2311
#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:2312
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:735
#define LoadString
Definition: winuser.h:5809
#define MAX_BACKGROUNDS
Definition: background.c:16
#define WM_VSCROLL
Definition: winuser.h:1734
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 525 of file background.c.

526 {
527  /* Load custom colors from Registry */
528  HKEY hKey = NULL;
530  CHOOSECOLOR cc;
531 
532  res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
534  /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
535  if (res == ERROR_SUCCESS)
536  {
537  /* Key opened */
538  DWORD dwType = REG_BINARY;
539  DWORD cbData = sizeof(pData->custom_colors);
540  res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
541  (LPBYTE)pData->custom_colors, &cbData);
542  RegCloseKey(hKey);
543  hKey = NULL;
544  }
545 
546  /* Launch ChooseColor() dialog */
547 
548  cc.lStructSize = sizeof(CHOOSECOLOR);
549  cc.hwndOwner = hwndDlg;
550  cc.hInstance = NULL;
551  cc.rgbResult = g_GlobalData.desktop_color;
552  cc.lpCustColors = pData->custom_colors;
553  cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
554  CC_FULLOPEN | /* opens dialog in full size */
555  CC_RGBINIT ; /* init chosen color by rgbResult value */
556  cc.lCustData = 0;
557  cc.lpfnHook = NULL;
558  cc.lpTemplateName = NULL;
559  if (ChooseColor(&cc))
560  {
561  /* Save selected color to var */
562  g_GlobalData.desktop_color = cc.rgbResult;
563  pData->bClrBackgroundChanged = TRUE;
564 
565  /* Apply button will be activated */
566  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
567 
568  /* Window will be updated :) */
570 
571  /* Save custom colors to reg. To this moment key must be created already. See above */
572  res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
573  KEY_SET_VALUE, &hKey);
574  if (res == ERROR_SUCCESS)
575  {
576  /* Key opened */
577  RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
578  (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
579  RegCloseKey(hKey);
580  hKey = NULL;
581  }
582  }
583 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:30
#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:159
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#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
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
GLOBAL_DATA g_GlobalData
Definition: background.c:70
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define RegCloseKey(hKey)
Definition: registry.h:47
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define CC_FULLOPEN
Definition: commdlg.h:51

Referenced by BackgroundPageProc().

◆ OnCustomButton()

static VOID OnCustomButton ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 1146 of file background.c.

1147 {
1148  HPROPSHEETPAGE hpsp[1] = {0};
1149  PROPSHEETHEADER psh = {sizeof(psh)};
1150  PROPSHEETPAGE psp = {sizeof(psp)};
1151 
1152  psh.dwFlags = PSH_NOAPPLYNOW;
1153  psh.hwndParent = GetParent(hwndDlg);
1154  psh.hInstance = hApplet;
1155  psh.pszCaption = MAKEINTRESOURCE(IDS_DESKTOP_ITEMS);
1156  psh.phpage = hpsp;
1157 
1158  psp.dwFlags = PSP_DEFAULT;
1159  psp.hInstance = hApplet;
1160  psp.pszTemplate = MAKEINTRESOURCE(IDD_DESKTOP_GENERAL);
1161  psp.pfnDlgProc = DesktopPageProc;
1162  psp.lParam = (LPARAM)&pData->desktopData;
1163 
1164  hpsp[0] = CreatePropertySheetPage(&psp);
1165  if (!hpsp[0])
1166  return;
1167 
1168  psh.nPages++;
1169 
1170  if (PropertySheet(&psh) > 0)
1171  {
1172  if (SaveDesktopSettings(&pData->desktopData))
1173  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1174  }
1175 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
HINSTANCE hApplet
Definition: access.c:17
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define PROPSHEETHEADER
Definition: prsht.h:392
#define IDD_DESKTOP_GENERAL
Definition: resource.h:17
LONG_PTR LPARAM
Definition: windef.h:208
#define CreatePropertySheetPage
Definition: prsht.h:399
INT_PTR CALLBACK DesktopPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
BOOL SaveDesktopSettings(PDESKTOP_DATA pData)
Definition: desktop.c:127
#define PSP_DEFAULT
Definition: prsht.h:22
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define IDS_DESKTOP_ITEMS
Definition: resource.h:184
HWND WINAPI GetParent(_In_ HWND)
#define PropertySheet
Definition: prsht.h:400
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define PROPSHEETPAGE
Definition: prsht.h:389

Referenced by BackgroundPageProc().

◆ SetDesktopBackColor()

static VOID SetDesktopBackColor ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 1113 of file background.c.

1114 {
1115  HKEY hKey;
1116  INT iElement = COLOR_BACKGROUND;
1117  TCHAR clText[16];
1118  BYTE red, green, blue;
1119 
1120  if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1121  {
1122  /* FIXME: these error texts can need internationalization? */
1123  MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1124  TEXT("Error!"), MB_ICONSTOP );
1125  }
1126 
1127  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1129  {
1130  return;
1131  }
1132 
1136 
1137  /* Format string to be set to registry */
1138  StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1139  RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1140  (wcslen(clText) + 1) * sizeof(TCHAR));
1141 
1142  RegCloseKey(hKey);
1143 }
#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:159
#define GetRValue(quad)
Definition: precomp.h:64
#define MB_ICONSTOP
Definition: winuser.h:797
int32_t INT
Definition: typedefs.h:58
unsigned char * LPBYTE
Definition: typedefs.h:53
#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:5812
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
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
GLOBAL_DATA g_GlobalData
Definition: background.c:70
#define COLOR_BACKGROUND
Definition: hardware.h:164
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 989 of file background.c.

990 {
991  HKEY regKey;
992  TCHAR szWallpaper[MAX_PATH];
993  GpImage *image;
994  CLSID encoderClsid;
995  GUID guidFormat;
996  size_t length = 0;
998 
1000  {
1001  return;
1002  }
1003 
1004  if (FAILED(StringCbCat(szWallpaper, sizeof(szWallpaper), TEXT("\\Wallpaper1.bmp"))))
1005  {
1006  return;
1007  }
1008 
1009  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1011  {
1012  return;
1013  }
1014 
1015  if (pData->placementSelection == PLACEMENT_TILE)
1016  {
1017  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1018  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1019  }
1020 
1021  if (pData->placementSelection == PLACEMENT_CENTER)
1022  {
1023  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1024  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1025  }
1026 
1027  if (pData->placementSelection == PLACEMENT_STRETCH)
1028  {
1029  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1030  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1031  }
1032 
1033  if (pData->placementSelection == PLACEMENT_FIT)
1034  {
1035  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1036  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1037  }
1038 
1039  if (pData->placementSelection == PLACEMENT_FILL)
1040  {
1041  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1042  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1043  }
1044 
1045  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1046  {
1047  GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1048  if (!image)
1049  {
1050  RegCloseKey(regKey);
1051  return;
1052  }
1053 
1054  GdipGetImageRawFormat(image, &guidFormat);
1055  if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1056  {
1058  RegCloseKey(regKey);
1059  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1060  return;
1061  }
1062 
1063  if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1064  {
1066  RegCloseKey(regKey);
1067  return;
1068  }
1069 
1070  status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1071 
1073 
1074  if (status != Ok)
1075  {
1076  RegCloseKey(regKey);
1077  return;
1078  }
1079 
1080  if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1081  {
1082  RegSetValueEx(regKey,
1083  TEXT("ConvertedWallpaper"),
1084  0,
1085  REG_SZ,
1086  (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1087  (DWORD)((length + 1) * sizeof(TCHAR)));
1088  }
1089 
1090  if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1091  {
1092  RegSetValueEx(regKey,
1093  TEXT("OriginalWallpaper"),
1094  0,
1095  REG_SZ,
1096  (LPBYTE)szWallpaper,
1097  (DWORD)((length + 1) * sizeof(TCHAR)));
1098  }
1099 
1101  }
1102  else
1103  {
1105  }
1106 
1107  RegCloseKey(regKey);
1108 }
#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:2976
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1359
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SHGetFolderPath
Definition: shlobj.h:2023
#define SystemParametersInfo
Definition: winuser.h:5848
HRESULT GdipGetEncoderClsid(PCWSTR MimeType, CLSID *pClsid)
Definition: background.c:74
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
Definition: image.c:4476
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
if SUCCEEDED(hr)
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
Definition: image.c:2354
Status
Definition: gdiplustypes.h:24
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
char TCHAR
Definition: xmlstorage.h:189
#define StringCbCat
Definition: strsafe.h:334
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2052
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1561
#define TEXT(s)
Definition: k32.h:26
#define NULL
Definition: types.h:112
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 RegCloseKey(hKey)
Definition: registry.h:47
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

Referenced by BackgroundPageProc().

Variable Documentation

◆ g_GlobalData