Fix the DisplayApplet function definition
[reactos.git] / reactos / dll / cpl / desk / desk.c
1 /* $Id$
2 *
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
7 *
8 * PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
9 */
10
11 #include "desk.h"
12 #include "preview.h"
13
14 #define NUM_APPLETS (1)
15
16 static LONG APIENTRY DisplayApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
17
18 extern INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
19 extern INT_PTR CALLBACK ScreenSaverPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
20 extern INT_PTR CALLBACK AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
21 extern INT_PTR CALLBACK SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
22
23 HINSTANCE hApplet = 0;
24
25 /* Applets */
26 APPLET Applets[NUM_APPLETS] =
27 {
28 {
29 IDC_DESK_ICON,
30 IDS_CPLNAME,
31 IDS_CPLDESCRIPTION,
32 DisplayApplet
33 }
34 };
35
36
37 static VOID
38 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
39 {
40 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
41 psp->dwSize = sizeof(PROPSHEETPAGE);
42 psp->dwFlags = PSP_DEFAULT;
43 psp->hInstance = hApplet;
44 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
45 psp->pfnDlgProc = DlgProc;
46 }
47
48
49 /* Display Applet */
50 static LONG APIENTRY
51 DisplayApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
52 {
53 PROPSHEETPAGE psp[4];
54 PROPSHEETHEADER psh;
55 TCHAR Caption[1024];
56
57 UNREFERENCED_PARAMETER(lParam);
58 UNREFERENCED_PARAMETER(wParam);
59 UNREFERENCED_PARAMETER(uMsg);
60 UNREFERENCED_PARAMETER(hwnd);
61
62 LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
63
64 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
65 psh.dwSize = sizeof(PROPSHEETHEADER);
66 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
67 psh.hwndParent = NULL;
68 psh.hInstance = hApplet;
69 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_DESK_ICON));
70 psh.pszCaption = Caption;
71 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
72 psh.nStartPage = 0;
73 psh.ppsp = psp;
74
75 InitPropSheetPage(&psp[0], IDD_BACKGROUND, (DLGPROC) BackgroundPageProc);
76 InitPropSheetPage(&psp[1], IDD_SCREENSAVER, (DLGPROC) ScreenSaverPageProc);
77 InitPropSheetPage(&psp[2], IDD_APPEARANCE, (DLGPROC) AppearancePageProc);
78 InitPropSheetPage(&psp[3], IDD_SETTINGS, (DLGPROC) SettingsPageProc);
79
80 return (LONG)(PropertySheet(&psh) != -1);
81 }
82
83
84 /* Control Panel Callback */
85 LONG CALLBACK
86 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
87 {
88 int i = (int)lParam1;
89
90 switch (uMsg)
91 {
92 case CPL_INIT:
93 return TRUE;
94
95 case CPL_GETCOUNT:
96 return NUM_APPLETS;
97
98 case CPL_INQUIRE:
99 {
100 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
101 CPlInfo->lData = 0;
102 CPlInfo->idIcon = Applets[i].idIcon;
103 CPlInfo->idName = Applets[i].idName;
104 CPlInfo->idInfo = Applets[i].idDescription;
105 }
106 break;
107
108 case CPL_DBLCLK:
109 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
110 break;
111 }
112
113 return FALSE;
114 }
115
116
117 BOOL WINAPI
118 DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
119 {
120 UNREFERENCED_PARAMETER(lpvReserved);
121
122 switch (dwReason)
123 {
124 case DLL_PROCESS_ATTACH:
125 RegisterPreviewControl(hInstDLL);
126 // case DLL_THREAD_ATTACH:
127 hApplet = hInstDLL;
128 break;
129
130 case DLL_PROCESS_DETACH:
131 UnregisterPreviewControl(hInstDLL);
132 break;
133 }
134
135 return TRUE;
136 }