ReactOS  0.4.14-dev-98-gb0d4763
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)
 

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

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

296 {
297  TCHAR szSearchPath[MAX_PATH];
298  LV_ITEM listItem;
300  RECT clientRect;
301  HKEY regKey;
302  SHFILEINFO sfi;
304  TCHAR wallpaperFilename[MAX_PATH];
305  TCHAR originalWallpaper[MAX_PATH];
306  DWORD bufferSize = sizeof(wallpaperFilename);
308  DWORD varType = REG_SZ;
309  LONG result;
310  UINT i = 0;
311  BackgroundItem *backgroundItem = NULL;
312  HWND hwndBackgroundList;
313  HRESULT hr;
314 
315  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
316 
317  GetClientRect(hwndBackgroundList, &clientRect);
318 
319  /* Add a new column to the list */
320  ZeroMemory(&dummy, sizeof(LV_COLUMN));
321  dummy.mask = LVCF_SUBITEM | LVCF_WIDTH;
322  dummy.iSubItem = 0;
323  dummy.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
324  (void)ListView_InsertColumn(hwndBackgroundList, 0, &dummy);
325 
326  /* Add the "None" item */
327  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
328  backgroundItem->bWallpaper = FALSE;
330  IDS_NONE,
331  backgroundItem->szDisplayName,
332  sizeof(backgroundItem->szDisplayName) / sizeof(TCHAR));
333 
334  ZeroMemory(&listItem, sizeof(LV_ITEM));
335  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
336  listItem.state = 0;
337  listItem.pszText = backgroundItem->szDisplayName;
338  listItem.iImage = -1;
339  listItem.iItem = pData->listViewItemCount;
340  listItem.lParam = pData->listViewItemCount;
341 
342  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
343  ListView_SetItemState(hwndBackgroundList,
344  pData->listViewItemCount,
346  LVIS_SELECTED);
347 
348  pData->listViewItemCount++;
349 
350  /* Add current wallpaper if any */
351  result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey);
352  if (result == ERROR_SUCCESS)
353  {
354  result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
355  if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
356  {
357  bufferSize = sizeof(originalWallpaper);
358  result = RegQueryValueEx(regKey, TEXT("OriginalWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
359 
360  /* If Wallpaper and OriginalWallpaper are the same, try to retrieve ConvertedWallpaper and use it instead of Wallpaper */
361  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0) && (_tcsicmp(wallpaperFilename, originalWallpaper) == 0))
362  {
363  bufferSize = sizeof(originalWallpaper);
364  result = RegQueryValueEx(regKey, TEXT("ConvertedWallpaper"), 0, &varType, (LPBYTE)originalWallpaper, &bufferSize);
365 
366  if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0))
367  {
368  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper);
369  if (FAILED(hr))
370  {
371  RegCloseKey(regKey);
372  return;
373  }
374  }
375  }
376 
377  /* Allow environment variables in file name */
378  if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
379  {
380  hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), buffer);
381  if (FAILED(hr))
382  {
383  RegCloseKey(regKey);
384  return;
385  }
386  }
387 
388  himl = (HIMAGELIST)SHGetFileInfo(wallpaperFilename,
389  0,
390  &sfi,
391  sizeof(sfi),
394  if (himl != NULL)
395  {
396  if (i++ == 0)
397  {
398  (void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
399  }
400 
401  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
402 
403  backgroundItem->bWallpaper = TRUE;
404 
405  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
406  if (FAILED(hr))
407  {
408  RegCloseKey(regKey);
409  return;
410  }
411 
412  PathRemoveExtension(backgroundItem->szDisplayName);
413 
414  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), wallpaperFilename);
415  if (FAILED(hr))
416  {
417  RegCloseKey(regKey);
418  return;
419  }
420 
421  ZeroMemory(&listItem, sizeof(LV_ITEM));
422  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
423  listItem.state = 0;
424  listItem.pszText = backgroundItem->szDisplayName;
425  listItem.iImage = sfi.iIcon;
426  listItem.iItem = pData->listViewItemCount;
427  listItem.lParam = pData->listViewItemCount;
428 
429  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
430  ListView_SetItemState(hwndBackgroundList,
431  pData->listViewItemCount,
433  LVIS_SELECTED);
434 
435  pData->listViewItemCount++;
436  }
437  }
438 
439  RegCloseKey(regKey);
440  }
441 
442  /* Add all the images in the C:\ReactOS directory. */
443  if (GetWindowsDirectory(szSearchPath, MAX_PATH))
444  {
445  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
446  }
447 
448  /* Add all the images in the wallpaper directory. */
449  if (SHRegGetPath(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), TEXT("WallPaperDir"), szSearchPath, 0) == ERROR_SUCCESS)
450  {
451  i = AddWallpapersFromDirectory(i, hwndBackgroundList, backgroundItem, pData, wallpaperFilename, szSearchPath);
452  }
453 }
#define RegQueryValueEx
Definition: winreg.h:524
#define LV_ITEM
Definition: commctrl.h:2309
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:169
#define TRUE
Definition: types.h:120
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:2559
#define LVSIL_SMALL
Definition: commctrl.h:2271
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define _tcsicmp
Definition: xmlstorage.h:205
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define LV_COLUMN
Definition: commctrl.h:2519
#define IDS_NONE
Definition: resource.h:122
#define ExpandEnvironmentStrings
Definition: winbase.h:3598
#define ZeroMemory
Definition: winbase.h:1642
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
HINSTANCE hApplet
Definition: access.c:17
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
HIMAGELIST himl
#define SHGFI_SMALLICON
Definition: shellapi.h:174
#define LVIF_TEXT
Definition: commctrl.h:2281
#define LVCF_SUBITEM
Definition: commctrl.h:2561
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2608
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2645
long LONG
Definition: pedump.c:60
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2276
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
#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)
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define LVIF_IMAGE
Definition: commctrl.h:2282
#define IDC_BACKGROUND_LIST
Definition: resource.h:20
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
TCHAR szDisplayName[256]
Definition: background.c:57
#define StringCbCopy
Definition: strsafe.h:155
#define SHRegGetPath
Definition: shlwapi.h:196
struct _IMAGELIST * HIMAGELIST
Definition: commctrl.h:309
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
unsigned char dummy
Definition: maze.c:118
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
#define LVIF_PARAM
Definition: commctrl.h:2283
#define SHGetFileInfo
Definition: shellapi.h:693
#define LVIF_STATE
Definition: commctrl.h:2284
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
GLuint64EXT * result
Definition: glext.h:11304
#define GetWindowsDirectory
Definition: winbase.h:3681
#define LoadString
Definition: winuser.h:5720
#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  token = _tcstok(szFileTypes, separators);
207  while (token != NULL)
208  {
209  if (!PathCombine(szSearchPath, wallpaperDirectory, token))
210  {
211  HeapFree(GetProcessHeap(), 0, szFileTypes);
212  return i;
213  }
214 
215  hFind = FindFirstFile(szSearchPath, &fd);
216  while (hFind != INVALID_HANDLE_VALUE)
217  {
219 
220  if (!PathCombine(filename, wallpaperDirectory, fd.cFileName))
221  {
222  FindClose(hFind);
223  HeapFree(GetProcessHeap(), 0, szFileTypes);
224  return i;
225  }
226 
227  /* Don't add any hidden bitmaps. Also don't add current wallpaper once more. */
228  if (((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) && (_tcsicmp(wallpaperFilename, filename) != 0))
229  {
231  0,
232  &sfi,
233  sizeof(sfi),
236  if (himl == NULL)
237  break;
238 
239  if (i++ == 0)
240  {
241  (void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
242  }
243 
244  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
245 
246  backgroundItem->bWallpaper = TRUE;
247 
248  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
249  if (FAILED(hr))
250  {
251  FindClose(hFind);
252  HeapFree(GetProcessHeap(), 0, szFileTypes);
253  return i;
254  }
255 
256  PathRemoveExtension(backgroundItem->szDisplayName);
257 
258  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
259  if (FAILED(hr))
260  {
261  FindClose(hFind);
262  HeapFree(GetProcessHeap(), 0, szFileTypes);
263  return i;
264  }
265 
266  ZeroMemory(&listItem, sizeof(LV_ITEM));
267  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
268  listItem.pszText = backgroundItem->szDisplayName;
269  listItem.state = 0;
270  listItem.iImage = sfi.iIcon;
271  listItem.iItem = pData->listViewItemCount;
272  listItem.lParam = pData->listViewItemCount;
273 
274  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
275 
276  pData->listViewItemCount++;
277  }
278 
279  if (!FindNextFile(hFind, &fd))
280  break;
281  }
282 
283  token = _tcstok(NULL, separators);
284  FindClose(hFind);
285  }
286 
287  HeapFree(GetProcessHeap(), 0, szFileTypes);
288 
289  return i;
290 }
#define LV_ITEM
Definition: commctrl.h:2309
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:169
#define TRUE
Definition: types.h:120
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:2271
HRESULT hr
Definition: shlfolder.c:183
#define _tcsicmp
Definition: xmlstorage.h:205
#define PathCombine
Definition: shlwapi.h:825
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1642
static int fd
Definition: io.c:51
#define PathRemoveExtension
Definition: shlwapi.h:1031
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
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:2281
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
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 ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2276
smooth NULL
Definition: ftsmooth.c:416
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:164
#define FindFirstFile
Definition: winbase.h:3606
char TCHAR
Definition: xmlstorage.h:189
CHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:366
#define GetProcessHeap()
Definition: compat.h:395
LONG HRESULT
Definition: typedefs.h:77
#define FindNextFile
Definition: winbase.h:3612
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:129
#define MAX_PATH
Definition: compat.h:26
#define LVIF_IMAGE
Definition: commctrl.h:2282
TCHAR szDisplayName[256]
Definition: background.c:57
#define StringCbCopy
Definition: strsafe.h:155
struct _IMAGELIST * HIMAGELIST
Definition: commctrl.h:309
#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:2283
#define SHGetFileInfo
Definition: shellapi.h:693
#define LVIF_STATE
Definition: commctrl.h:2284
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define HeapFree(x, y, z)
Definition: compat.h:394
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 1157 of file background.c.

1161 {
1163  struct GdiplusStartupInput gdipStartup;
1164 
1166 
1167  switch (uMsg)
1168  {
1169  case WM_INITDIALOG:
1172  gdipStartup.GdiplusVersion = 1;
1173  gdipStartup.DebugEventCallback = NULL;
1174  gdipStartup.SuppressBackgroundThread = FALSE;
1175  gdipStartup.SuppressExternalCodecs = FALSE;
1176  GdiplusStartup(&pData->gdipToken, &gdipStartup, NULL);
1177  InitBackgroundDialog(hwndDlg, pData);
1178  break;
1179 
1180  case WM_COMMAND:
1181  {
1182  DWORD controlId = LOWORD(wParam);
1184 
1185  switch (controlId)
1186  {
1187  case IDC_COLOR_BUTTON:
1188  if (command == BN_CLICKED)
1189  OnColorButton(hwndDlg, pData);
1190  break;
1191 
1192  case IDC_BROWSE_BUTTON:
1193  if (command == BN_CLICKED)
1194  OnBrowseButton(hwndDlg, pData);
1195  break;
1196 
1197  case IDC_PLACEMENT_COMBO:
1198  if (command == CBN_SELCHANGE)
1199  {
1200  pData->placementSelection = (int)SendDlgItemMessage(hwndDlg, IDC_PLACEMENT_COMBO, CB_GETCURSEL, 0, 0);
1201 
1203 
1204  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
1205  }
1206  break;
1207  }
1208  } break;
1209 
1210  case WM_DRAWITEM:
1211  {
1212  LPDRAWITEMSTRUCT drawItem;
1213  drawItem = (LPDRAWITEMSTRUCT)lParam;
1214 
1215  if (drawItem->CtlID == IDC_BACKGROUND_PREVIEW)
1216  {
1217  DrawBackgroundPreview(drawItem, pData);
1218  }
1219 
1220  }
1221  break;
1222 
1223  case WM_NOTIFY:
1224  {
1225  LPNMHDR lpnm = (LPNMHDR)lParam;
1226 
1227  switch(lpnm->code)
1228  {
1229  case PSN_APPLY:
1230  if (pData->bWallpaperChanged)
1232  if (pData->bClrBackgroundChanged)
1233  SetDesktopBackColor(hwndDlg, pData);
1235  return TRUE;
1236 
1237  case LVN_ITEMCHANGED:
1238  {
1240 
1241  if ((nm->uNewState & LVIS_SELECTED) == 0)
1242  return FALSE;
1243 
1244  ListViewItemChanged(hwndDlg, pData, nm->iItem);
1245  }
1246  break;
1247  }
1248  }
1249  break;
1250 
1251  case WM_DESTROY:
1252  if (pData->pWallpaperBitmap != NULL)
1253  DibFreeImage(pData->pWallpaperBitmap);
1254 
1255  DeleteObject(pData->hBitmap);
1256  GdiplusShutdown(pData->gdipToken);
1257  HeapFree(GetProcessHeap(), 0, pData);
1258  break;
1259  }
1260 
1261  return FALSE;
1262 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:22
#define IDC_BROWSE_BUTTON
Definition: resource.h:23
#define TRUE
Definition: types.h:120
static VOID SetWallpaper(PBACKGROUND_DATA pData)
Definition: background.c:1000
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
UINT uNewState
Definition: commctrl.h:3008
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
struct _BACKGROUND_DATA * PBACKGROUND_DATA
#define LVN_ITEMCHANGED
Definition: commctrl.h:3103
struct _BACKGROUND_DATA BACKGROUND_DATA
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SendDlgItemMessage
Definition: winuser.h:5743
#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:3133
static VOID OnColorButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:541
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_COLOR_BUTTON
Definition: resource.h:24
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
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:755
#define WM_COMMAND
Definition: winuser.h:1722
static VOID SetDesktopBackColor(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:1124
HWND WINAPI GetParent(_In_ HWND)
struct tagNMLISTVIEW * LPNMLISTVIEW
static VOID InitBackgroundDialog(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:457
static VOID OnBrowseButton(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:625
static VOID DrawBackgroundPreview(LPDRAWITEMSTRUCT draw, PBACKGROUND_DATA pData)
Definition: background.c:789
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CBN_SELCHANGE
Definition: winuser.h:1961
#define WM_DRAWITEM
Definition: winuser.h:1627
#define SendMessage
Definition: winuser.h:5744
#define IDC_PLACEMENT_COMBO
Definition: resource.h:25
#define HIWORD(l)
Definition: typedefs.h:246
#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:394
#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 607 of file background.c.

608 {
609  LVFINDINFO lvfi;
610  int retVal;
611 
612  lvfi.flags = LVFI_STRING; /* Search item by EXACT string */
613  lvfi.psz = tszFileName; /* String to search */
614 
615  /* Other items of this structure are not valid, besacuse flags are not set. */
616  retVal = ListView_FindItem(hwndList, -1, &lvfi);
617  if (retVal != -1)
618  return TRUE; /* item found! */
619 
620  return FALSE; /* item not found. */
621 }
#define TRUE
Definition: types.h:120
#define LVFINDINFO
Definition: commctrl.h:2435
#define LVFI_STRING
Definition: commctrl.h:2409
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2442

Referenced by OnBrowseButton().

◆ DrawBackgroundPreview()

static VOID DrawBackgroundPreview ( LPDRAWITEMSTRUCT  draw,
PBACKGROUND_DATA  pData 
)
static

Definition at line 789 of file background.c.

790 {
791  float scaleX;
792  float scaleY;
793  int scaledWidth;
794  int scaledHeight;
795  int posX, desX;
796  int posY, desY;
797  int fitFillScaleNum, fitFillScaleDen;
798  int fitFillWidth, fitFillHeight;
799  HBRUSH hBrush;
800  int x;
801  int y;
802  HDC hDC;
803  HGDIOBJ hOldObj;
804  RECT rcItem = {
805  MONITOR_LEFT,
806  MONITOR_TOP,
809  };
810 
811  hDC = CreateCompatibleDC(draw->hDC);
812  hOldObj = SelectObject(hDC, pData->hBitmap);
813 
814  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper == FALSE)
815  {
816  /* Update desktop background color image */
818  FillRect(hDC, &rcItem, hBrush);
819  DeleteObject(hBrush);
820  }
821  else
822  if (pData->pWallpaperBitmap != NULL)
823  {
824  scaleX = ((float)GetSystemMetrics(SM_CXSCREEN) - 1) / (float)MONITOR_WIDTH;
825  scaleY = ((float)GetSystemMetrics(SM_CYSCREEN) - 1) / (float)MONITOR_HEIGHT;
826 
827  scaledWidth = (int)(pData->pWallpaperBitmap->width / scaleX);
828  scaledHeight = (int)(pData->pWallpaperBitmap->height / scaleY);
829 
831 
833 
834  switch (pData->placementSelection)
835  {
836  case PLACEMENT_CENTER:
837  posX = (MONITOR_WIDTH - scaledWidth + 1) / 2;
838  posY = (MONITOR_HEIGHT - scaledHeight + 1) / 2;
839  desX = 0;
840  desY = 0;
841 
842  if (posX < 0) { desX = -posX / 2; posX = 0; }
843  if (posY < 0) { desY = -posY / 2; posY = 0; }
844 
845  if (scaledWidth > MONITOR_WIDTH)
846  scaledWidth = MONITOR_WIDTH;
847 
848  if (scaledHeight > MONITOR_HEIGHT)
849  scaledHeight = MONITOR_HEIGHT;
850 
852  MONITOR_LEFT+posX,
853  MONITOR_TOP+posY,
854  scaledWidth,
855  scaledHeight,
856  desX,
857  desY,
858  pData->pWallpaperBitmap->width - (int)(desX * scaleX),
859  pData->pWallpaperBitmap->height - (int)(desY * scaleY),
860  pData->pWallpaperBitmap->bits,
861  pData->pWallpaperBitmap->info,
863  SRCCOPY);
864  break;
865 
866  case PLACEMENT_STRETCH:
868  MONITOR_LEFT,
869  MONITOR_TOP,
872  0,
873  0,
874  pData->pWallpaperBitmap->width,
875  pData->pWallpaperBitmap->height,
876  pData->pWallpaperBitmap->bits,
877  pData->pWallpaperBitmap->info,
879  SRCCOPY);
880  break;
881 
882  case PLACEMENT_TILE:
883  for (y = 0; y < MONITOR_HEIGHT; y += scaledHeight)
884  {
885  for (x = 0; x < MONITOR_WIDTH; x += scaledWidth)
886  {
887  if ((MONITOR_WIDTH-x) >= scaledWidth)
888  posX = scaledWidth;
889  else
890  posX = MONITOR_WIDTH-x;
891 
892 
893  if ((MONITOR_HEIGHT-y) >= scaledHeight)
894  posY = scaledHeight;
895  else
896  posY = MONITOR_HEIGHT-y;
897 
899  MONITOR_LEFT + x,
900  MONITOR_TOP + y,
901  posX,
902  posY,
903  0,
904  0,
905  pData->pWallpaperBitmap->width * posX / scaledWidth,
906  pData->pWallpaperBitmap->height * posY / scaledHeight,
907  pData->pWallpaperBitmap->bits,
908  pData->pWallpaperBitmap->info,
910  SRCCOPY);
911  }
912 
913  }
914 
915  break;
916 
917  case PLACEMENT_FIT:
918  if ((MONITOR_WIDTH * scaledHeight) <= (MONITOR_HEIGHT * scaledWidth))
919  {
920  fitFillScaleNum = MONITOR_WIDTH;
921  fitFillScaleDen = scaledWidth;
922  }
923  else
924  {
925  fitFillScaleNum = MONITOR_HEIGHT;
926  fitFillScaleDen = scaledHeight;
927  }
928 
929  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
930  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
931 
932  posX = (MONITOR_WIDTH - fitFillWidth) / 2;
933  posY = (MONITOR_HEIGHT - fitFillHeight) / 2;
934 
936  MONITOR_LEFT + posX,
937  MONITOR_TOP + posY,
938  fitFillWidth,
939  fitFillHeight,
940  0,
941  0,
942  pData->pWallpaperBitmap->width,
943  pData->pWallpaperBitmap->height,
944  pData->pWallpaperBitmap->bits,
945  pData->pWallpaperBitmap->info,
947  SRCCOPY);
948  break;
949 
950  case PLACEMENT_FILL:
951  if ((MONITOR_WIDTH * scaledHeight) > (MONITOR_HEIGHT * scaledWidth))
952  {
953  fitFillScaleNum = MONITOR_WIDTH;
954  fitFillScaleDen = scaledWidth;
955  }
956  else
957  {
958  fitFillScaleNum = MONITOR_HEIGHT;
959  fitFillScaleDen = scaledHeight;
960  }
961 
962  fitFillWidth = MulDiv(scaledWidth, fitFillScaleNum, fitFillScaleDen);
963  fitFillHeight = MulDiv(scaledHeight, fitFillScaleNum, fitFillScaleDen);
964 
965  desX = (((fitFillWidth - MONITOR_WIDTH) * pData->pWallpaperBitmap->width) / (2 * fitFillWidth));
966  desY = (((fitFillHeight - MONITOR_HEIGHT) * pData->pWallpaperBitmap->height) / (2 * fitFillHeight));
967 
969  MONITOR_LEFT,
970  MONITOR_TOP,
973  desX,
974  desY,
975  (MONITOR_WIDTH * pData->pWallpaperBitmap->width) / fitFillWidth,
976  (MONITOR_HEIGHT * pData->pWallpaperBitmap->height) / fitFillHeight,
977  pData->pWallpaperBitmap->bits,
978  pData->pWallpaperBitmap->info,
980  SRCCOPY);
981  break;
982  }
983  }
984 
985  GdiTransparentBlt(draw->hDC,
986  draw->rcItem.left, draw->rcItem.top,
987  draw->rcItem.right-draw->rcItem.left+1,
988  draw->rcItem.bottom-draw->rcItem.top+1,
989  hDC,
990  0, 0,
991  pData->cxSource, pData->cySource,
992  0xFF00FF);
993 
994  SelectObject(hDC, hOldObj);
995  DeleteDC(hDC);
996 }
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:292
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
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:291
#define COLORONCOLOR
Definition: wingdi.h:953
LONG right
Definition: windef.h:293
#define SM_CXSCREEN
Definition: winuser.h:949
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:1324
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
#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:294
#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:395
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:59
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:394
_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:395
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:123
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by AddWallpapersFromDirectory(), and OnBrowseButton().

