- Start implementing of hdwwiz
[reactos.git] / reactos / dll / cpl / hdwwiz / hdwwiz.c
1 /*
2 * ReactOS New devices installation
3 * Copyright (C) 2005 ReactOS Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /*
20 * PROJECT: ReactOS Add hardware control panel
21 * FILE: dll/cpl/hdwwiz/hdwwiz.c
22 * PURPOSE: ReactOS Add hardware control panel
23 * PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org)
24 * Dmitry Chapyshev (dmitry@reactos.org)
25 */
26
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <setupapi.h>
30 #include <cpl.h>
31 #include <tchar.h>
32 #include <stdio.h>
33
34 #include "resource.h"
35 #include "hdwwiz.h"
36
37 HINSTANCE hApplet = NULL;
38
39 typedef BOOL (WINAPI *PINSTALL_NEW_DEVICE)(HWND, LPGUID, PDWORD);
40
41
42 BOOL CALLBACK
43 InstallNewDevice(HWND hwndParent, LPGUID ClassGuid, PDWORD pReboot)
44 {
45 return FALSE;
46 }
47
48 static INT_PTR CALLBACK
49 StartPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
50 {
51 return FALSE;
52 }
53
54 static INT_PTR CALLBACK
55 SearchPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
56 {
57 return FALSE;
58 }
59
60 static INT_PTR CALLBACK
61 IsConnctedPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
62 {
63 return FALSE;
64 }
65
66 static INT_PTR CALLBACK
67 FinishPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
68 {
69 return FALSE;
70 }
71
72 static VOID
73 HardwareWizardInit(HWND hwnd)
74 {
75 HPROPSHEETPAGE ahpsp[3];
76 PROPSHEETPAGE psp = {0};
77 PROPSHEETHEADER psh;
78 UINT nPages = 0;
79
80 /* Create the Start page, until setup is working */
81 psp.dwSize = sizeof(PROPSHEETPAGE);
82 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
83 psp.hInstance = hApplet;
84 psp.lParam = 0;
85 psp.pfnDlgProc = StartPageDlgProc;
86 psp.pszTemplate = MAKEINTRESOURCE(IDD_STARTPAGE);
87 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
88
89 /* Create search page */
90 psp.dwSize = sizeof(PROPSHEETPAGE);
91 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
92 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_SEARCHTITLE);
93 psp.pszHeaderSubTitle = NULL;
94 psp.hInstance = hApplet;
95 psp.lParam = 0;
96 psp.pfnDlgProc = SearchPageDlgProc;
97 psp.pszTemplate = MAKEINTRESOURCE(IDD_SEARCHPAGE);
98 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
99
100 /* Create is connected page */
101 psp.dwSize = sizeof(PROPSHEETPAGE);
102 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
103 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_ISCONNECTED);
104 psp.pszHeaderSubTitle = NULL;
105 psp.hInstance = hApplet;
106 psp.lParam = 0;
107 psp.pfnDlgProc = IsConnctedPageDlgProc;
108 psp.pszTemplate = MAKEINTRESOURCE(IDD_ISCONNECTEDPAGE);
109 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
110
111 /* Create finish page */
112 psp.dwSize = sizeof(PROPSHEETPAGE);
113 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
114 psp.hInstance = hApplet;
115 psp.lParam = 0;
116 psp.pfnDlgProc = FinishPageDlgProc;
117 psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE);
118 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
119
120 /* Create the property sheet */
121 psh.dwSize = sizeof(PROPSHEETHEADER);
122 psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
123 psh.hInstance = hApplet;
124 psh.hwndParent = NULL;
125 psh.nPages = nPages;
126 psh.nStartPage = 0;
127 psh.phpage = ahpsp;
128 psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
129 psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
130
131 /* Display the wizard */
132 PropertySheet(&psh);
133 }
134
135 VOID CALLBACK
136 AddHardwareWizard(HWND hwnd, LPTSTR lpName)
137 {
138 HardwareWizardInit(hwnd);
139 }
140
141 /* Control Panel Callback */
142 LONG CALLBACK
143 CPlApplet(HWND hwndCpl,
144 UINT uMsg,
145 LPARAM lParam1,
146 LPARAM lParam2)
147 {
148 switch (uMsg)
149 {
150 case CPL_INIT:
151 return TRUE;
152
153 case CPL_GETCOUNT:
154 return 1;
155
156 case CPL_INQUIRE:
157 {
158 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
159 CPlInfo->lData = 0;
160 CPlInfo->idIcon = IDI_CPLICON;
161 CPlInfo->idName = IDS_CPLNAME;
162 CPlInfo->idInfo = IDS_CPLDESCRIPTION;
163 }
164 break;
165
166 case CPL_DBLCLK:
167 AddHardwareWizard(hwndCpl, NULL);
168 break;
169 }
170
171 return FALSE;
172 }
173
174
175 BOOL WINAPI
176 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
177 {
178 UNREFERENCED_PARAMETER(lpvReserved);
179
180 switch (dwReason)
181 {
182 case DLL_PROCESS_ATTACH:
183 hApplet = hinstDLL;
184 break;
185 }
186
187 return TRUE;
188 }