3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS Display Control Panel
5 * FILE: lib/cpl/desk/desk.c
6 * PURPOSE: ReactOS Display Control Panel
8 * PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
14 #define NUM_APPLETS (1)
16 static LONG APIENTRY
DisplayApplet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
18 INT_PTR CALLBACK
BackgroundPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
19 INT_PTR CALLBACK
ScreenSaverPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
20 INT_PTR CALLBACK
AppearancePageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
21 INT_PTR CALLBACK
SettingsPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
22 UINT CALLBACK
SettingsPageCallbackProc(HWND hwnd
, UINT uMsg
, LPPROPSHEETPAGE ppsp
);
24 HINSTANCE hApplet
= 0;
27 APPLET Applets
[NUM_APPLETS
] =
38 PropSheetAddPage(HPROPSHEETPAGE hpage
, LPARAM lParam
)
40 PROPSHEETHEADER
*ppsh
= (PROPSHEETHEADER
*)lParam
;
41 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_DESK_PAGES
)
43 ppsh
->phpage
[ppsh
->nPages
++] = hpage
;
51 InitPropSheetPage(PROPSHEETHEADER
*ppsh
, WORD idDlg
, DLGPROC DlgProc
, LPFNPSPCALLBACK pfnCallback
)
56 if (ppsh
->nPages
< MAX_DESK_PAGES
)
58 ZeroMemory(&psp
, sizeof(psp
));
59 psp
.dwSize
= sizeof(psp
);
60 psp
.dwFlags
= PSP_DEFAULT
;
61 if (pfnCallback
!= NULL
)
62 psp
.dwFlags
|= PSP_USECALLBACK
;
63 psp
.hInstance
= hApplet
;
64 psp
.pszTemplate
= MAKEINTRESOURCE(idDlg
);
65 psp
.pfnDlgProc
= DlgProc
;
66 psp
.pfnCallback
= pfnCallback
;
68 hPage
= CreatePropertySheetPage(&psp
);
71 return PropSheetAddPage(hPage
, (LPARAM
)ppsh
);
82 LPFNPSPCALLBACK Callback
;
85 { IDD_BACKGROUND
, BackgroundPageProc
, NULL
},
86 { IDD_SCREENSAVER
, ScreenSaverPageProc
, NULL
},
87 { IDD_APPEARANCE
, AppearancePageProc
, NULL
},
88 { IDD_SETTINGS
, SettingsPageProc
, SettingsPageCallbackProc
},
93 DisplayApplet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
95 HPROPSHEETPAGE hpsp
[MAX_DESK_PAGES
];
102 UNREFERENCED_PARAMETER(lParam
);
103 UNREFERENCED_PARAMETER(wParam
);
104 UNREFERENCED_PARAMETER(uMsg
);
105 UNREFERENCED_PARAMETER(hwnd
);
107 LoadString(hApplet
, IDS_CPLNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
109 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
110 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
111 psh
.dwFlags
= PSH_USECALLBACK
| PSH_PROPTITLE
;
112 psh
.hwndParent
= NULL
;
113 psh
.hInstance
= hApplet
;
114 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_DESK_ICON
));
115 psh
.pszCaption
= Caption
;
120 /* Allow shell extensions to replace the background page */
121 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Desk"), MAX_DESK_PAGES
- psh
.nPages
);
123 for (i
= 0; i
!= sizeof(PropPages
) / sizeof(PropPages
[0]); i
++)
125 /* Override the background page if requested by a shell extension */
126 if (PropPages
[i
].idDlg
== IDD_BACKGROUND
&& hpsxa
!= NULL
&&
127 SHReplaceFromPropSheetExtArray(hpsxa
, CPLPAGE_DISPLAY_BACKGROUND
, PropSheetAddPage
, (LPARAM
)&psh
) != 0)
129 /* The shell extension added one or more pages to replace the background page.
130 Don't create the built-in page anymore! */
134 InitPropSheetPage(&psh
, PropPages
[i
].idDlg
, PropPages
[i
].DlgProc
, PropPages
[i
].Callback
);
137 /* NOTE: Don;t call SHAddFromPropSheetExtArray here because this applet only allows
138 replacing the background page but not extending the applet by more pages */
140 ret
= (LONG
)(PropertySheet(&psh
) != -1);
143 SHDestroyPropSheetExtArray(hpsxa
);
149 /* Control Panel Callback */
151 CPlApplet(HWND hwndCPl
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
153 int i
= (int)lParam1
;
165 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
167 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
168 CPlInfo
->idName
= Applets
[i
].idName
;
169 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
174 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
183 DllMain(HINSTANCE hInstDLL
, DWORD dwReason
, LPVOID lpvReserved
)
185 UNREFERENCED_PARAMETER(lpvReserved
);
189 case DLL_PROCESS_ATTACH
:
190 RegisterPreviewControl(hInstDLL
);
191 // case DLL_THREAD_ATTACH:
195 case DLL_PROCESS_DETACH
:
196 UnregisterPreviewControl(hInstDLL
);