◆ InitBackgroundDialog()

static VOID InitBackgroundDialog ( HWND  hwndDlg,
PBACKGROUND_DATA  pData 
)
static

Definition at line 457 of file background.c.

458 {
459  TCHAR szString[256];
460  HKEY regKey;
461  TCHAR szBuffer[3];
462  DWORD bufferSize = sizeof(szBuffer);
463  BITMAP bitmap;
464 
465  AddListViewItems(hwndDlg, pData);
466 
467  LoadString(hApplet, IDS_CENTER, szString, sizeof(szString) / sizeof(TCHAR));
469 
470  LoadString(hApplet, IDS_STRETCH, szString, sizeof(szString) / sizeof(TCHAR));
472 
473  LoadString(hApplet, IDS_TILE, szString, sizeof(szString) / sizeof(TCHAR));
475 
476  LoadString(hApplet, IDS_FIT, szString, sizeof(szString) / sizeof(TCHAR));
478 
479  LoadString(hApplet, IDS_FILL, szString, sizeof(szString) / sizeof(TCHAR));
481 
483  pData->placementSelection = PLACEMENT_CENTER;
484 
486  if (pData->hBitmap != NULL)
487  {
488  GetObject(pData->hBitmap, sizeof(BITMAP), &bitmap);
489 
490  pData->cxSource = bitmap.bmWidth;
491  pData->cySource = bitmap.bmHeight;
492  }
493 
494  /* Load the default settings from the registry */
495  if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &regKey) != ERROR_SUCCESS)
496  {
497  return;
498  }
499 
500  if (RegQueryValueEx(regKey, TEXT("WallpaperStyle"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
501  {
502  if (_ttoi(szBuffer) == PLACEMENT_VALUE_CENTER)
503  {
505  pData->placementSelection = PLACEMENT_CENTER;
506  }
507 
508  if (_ttoi(szBuffer) == PLACEMENT_VALUE_STRETCH)
509  {
511  pData->placementSelection = PLACEMENT_STRETCH;
512  }
513 
514  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FIT)
515  {
517  pData->placementSelection = PLACEMENT_FIT;
518  }
519 
520  if (_ttoi(szBuffer) == PLACEMENT_VALUE_FILL)
521  {
523  pData->placementSelection = PLACEMENT_FILL;
524  }
525  }
526 
527  if (RegQueryValueEx(regKey, TEXT("TileWallpaper"), 0, NULL, (LPBYTE)szBuffer, &bufferSize) == ERROR_SUCCESS)
528  {
529  if (_ttoi(szBuffer) == 1)
530  {
532  pData->placementSelection = PLACEMENT_TILE;
533  }
534  }
535 
536  RegCloseKey(regKey);
537 }
#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:5743
#define IDS_FIT
Definition: resource.h:51
#define IDS_FILL
Definition: resource.h:52
#define IDS_CENTER
Definition: resource.h:48
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#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:21
#define IDS_TILE
Definition: resource.h:50
Definition: uimain.c:88
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetObject
Definition: wingdi.h:4463
#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:25
#define IDS_STRETCH
Definition: resource.h:49
#define LoadImage
Definition: winuser.h:5716
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:5720
static VOID AddListViewItems(HWND hwndDlg, PBACKGROUND_DATA pData)
Definition: background.c:295

Referenced by BackgroundPageProc().

◆ ListViewItemChanged()

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

Definition at line 755 of file background.c.

756 {
757  BackgroundItem *backgroundItem = NULL;
758 
759  pData->backgroundSelection = itemIndex;
760  backgroundItem = &pData->backgroundItems[pData->backgroundSelection];
761 
762  if (pData->pWallpaperBitmap != NULL)
763  {
764  DibFreeImage(pData->pWallpaperBitmap);
765  pData->pWallpaperBitmap = NULL;
766  }
767 
768  if (backgroundItem->bWallpaper != FALSE)
769  {
770  pData->pWallpaperBitmap = DibLoadImage(backgroundItem->szFilename);
771 
772  if (pData->pWallpaperBitmap == NULL)
773  return;
774  }
775 
776  pData->bWallpaperChanged = TRUE;
777 
779  NULL, TRUE);
780 
782  backgroundItem->bWallpaper);
783 
784  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
785 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:22
#define TRUE
Definition: types.h:120
VOID DibFreeImage(PDIBITMAP lpBitmap)
Definition: dibitmap.c:90
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:326
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:25
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 625 of file background.c.

