2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2004-08-07 00:05:23 +00:00
|
|
|
*
|
2005-02-04 20:39:10 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2004-08-07 00:05:23 +00:00
|
|
|
* PROJECT: ReactOS Display Control Panel
|
|
|
|
* FILE: lib/cpl/desk/desk.c
|
|
|
|
* PURPOSE: ReactOS Display Control Panel
|
2007-10-19 23:21:45 +00:00
|
|
|
*
|
2005-02-04 20:39:10 +00:00
|
|
|
* PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
|
2004-08-07 00:05:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "desk.h"
|
2007-01-02 21:53:26 +00:00
|
|
|
#include "preview.h"
|
2004-08-07 00:05:23 +00:00
|
|
|
|
|
|
|
#define NUM_APPLETS (1)
|
|
|
|
|
2007-07-28 19:56:15 +00:00
|
|
|
static LONG APIENTRY DisplayApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
|
2004-10-13 10:17:41 +00:00
|
|
|
|
2007-09-29 02:32:14 +00:00
|
|
|
INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
INT_PTR CALLBACK ScreenSaverPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
INT_PTR CALLBACK AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
INT_PTR CALLBACK SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
UINT CALLBACK SettingsPageCallbackProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
|
2004-10-13 10:17:41 +00:00
|
|
|
|
2004-08-07 00:05:23 +00:00
|
|
|
HINSTANCE hApplet = 0;
|
2008-05-15 05:43:01 +00:00
|
|
|
HWND hCPLWindow;
|
2004-08-07 00:05:23 +00:00
|
|
|
|
|
|
|
/* Applets */
|
2007-10-19 23:21:45 +00:00
|
|
|
APPLET Applets[NUM_APPLETS] =
|
2004-08-07 00:05:23 +00:00
|
|
|
{
|
2005-02-04 20:39:10 +00:00
|
|
|
{
|
|
|
|
IDC_DESK_ICON,
|
|
|
|
IDS_CPLNAME,
|
|
|
|
IDS_CPLDESCRIPTION,
|
|
|
|
DisplayApplet
|
|
|
|
}
|
2004-08-07 00:05:23 +00:00
|
|
|
};
|
|
|
|
|
2007-10-11 20:23:26 +00:00
|
|
|
HMENU
|
|
|
|
LoadPopupMenu(IN HINSTANCE hInstance,
|
|
|
|
IN LPCTSTR lpMenuName)
|
|
|
|
{
|
|
|
|
HMENU hMenu, hSubMenu = NULL;
|
|
|
|
|
|
|
|
hMenu = LoadMenu(hInstance,
|
|
|
|
lpMenuName);
|
|
|
|
|
|
|
|
if (hMenu != NULL)
|
|
|
|
{
|
|
|
|
hSubMenu = GetSubMenu(hMenu,
|
|
|
|
0);
|
|
|
|
if (hSubMenu != NULL &&
|
|
|
|
!RemoveMenu(hMenu,
|
|
|
|
0,
|
|
|
|
MF_BYPOSITION))
|
|
|
|
{
|
|
|
|
hSubMenu = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hSubMenu;
|
|
|
|
}
|
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
static BOOL CALLBACK
|
|
|
|
PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
|
|
|
|
{
|
|
|
|
PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
|
|
|
|
if (ppsh != NULL && ppsh->nPages < MAX_DESK_PAGES)
|
|
|
|
{
|
|
|
|
ppsh->phpage[ppsh->nPages++] = hpage;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
static BOOL
|
2007-09-29 02:32:14 +00:00
|
|
|
InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc, LPFNPSPCALLBACK pfnCallback)
|
2004-08-07 00:05:23 +00:00
|
|
|
{
|
2007-09-26 06:20:16 +00:00
|
|
|
HPROPSHEETPAGE hPage;
|
|
|
|
PROPSHEETPAGE psp;
|
|
|
|
|
|
|
|
if (ppsh->nPages < MAX_DESK_PAGES)
|
|
|
|
{
|
|
|
|
ZeroMemory(&psp, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = PSP_DEFAULT;
|
2007-09-29 02:32:14 +00:00
|
|
|
if (pfnCallback != NULL)
|
|
|
|
psp.dwFlags |= PSP_USECALLBACK;
|
2007-09-26 06:20:16 +00:00
|
|
|
psp.hInstance = hApplet;
|
|
|
|
psp.pszTemplate = MAKEINTRESOURCE(idDlg);
|
|
|
|
psp.pfnDlgProc = DlgProc;
|
2007-09-29 02:32:14 +00:00
|
|
|
psp.pfnCallback = pfnCallback;
|
2007-09-26 06:20:16 +00:00
|
|
|
|
|
|
|
hPage = CreatePropertySheetPage(&psp);
|
|
|
|
if (hPage != NULL)
|
|
|
|
{
|
|
|
|
return PropSheetAddPage(hPage, (LPARAM)ppsh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2004-08-07 00:05:23 +00:00
|
|
|
}
|
2004-10-13 10:17:41 +00:00
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
WORD idDlg;
|
|
|
|
DLGPROC DlgProc;
|
2007-09-29 02:32:14 +00:00
|
|
|
LPFNPSPCALLBACK Callback;
|
2007-09-26 06:20:16 +00:00
|
|
|
} PropPages[] =
|
|
|
|
{
|
2007-09-29 02:32:14 +00:00
|
|
|
{ IDD_BACKGROUND, BackgroundPageProc, NULL },
|
|
|
|
{ IDD_SCREENSAVER, ScreenSaverPageProc, NULL },
|
|
|
|
{ IDD_APPEARANCE, AppearancePageProc, NULL },
|
|
|
|
{ IDD_SETTINGS, SettingsPageProc, SettingsPageCallbackProc },
|
2007-09-26 06:20:16 +00:00
|
|
|
};
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
/* Display Applet */
|
2007-07-28 19:56:15 +00:00
|
|
|
static LONG APIENTRY
|
|
|
|
DisplayApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
|
2004-08-07 00:05:23 +00:00
|
|
|
{
|
2007-09-26 06:20:16 +00:00
|
|
|
HPROPSHEETPAGE hpsp[MAX_DESK_PAGES];
|
2005-02-04 20:39:10 +00:00
|
|
|
PROPSHEETHEADER psh;
|
2007-09-26 06:20:16 +00:00
|
|
|
HPSXA hpsxa;
|
2005-02-04 20:39:10 +00:00
|
|
|
TCHAR Caption[1024];
|
2007-09-26 06:20:16 +00:00
|
|
|
LONG ret;
|
|
|
|
UINT i;
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2006-07-09 21:10:40 +00:00
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(uMsg);
|
|
|
|
UNREFERENCED_PARAMETER(hwnd);
|
2006-06-23 20:01:20 +00:00
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
2007-09-26 06:20:16 +00:00
|
|
|
psh.dwFlags = PSH_USECALLBACK | PSH_PROPTITLE;
|
2008-05-15 05:43:01 +00:00
|
|
|
psh.hwndParent = hCPLWindow;
|
2005-02-04 20:39:10 +00:00
|
|
|
psh.hInstance = hApplet;
|
|
|
|
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_DESK_ICON));
|
|
|
|
psh.pszCaption = Caption;
|
2007-09-26 06:20:16 +00:00
|
|
|
psh.nPages = 0;
|
2005-02-04 20:39:10 +00:00
|
|
|
psh.nStartPage = 0;
|
2007-09-26 06:20:16 +00:00
|
|
|
psh.phpage = hpsp;
|
|
|
|
|
|
|
|
/* Allow shell extensions to replace the background page */
|
|
|
|
hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Desk"), MAX_DESK_PAGES - psh.nPages);
|
|
|
|
|
|
|
|
for (i = 0; i != sizeof(PropPages) / sizeof(PropPages[0]); i++)
|
|
|
|
{
|
|
|
|
/* Override the background page if requested by a shell extension */
|
|
|
|
if (PropPages[i].idDlg == IDD_BACKGROUND && hpsxa != NULL &&
|
|
|
|
SHReplaceFromPropSheetExtArray(hpsxa, CPLPAGE_DISPLAY_BACKGROUND, PropSheetAddPage, (LPARAM)&psh) != 0)
|
|
|
|
{
|
|
|
|
/* The shell extension added one or more pages to replace the background page.
|
|
|
|
Don't create the built-in page anymore! */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-09-29 02:32:14 +00:00
|
|
|
InitPropSheetPage(&psh, PropPages[i].idDlg, PropPages[i].DlgProc, PropPages[i].Callback);
|
2007-09-26 06:20:16 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 20:45:16 +00:00
|
|
|
/* NOTE: Don't call SHAddFromPropSheetExtArray here because this applet only allows
|
2007-09-26 06:20:16 +00:00
|
|
|
replacing the background page but not extending the applet by more pages */
|
|
|
|
|
|
|
|
ret = (LONG)(PropertySheet(&psh) != -1);
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
if (hpsxa != NULL)
|
|
|
|
SHDestroyPropSheetExtArray(hpsxa);
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
return ret;
|
2004-08-07 00:05:23 +00:00
|
|
|
}
|
|
|
|
|
2004-10-13 10:17:41 +00:00
|
|
|
|
2004-08-07 00:05:23 +00:00
|
|
|
/* Control Panel Callback */
|
2006-11-26 12:47:56 +00:00
|
|
|
LONG CALLBACK
|
|
|
|
CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
|
2004-08-07 00:05:23 +00:00
|
|
|
{
|
2005-02-04 20:39:10 +00:00
|
|
|
int i = (int)lParam1;
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
switch (uMsg)
|
2005-02-04 20:39:10 +00:00
|
|
|
{
|
|
|
|
case CPL_INIT:
|
2006-11-26 12:47:56 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
case CPL_GETCOUNT:
|
2006-11-26 12:47:56 +00:00
|
|
|
return NUM_APPLETS;
|
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
case CPL_INQUIRE:
|
|
|
|
{
|
|
|
|
CPLINFO *CPlInfo = (CPLINFO*)lParam2;
|
|
|
|
CPlInfo->lData = 0;
|
|
|
|
CPlInfo->idIcon = Applets[i].idIcon;
|
|
|
|
CPlInfo->idName = Applets[i].idName;
|
|
|
|
CPlInfo->idInfo = Applets[i].idDescription;
|
2006-11-26 12:47:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
case CPL_DBLCLK:
|
2008-05-15 05:43:01 +00:00
|
|
|
hCPLWindow = hwndCPl;
|
2006-11-26 12:47:56 +00:00
|
|
|
Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
|
|
|
|
break;
|
2005-02-04 20:39:10 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
return FALSE;
|
2004-08-07 00:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
BOOL WINAPI
|
2007-01-02 21:53:26 +00:00
|
|
|
DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
|
2004-08-07 00:05:23 +00:00
|
|
|
{
|
2006-07-09 21:10:40 +00:00
|
|
|
UNREFERENCED_PARAMETER(lpvReserved);
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
switch (dwReason)
|
2005-02-04 20:39:10 +00:00
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2007-10-19 02:16:54 +00:00
|
|
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
2007-01-02 21:53:26 +00:00
|
|
|
RegisterPreviewControl(hInstDLL);
|
|
|
|
// case DLL_THREAD_ATTACH:
|
|
|
|
hApplet = hInstDLL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
UnregisterPreviewControl(hInstDLL);
|
2007-10-19 02:16:54 +00:00
|
|
|
CoUninitialize();
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2005-02-04 20:39:10 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2005-02-04 20:39:10 +00:00
|
|
|
return TRUE;
|
2004-08-07 00:05:23 +00:00
|
|
|
}
|