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