626 {
629  TCHAR fileTitle[256];
630  LPTSTR filter;
631  LPTSTR extensions;
632  BackgroundItem *backgroundItem = NULL;
633  SHFILEINFO sfi;
634  LV_ITEM listItem;
635  HWND hwndBackgroundList;
636  TCHAR *p;
637  HRESULT hr;
638  TCHAR filterdesc[MAX_PATH];
639  TCHAR *c;
640  size_t sizeRemain;
641  SIZE_T buffersize;
642  BOOL success;
643 
644  hwndBackgroundList = GetDlgItem(hwndDlg, IDC_BACKGROUND_LIST);
645 
646  ZeroMemory(&ofn, sizeof(OPENFILENAME));
647 
648  ofn.lStructSize = sizeof(OPENFILENAME);
649  ofn.hwndOwner = hwndDlg;
651 
652  LoadString(hApplet, IDS_BACKGROUND_COMDLG_FILTER, filterdesc, sizeof(filterdesc) / sizeof(TCHAR));
653 
654  extensions = GdipGetSupportedFileExtensions();
655  if (!extensions)
656  {
657  return;
658  }
659 
660  buffersize = (_tcslen(extensions) * 2 + 6) * sizeof(TCHAR) + sizeof(filterdesc);
661 
663  if (!filter)
664  {
665  HeapFree(GetProcessHeap(), 0, extensions);
666  return;
667  }
668 
669  sizeRemain = buffersize;
670  c = filter;
671 
672  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls (%ls)", filterdesc, extensions)))
673  {
674  HeapFree(GetProcessHeap(), 0, extensions);
676  return;
677  }
678 
679  c++;
680  sizeRemain -= sizeof(*c);
681 
682  if (FAILED(StringCbPrintfEx(c, sizeRemain, &c, &sizeRemain, 0, L"%ls", extensions)))
683  {
684  HeapFree(GetProcessHeap(), 0, extensions);
686  return;
687  }
688 
689  HeapFree(GetProcessHeap(), 0, extensions);
690 
691  /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not
692  * use the contents of szFile to initialize itself */
693  ofn.lpstrFile[0] = TEXT('\0');
696  ofn.nFilterIndex = 0;
697  ofn.lpstrFileTitle = fileTitle;
698  ofn.nMaxFileTitle = 256;
701 
704 
705  if (success)
706  {
707  /* Check if there is already a entry that holds this filename */
708  if (CheckListViewFilenameExists(hwndBackgroundList, ofn.lpstrFileTitle) != FALSE)
709  return;
710 
711  if (pData->listViewItemCount > (MAX_BACKGROUNDS - 1))
712  return;
713 
715  0,
716  &sfi,
717  sizeof(sfi),
719 
720  backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
721 
722  backgroundItem->bWallpaper = TRUE;
723 
724  hr = StringCbCopy(backgroundItem->szDisplayName, sizeof(backgroundItem->szDisplayName), sfi.szDisplayName);
725  if (FAILED(hr))
726  return;
727  p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
728  if (p)
729  *p = (TCHAR)0;
730  hr = StringCbCopy(backgroundItem->szFilename, sizeof(backgroundItem->szFilename), filename);
731  if (FAILED(hr))
732  return;
733 
734  ZeroMemory(&listItem, sizeof(LV_ITEM));
735  listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
736  listItem.state = 0;
737  listItem.pszText = backgroundItem->szDisplayName;
738  listItem.iImage = sfi.iIcon;
739  listItem.iItem = pData->listViewItemCount;
740  listItem.lParam = pData->listViewItemCount;
741 
742  (void)ListView_InsertItem(hwndBackgroundList, &listItem);
743  ListView_SetItemState(hwndBackgroundList,
744  pData->listViewItemCount,
746  LVIS_SELECTED);
747  SendMessage(hwndBackgroundList, WM_VSCROLL, SB_BOTTOM, 0);
748 
749  pData->listViewItemCount++;
750  }
751 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define LV_ITEM
Definition: commctrl.h:2309
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:169
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
HRESULT hr
Definition: shlfolder.c:183
LPSTR lpstrFileTitle
Definition: commdlg.h:338
HWND hwndOwner
Definition: commdlg.h:330
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1642
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
const char * filename
Definition: ioapi.h:135
#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:2281
static BOOL CheckListViewFilenameExists(HWND hwndList, LPCTSTR tszFileName)
Definition: background.c:607
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2645
unsigned int BOOL
Definition: ntddk_ex.h:94
#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:2291
#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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LONG HRESULT
Definition: typedefs.h:77
LPWSTR GdipGetSupportedFileExtensions(VOID)
Definition: background.c:129
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
#define LVIF_IMAGE
Definition: commctrl.h:2282
const GLubyte * c
Definition: glext.h:8905
#define IDC_BACKGROUND_LIST
Definition: resource.h:20
#define success(from, fromstr, to, tostr)
#define IDS_BACKGROUND_COMDLG_FILTER
Definition: resource.h:26
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:78
#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:123
TCHAR szFilename[MAX_PATH]
Definition: background.c:56
#define SendMessage
Definition: winuser.h:5744
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define LVIF_PARAM
Definition: commctrl.h:2283
#define SHGetFileInfo
Definition: shellapi.h:693
#define c
Definition: ke_i.h:80
DWORD nFilterIndex
Definition: commdlg.h:335
GLfloat GLfloat p
Definition: glext.h:8902
#define LVIF_STATE
Definition: commctrl.h:2284
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:394
#define LoadString
Definition: winuser.h:5720
#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 541 of file background.c.

542 {
543  /* Load custom colors from Registry */
544  HKEY hKey = NULL;
546  CHOOSECOLOR cc;
547 
548  res = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0, NULL,
550  /* Now the key is either created or opened existing, if res == ERROR_SUCCESS */
551  if (res == ERROR_SUCCESS)
552  {
553  /* Key opened */
554  DWORD dwType = REG_BINARY;
555  DWORD cbData = sizeof(pData->custom_colors);
556  res = RegQueryValueEx(hKey, TEXT("CustomColors"), NULL, &dwType,
557  (LPBYTE)pData->custom_colors, &cbData);
558  RegCloseKey(hKey);
559  hKey = NULL;
560  }
561 
562  /* Launch ChooseColor() dialog */
563 
564  cc.lStructSize = sizeof(CHOOSECOLOR);
565  cc.hwndOwner = hwndDlg;
566  cc.hInstance = NULL;
567  cc.rgbResult = g_GlobalData.desktop_color;
568  cc.lpCustColors = pData->custom_colors;
569  cc.Flags = CC_ANYCOLOR | /* Causes the dialog box to display all available colors in the set of basic colors. */
570  CC_FULLOPEN | /* opens dialog in full size */
571  CC_RGBINIT ; /* init chosen color by rgbResult value */
572  cc.lCustData = 0;
573  cc.lpfnHook = NULL;
574  cc.lpTemplateName = NULL;
575  if (ChooseColor(&cc))
576  {
577  /* Save selected color to var */
578  g_GlobalData.desktop_color = cc.rgbResult;
579  pData->bClrBackgroundChanged = TRUE;
580 
581  /* Apply button will be activated */
582  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
583 
584  /* Window will be updated :) */
586 
587  /* Save custom colors to reg. To this moment key must be created already. See above */
588  res = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance"), 0,
589  KEY_SET_VALUE, &hKey);
590  if (res == ERROR_SUCCESS)
591  {
592  /* Key opened */
593  RegSetValueEx(hKey, TEXT("CustomColors"), 0, REG_BINARY,
594  (LPBYTE)pData->custom_colors, sizeof(pData->custom_colors));
595  RegCloseKey(hKey);
596  hKey = NULL;
597  }
598  }
599 }
#define IDC_BACKGROUND_PREVIEW
Definition: resource.h:22
#define RegQueryValueEx
Definition: winreg.h:524
#define TRUE
Definition: types.h:120
#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
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:52
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:326
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 1124 of file background.c.

