Merge from branch ReactX to Trunk,
[reactos.git] / reactos / dll / cpl / appwiz / appwiz.c
1 /*
2 * ReactOS
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * PROJECT: ReactOS Software Control Panel
22 * FILE: dll/cpl/appwiz/appwiz.c
23 * PURPOSE: ReactOS Software Control Panel
24 * PROGRAMMERS: Gero Kuehn (reactos.filter@gkware.com)
25 * Dmitry Chapyshev (lentind@yandex.ru)
26 * UPDATE HISTORY:
27 * 06-17-2004 Created
28 * 09-25-2007 Modify
29 */
30
31 #include "appwiz.h"
32
33 #define NUM_APPLETS (1)
34
35 LONG CALLBACK SystemApplet(VOID);
36 INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
37 INT_PTR CALLBACK ComputerPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
38 HINSTANCE hApplet = 0;
39
40 /* Applets */
41
42 APPLET Applets[NUM_APPLETS] =
43 {
44 {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
45 };
46
47 static VOID
48 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
49 {
50 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
51 psp->dwSize = sizeof(PROPSHEETPAGE);
52 psp->dwFlags = PSP_DEFAULT;
53 psp->hInstance = hApplet;
54 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
55 psp->pfnDlgProc = DlgProc;
56 }
57
58
59 /* First Applet */
60 LONG CALLBACK
61 SystemApplet(VOID)
62 {
63 PROPSHEETPAGE psp[4];
64 PROPSHEETHEADER psh;
65 TCHAR Caption[1024];
66
67 LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
68
69 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
70 psh.dwSize = sizeof(PROPSHEETHEADER);
71 psh.dwFlags = PSH_PROPSHEETPAGE;
72 psh.hwndParent = NULL;
73 psh.hInstance = hApplet;
74 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
75 psh.pszCaption = Caption;
76 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
77 psh.nStartPage = 0;
78 psh.ppsp = psp;
79 psh.pfnCallback = NULL;
80
81 InitPropSheetPage(&psp[0], IDD_PROPPAGEINSTALL, (DLGPROC) RemovePageProc);
82 InitPropSheetPage(&psp[1], IDD_PROPPAGEUPDATES, (DLGPROC) UpdatesPageProc);
83 InitPropSheetPage(&psp[2], IDD_PROPPAGEADD, (DLGPROC) AddPageProc);
84 InitPropSheetPage(&psp[3], IDD_PROPPAGEROSSETUP, (DLGPROC) RosPageProc);
85
86 return (LONG)(PropertySheet(&psh) != -1);
87 }
88
89
90 /* Control Panel Callback */
91 LONG CALLBACK
92 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
93 {
94 CPLINFO *CPlInfo;
95 DWORD i;
96
97 UNREFERENCED_PARAMETER(hwndCPl);
98
99 i = (DWORD)lParam1;
100 switch (uMsg)
101 {
102 case CPL_INIT:
103 return TRUE;
104
105 case CPL_GETCOUNT:
106 return NUM_APPLETS;
107
108 case CPL_INQUIRE:
109 CPlInfo = (CPLINFO*)lParam2;
110 CPlInfo->lData = 0;
111 CPlInfo->idIcon = Applets[i].idIcon;
112 CPlInfo->idName = Applets[i].idName;
113 CPlInfo->idInfo = Applets[i].idDescription;
114 break;
115
116 case CPL_DBLCLK:
117 Applets[i].AppletProc();
118 break;
119 }
120
121 return FALSE;
122 }
123
124
125 BOOL WINAPI
126 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
127 {
128 UNREFERENCED_PARAMETER(lpvReserved);
129
130 switch (dwReason)
131 {
132 case DLL_PROCESS_ATTACH:
133 case DLL_THREAD_ATTACH:
134 CoInitialize(NULL);
135 hApplet = hinstDLL;
136 break;
137 }
138
139 return TRUE;
140 }