1125 {
1126  HKEY hKey;
1127  INT iElement = COLOR_BACKGROUND;
1128  TCHAR clText[16];
1129  BYTE red, green, blue;
1130 
1131  if (!SetSysColors(1, &iElement, &g_GlobalData.desktop_color))
1132  {
1133  /* FIXME: these error texts can need internationalization? */
1134  MessageBox(hwndDlg, TEXT("SetSysColor() failed!"),
1135  TEXT("Error!"), MB_ICONSTOP );
1136  }
1137 
1138  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, NULL,
1140  {
1141  return;
1142  }
1143 
1147 
1148  /* Format string to be set to registry */
1149  StringCbPrintf(clText, sizeof(clText), TEXT("%d %d %d"), red, green, blue);
1150  RegSetValueEx(hKey, TEXT("Background"), 0, REG_SZ, (LPBYTE)clText,
1151  (wcslen(clText) + 1) * sizeof(TCHAR));
1152 
1153  RegCloseKey(hKey);
1154 }
#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(rgb)
Definition: wingdi.h:2930
#define MB_ICONSTOP
Definition: winuser.h:797
int32_t INT
Definition: typedefs.h:56
#define GetGValue(rgb)
Definition: wingdi.h:2931
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
GLclampf GLclampf blue
Definition: gl.h:1740
#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
unsigned char BYTE
Definition: mem.h:68
#define MessageBox
Definition: winuser.h:5723
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define TEXT(s)
Definition: k32.h:26
GLOBAL_DATA g_GlobalData
Definition: background.c:84
#define GetBValue(rgb)
Definition: wingdi.h:2932
#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 1000 of file background.c.

1001 {
1002  HKEY regKey;
1003  TCHAR szWallpaper[MAX_PATH];
1004  GpImage *image;
1005  CLSID encoderClsid;
1006  GUID guidFormat;
1007  size_t length = 0;
1008  GpStatus status;
1009 
1011  {
1012  return;
1013  }
1014 
1015  if (FAILED(StringCbCat(szWallpaper, MAX_PATH, TEXT("\\Wallpaper1.bmp"))))
1016  {
1017  return;
1018  }
1019 
1020  if (RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, NULL,
1022  {
1023  return;
1024  }
1025 
1026  if (pData->placementSelection == PLACEMENT_TILE)
1027  {
1028  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("1"), sizeof(TCHAR) * 2);
1029  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1030  }
1031 
1032  if (pData->placementSelection == PLACEMENT_CENTER)
1033  {
1034  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1035  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1036  }
1037 
1038  if (pData->placementSelection == PLACEMENT_STRETCH)
1039  {
1040  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1041  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("2"), sizeof(TCHAR) * 2);
1042  }
1043 
1044  if (pData->placementSelection == PLACEMENT_FIT)
1045  {
1046  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1047  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("6"), sizeof(TCHAR) * 2);
1048  }
1049 
1050  if (pData->placementSelection == PLACEMENT_FILL)
1051  {
1052  RegSetValueEx(regKey, TEXT("TileWallpaper"), 0, REG_SZ, (LPBYTE)TEXT("0"), sizeof(TCHAR) * 2);
1053  RegSetValueEx(regKey, TEXT("WallpaperStyle"), 0, REG_SZ, (LPBYTE)TEXT("10"), sizeof(TCHAR) * 3);
1054  }
1055 
1056  if (pData->backgroundItems[pData->backgroundSelection].bWallpaper != FALSE)
1057  {
1058  GdipLoadImageFromFile(pData->backgroundItems[pData->backgroundSelection].szFilename, &image);
1059  if (!image)
1060  {
1061  RegCloseKey(regKey);
1062  return;
1063  }
1064 
1065  GdipGetImageRawFormat(image, &guidFormat);
1066  if (IsEqualGUID(&guidFormat, &ImageFormatBMP))
1067  {
1069  RegCloseKey(regKey);
1070  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pData->backgroundItems[pData->backgroundSelection].szFilename, SPIF_UPDATEINIFILE);
1071  return;
1072  }
1073 
1074  if (FAILED(GdipGetEncoderClsid(L"image/bmp", &encoderClsid)))
1075  {
1077  RegCloseKey(regKey);
1078  return;
1079  }
1080 
1081  status = GdipSaveImageToFile(image, szWallpaper, &encoderClsid, NULL);
1082 
1084 
1085  if (status != Ok)
1086  {
1087  RegCloseKey(regKey);
1088  return;
1089  }
1090 
1091  if (SUCCEEDED(StringCchLength(pData->backgroundItems[pData->backgroundSelection].szFilename, MAX_PATH, &length)))
1092  {
1093  RegSetValueEx(regKey,
1094  TEXT("ConvertedWallpaper"),
1095  0,
1096  REG_SZ,
1097  (LPBYTE)pData->backgroundItems[pData->backgroundSelection].szFilename,
1098  (DWORD)((length + 1) * sizeof(TCHAR)));
1099  }
1100 
1101  if (SUCCEEDED(StringCchLength(szWallpaper, MAX_PATH, &length)))
1102  {
1103  RegSetValueEx(regKey,
1104  TEXT("OriginalWallpaper"),
1105  0,
1106  REG_SZ,
1107  (LPBYTE)szWallpaper,
1108  (DWORD)((length + 1) * sizeof(TCHAR)));
1109  }
1110 
1112  }
1113  else
1114  {
1116  }
1117 
1118  RegCloseKey(regKey);
1119 }
#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:2001
#define SystemParametersInfo
Definition: winuser.h:5759
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:52
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:2030
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
Status
Definition: gdiplustypes.h:24
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define TEXT(s)
Definition: k32.h:26
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#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:57
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

Referenced by BackgroundPageProc().

Variable Documentation

◆ g_GlobalData