8cfd7e575fa2c1113119d0d9377895aff5fa7c5f
[reactos.git] / reactos / lib / syssetup / wizard.c
1 /*
2 * ReactOS kernel
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: wizard.c,v 1.11 2004/11/05 11:48:45 ekohl Exp $
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS system libraries
23 * PURPOSE: System setup
24 * FILE: lib/syssetup/wizard.c
25 * PROGRAMER: Eric Kohl
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <windows.h>
31 #include <commctrl.h>
32
33 #include <string.h>
34 #include <tchar.h>
35 #include <setupapi.h>
36
37 #include <syssetup.h>
38
39
40 #include "globals.h"
41 #include "resource.h"
42
43
44 /* GLOBALS ******************************************************************/
45
46 static SETUPDATA SetupData;
47
48
49 /* FUNCTIONS ****************************************************************/
50
51 static VOID
52 CenterWindow(HWND hWnd)
53 {
54 HWND hWndParent;
55 RECT rcParent;
56 RECT rcWindow;
57
58 hWndParent = GetParent(hWnd);
59 if (hWndParent == NULL)
60 hWndParent = GetDesktopWindow();
61
62 GetWindowRect(hWndParent, &rcParent);
63 GetWindowRect(hWnd, &rcWindow);
64
65 SetWindowPos(hWnd,
66 HWND_TOP,
67 ((rcParent.right - rcParent.left) - (rcWindow.right - rcWindow.left)) / 2,
68 ((rcParent.bottom - rcParent.top) - (rcWindow.bottom - rcWindow.top)) / 2,
69 0,
70 0,
71 SWP_NOSIZE);
72 }
73
74
75 static HFONT
76 CreateTitleFont(VOID)
77 {
78 NONCLIENTMETRICS ncm;
79 LOGFONT LogFont;
80 HDC hdc;
81 INT FontSize;
82 HFONT hFont;
83
84 ncm.cbSize = sizeof(NONCLIENTMETRICS);
85 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
86
87 LogFont = ncm.lfMessageFont;
88 LogFont.lfWeight = FW_BOLD;
89 _tcscpy(LogFont.lfFaceName, TEXT("MS Shell Dlg"));
90
91 hdc = GetDC(NULL);
92 FontSize = 12;
93 LogFont.lfHeight = 0 - GetDeviceCaps (hdc, LOGPIXELSY) * FontSize / 72;
94 hFont = CreateFontIndirect(&LogFont);
95 ReleaseDC(NULL, hdc);
96
97 return hFont;
98 }
99
100
101 INT_PTR CALLBACK
102 WelcomeDlgProc(HWND hwndDlg,
103 UINT uMsg,
104 WPARAM wParam,
105 LPARAM lParam)
106 {
107 switch (uMsg)
108 {
109 case WM_INITDIALOG:
110 {
111 PSETUPDATA SetupData;
112 HWND hwndControl;
113 DWORD dwStyle;
114
115 /* Get pointer to the global setup data */
116 SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
117
118 hwndControl = GetParent(hwndDlg);
119
120 /* Center the wizard window */
121 CenterWindow (hwndControl);
122
123 /* Hide the system menu */
124 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
125 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
126
127 /* Hide and disable the 'Cancel' button */
128 hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL);
129 ShowWindow (hwndControl, SW_HIDE);
130 EnableWindow (hwndControl, FALSE);
131
132 /* Set title font */
133 SendDlgItemMessage(hwndDlg,
134 IDC_WELCOMETITLE,
135 WM_SETFONT,
136 (WPARAM)SetupData->hTitleFont,
137 (LPARAM)TRUE);
138 }
139 break;
140
141
142 case WM_NOTIFY:
143 {
144 LPNMHDR lpnm = (LPNMHDR)lParam;
145
146 switch (lpnm->code)
147 {
148 case PSN_SETACTIVE:
149 /* Enable the Next button */
150 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
151 break;
152
153 default:
154 break;
155 }
156 }
157 break;
158
159 default:
160 break;
161 }
162
163 return FALSE;
164 }
165
166
167 INT_PTR CALLBACK
168 OwnerPageDlgProc(HWND hwndDlg,
169 UINT uMsg,
170 WPARAM wParam,
171 LPARAM lParam)
172 {
173 TCHAR OwnerName[51];
174 TCHAR OwnerOrganization[51];
175 HKEY hKey;
176 LPNMHDR lpnm;
177
178 switch (uMsg)
179 {
180 case WM_INITDIALOG:
181 {
182 SendDlgItemMessage(hwndDlg, IDC_OWNERNAME, EM_LIMITTEXT, 50, 0);
183 SendDlgItemMessage(hwndDlg, IDC_OWNERORGANIZATION, EM_LIMITTEXT, 50, 0);
184
185 /* Set focus to owner name */
186 SetFocus(GetDlgItem(hwndDlg, IDC_OWNERNAME));
187 }
188 break;
189
190
191 case WM_NOTIFY:
192 {
193 lpnm = (LPNMHDR)lParam;
194
195 switch (lpnm->code)
196 {
197 case PSN_SETACTIVE:
198 /* Enable the Back and Next buttons */
199 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
200 break;
201
202 case PSN_WIZNEXT:
203 OwnerName[0] = 0;
204 if (GetDlgItemText(hwndDlg, IDC_OWNERNAME, OwnerName, 50) == 0)
205 {
206 MessageBox(hwndDlg,
207 _T("Setup cannot continue until you enter your name."),
208 _T("ReactOS Setup"),
209 MB_ICONERROR | MB_OK);
210 SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
211 return TRUE;
212 }
213
214 OwnerOrganization[0] = 0;
215 GetDlgItemText(hwndDlg, IDC_OWNERORGANIZATION, OwnerOrganization, 50);
216
217 RegOpenKeyEx(HKEY_LOCAL_MACHINE,
218 _T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
219 0,
220 KEY_ALL_ACCESS,
221 &hKey);
222 /* FIXME: check error code */
223
224 RegSetValueEx(hKey,
225 _T("RegisteredOwner"),
226 0,
227 REG_SZ,
228 OwnerName,
229 (_tcslen(OwnerName) + 1) * sizeof(TCHAR));
230 /* FIXME: check error code */
231
232 RegSetValueEx(hKey,
233 _T("RegisteredOrganization"),
234 0,
235 REG_SZ,
236 OwnerOrganization,
237 (_tcslen(OwnerOrganization) + 1) * sizeof(TCHAR));
238 /* FIXME: check error code */
239
240 RegCloseKey(hKey);
241 break;
242
243 default:
244 break;
245 }
246 }
247 break;
248
249 default:
250 break;
251 }
252
253 return FALSE;
254 }
255
256
257 INT_PTR CALLBACK
258 ComputerPageDlgProc(HWND hwndDlg,
259 UINT uMsg,
260 WPARAM wParam,
261 LPARAM lParam)
262 {
263 TCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
264 TCHAR Password1[15];
265 TCHAR Password2[15];
266 DWORD Length;
267 LPNMHDR lpnm;
268
269 switch (uMsg)
270 {
271 case WM_INITDIALOG:
272 {
273 /* Retrieve current computer name */
274 Length = MAX_COMPUTERNAME_LENGTH + 1;
275 GetComputerName(ComputerName, &Length);
276
277 /* Display current computer name */
278 SetDlgItemText(hwndDlg, IDC_COMPUTERNAME, ComputerName);
279
280 /* Set text limits */
281 SendDlgItemMessage(hwndDlg, IDC_COMPUTERNAME, EM_LIMITTEXT, 64, 0);
282 SendDlgItemMessage(hwndDlg, IDC_ADMINPASSWORD1, EM_LIMITTEXT, 14, 0);
283 SendDlgItemMessage(hwndDlg, IDC_ADMINPASSWORD2, EM_LIMITTEXT, 14, 0);
284
285 /* Set focus to computer name */
286 SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
287 }
288 break;
289
290
291 case WM_NOTIFY:
292 {
293 lpnm = (LPNMHDR)lParam;
294
295 switch (lpnm->code)
296 {
297 case PSN_SETACTIVE:
298 /* Enable the Back and Next buttons */
299 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
300 break;
301
302 case PSN_WIZNEXT:
303 if (GetDlgItemText(hwndDlg, IDC_COMPUTERNAME, ComputerName, 64) == 0)
304 {
305 MessageBox(hwndDlg,
306 _T("Setup cannot continue until you enter the name of your computer."),
307 _T("ReactOS Setup"),
308 MB_ICONERROR | MB_OK);
309 SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
310 return TRUE;
311 }
312
313 /* FIXME: check computer name for invalid characters */
314
315 if (!SetComputerName(ComputerName))
316 {
317 MessageBox(hwndDlg,
318 _T("Setup failed to set the computer name."),
319 _T("ReactOS Setup"),
320 MB_ICONERROR | MB_OK);
321 SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
322 return TRUE;
323 }
324
325 /* Check admin passwords */
326 GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD1, Password1, 15);
327 GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD2, Password2, 15);
328 if (_tcscmp(Password1, Password2))
329 {
330 MessageBox(hwndDlg,
331 _T("The passwords you entered do not match. Please enter "\
332 "the desired password again."),
333 _T("ReactOS Setup"),
334 MB_ICONERROR | MB_OK);
335 SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
336 return TRUE;
337 }
338
339 /* FIXME: check password for invalid characters */
340
341 /* FIXME: Set admin password */
342 break;
343
344 default:
345 break;
346 }
347 }
348 break;
349
350 default:
351 break;
352 }
353
354 return FALSE;
355 }
356
357
358 static VOID
359 SetKeyboardLayoutName(HWND hwnd)
360 {
361 #if 0
362 WCHAR szLayoutPath[256];
363 WCHAR szLocaleName[32];
364 DWORD dwLocaleSize;
365 HKEY hKey;
366
367 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
368 L"SYSTEM\\CurrentControlSet\\Control\\NLS\\Locale",
369 0,
370 KEY_ALL_ACCESS,
371 &hKey))
372 return;
373
374 dwValueSize = 16 * sizeof(WCHAR);
375 if (RegQueryValueExW(hKey,
376 NULL,
377 NULL,
378 NULL,
379 szLocaleName,
380 &dwLocaleSize))
381 {
382 RegCloseKey(hKey);
383 return;
384 }
385
386 wcscpy(szLayoutPath,
387 L"SYSTEM\\CurrentControlSet\\Control\\KeyboardLayouts\\"
388 wcscat(szLayoutPath,
389 szLocaleName);
390
391 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
392 szLayoutPath,
393 0,
394 KEY_ALL_ACCESS,
395 &hKey))
396 return;
397
398 dwValueSize = 32 * sizeof(WCHAR);
399 if (RegQueryValueExW(hKey,
400 L"Layout Text",
401 NULL,
402 NULL,
403 szLocaleName,
404 &dwLocaleSize))
405 {
406 RegCloseKey(hKey);
407 return;
408 }
409
410 RegCloseKey(hKey);
411 #endif
412 }
413
414 static VOID
415 RunLocalePage(VOID)
416 {
417 PROPSHEETPAGE psp;
418 PROPSHEETHEADER psh;
419 HMODULE hDll;
420 // TCHAR Caption[256];
421
422 hDll = LoadLibraryW(L"intl.cpl");
423
424 ZeroMemory(&psp, sizeof(PROPSHEETPAGE));
425 psp.dwSize = sizeof(PROPSHEETPAGE);
426 psp.dwFlags = PSP_DEFAULT;
427 psp.hInstance = hDll;
428 psp.pszTemplate = MAKEINTRESOURCE(IDD_LOCALEPAGE);
429 psp.pfnDlgProc = GetProcAddress(hDll, "LocalePageProc");
430
431
432 // LoadString(hDll, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
433
434 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
435 psh.dwSize = sizeof(PROPSHEETHEADER);
436 psh.dwFlags = PSH_PROPSHEETPAGE; // | PSH_PROPTITLE;
437 psh.hwndParent = NULL;
438 psh.hInstance = hDll;
439 // psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
440 // psh.pszCaption = Caption;
441 psh.nPages = 1;
442 psh.nStartPage = 0;
443 psh.ppsp = &psp;
444
445 PropertySheet(&psh);
446
447 FreeLibrary(hDll);
448 }
449
450
451 INT_PTR CALLBACK
452 LocalePageDlgProc(HWND hwndDlg,
453 UINT uMsg,
454 WPARAM wParam,
455 LPARAM lParam)
456 {
457 PSETUPDATA SetupData;
458
459 /* Retrieve pointer to the global setup data */
460 SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
461
462 switch (uMsg)
463 {
464 case WM_INITDIALOG:
465 {
466 /* Save pointer to the global setup data */
467 SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
468 SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
469
470
471 SetKeyboardLayoutName(GetDlgItem(hwndDlg, IDC_LAYOUTTEXT));
472
473 }
474 break;
475
476 case WM_COMMAND:
477 if (HIWORD(wParam) == BN_CLICKED)
478 {
479 switch (LOWORD(wParam))
480 {
481 case IDC_CUSTOMLOCALE:
482 {
483 RunLocalePage();
484 }
485 break;
486 }
487 }
488 break;
489
490 case WM_NOTIFY:
491 {
492 LPNMHDR lpnm = (LPNMHDR)lParam;
493
494 switch (lpnm->code)
495 {
496 case PSN_SETACTIVE:
497 /* Enable the Back and Next buttons */
498 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
499 break;
500
501 case PSN_WIZNEXT:
502 break;
503
504 default:
505 break;
506 }
507 }
508 break;
509
510 default:
511 break;
512 }
513
514 return FALSE;
515 }
516
517
518 static PTIMEZONE_ENTRY
519 GetLargerTimeZoneEntry(PSETUPDATA SetupData, DWORD Index)
520 {
521 PTIMEZONE_ENTRY Entry;
522
523 Entry = SetupData->TimeZoneListHead;
524 while (Entry != NULL)
525 {
526 if (Entry->Index >= Index)
527 return Entry;
528
529 Entry = Entry->Next;
530 }
531
532 return NULL;
533 }
534
535
536 static VOID
537 CreateTimeZoneList(PSETUPDATA SetupData)
538 {
539 WCHAR szKeyName[256];
540 // WCHAR szValue[256];
541 DWORD dwIndex;
542 DWORD dwNameSize;
543 DWORD dwValueSize;
544 LONG lError;
545 HKEY hZonesKey;
546 HKEY hZoneKey;
547
548 PTIMEZONE_ENTRY Entry;
549 PTIMEZONE_ENTRY Current;
550
551 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
552 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
553 0,
554 KEY_ALL_ACCESS,
555 &hZonesKey))
556 return;
557
558 dwIndex = 0;
559 while (TRUE)
560 {
561 dwNameSize = 256;
562 lError = RegEnumKeyExW(hZonesKey,
563 dwIndex,
564 szKeyName,
565 &dwNameSize,
566 NULL,
567 NULL,
568 NULL,
569 NULL);
570 if (lError != ERROR_SUCCESS && lError != ERROR_MORE_DATA)
571 break;
572
573 if (RegOpenKeyExW(hZonesKey,
574 szKeyName,
575 0,
576 KEY_ALL_ACCESS,
577 &hZoneKey))
578 break;
579
580 Entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TIMEZONE_ENTRY));
581 if (Entry == NULL)
582 {
583 RegCloseKey(hZoneKey);
584 break;
585 }
586
587 dwValueSize = 64 * sizeof(WCHAR);
588 if (RegQueryValueExW(hZoneKey,
589 L"Display",
590 NULL,
591 NULL,
592 (LPBYTE)&Entry->Description,
593 &dwValueSize))
594 {
595 RegCloseKey(hZoneKey);
596 break;
597 }
598
599 dwValueSize = 32 * sizeof(WCHAR);
600 if (RegQueryValueExW(hZoneKey,
601 L"Std",
602 NULL,
603 NULL,
604 (LPBYTE)&Entry->StandardName,
605 &dwValueSize))
606 {
607 RegCloseKey(hZoneKey);
608 break;
609 }
610
611 dwValueSize = 32 * sizeof(WCHAR);
612 if (RegQueryValueExW(hZoneKey,
613 L"Dlt",
614 NULL,
615 NULL,
616 (LPBYTE)&Entry->DaylightName,
617 &dwValueSize))
618 {
619 RegCloseKey(hZoneKey);
620 break;
621 }
622
623 dwValueSize = sizeof(DWORD);
624 if (RegQueryValueExW(hZoneKey,
625 L"Index",
626 NULL,
627 NULL,
628 (LPBYTE)&Entry->Index,
629 &dwValueSize))
630 {
631 RegCloseKey(hZoneKey);
632 break;
633 }
634
635 dwValueSize = sizeof(TZ_INFO);
636 if (RegQueryValueExW(hZoneKey,
637 L"TZI",
638 NULL,
639 NULL,
640 (LPBYTE)&Entry->TimezoneInfo,
641 &dwValueSize))
642 {
643 RegCloseKey(hZoneKey);
644 break;
645 }
646
647 RegCloseKey(hZoneKey);
648
649 if (SetupData->TimeZoneListHead == NULL &&
650 SetupData->TimeZoneListTail == NULL)
651 {
652 Entry->Prev = NULL;
653 Entry->Next = NULL;
654 SetupData->TimeZoneListHead = Entry;
655 SetupData->TimeZoneListTail = Entry;
656 }
657 else
658 {
659 Current = GetLargerTimeZoneEntry(SetupData, Entry->Index);
660 if (Current != NULL)
661 {
662 if (Current == SetupData->TimeZoneListHead)
663 {
664 /* Prepend to head */
665 Entry->Prev = NULL;
666 Entry->Next = SetupData->TimeZoneListHead;
667 SetupData->TimeZoneListHead->Prev = Entry;
668 SetupData->TimeZoneListHead = Entry;
669 }
670 else
671 {
672 /* Insert before current */
673 Entry->Prev = Current->Prev;
674 Entry->Next = Current;
675 Current->Prev->Next = Entry;
676 Current->Prev = Entry;
677 }
678 }
679 else
680 {
681 /* Append to tail */
682 Entry->Prev = SetupData->TimeZoneListTail;
683 Entry->Next = NULL;
684 SetupData->TimeZoneListTail->Next = Entry;
685 SetupData->TimeZoneListTail = Entry;
686 }
687 }
688
689 dwIndex++;
690 }
691
692 RegCloseKey(hZonesKey);
693 }
694
695
696 #if 0
697 static VOID
698 DestroyTimeZoneList(PSETUPDATA SetupData)
699 {
700
701 }
702 #endif
703
704
705 static VOID
706 ShowTimeZoneList(HWND hwnd, PSETUPDATA SetupData)
707 {
708 PTIMEZONE_ENTRY Entry;
709
710 Entry = SetupData->TimeZoneListHead;
711 while (Entry != NULL)
712 {
713 SendMessageW(hwnd,
714 CB_ADDSTRING,
715 0,
716 (LPARAM)Entry->Description);
717
718
719 Entry = Entry->Next;
720 }
721
722 SendMessageW(hwnd,
723 CB_SETCURSEL,
724 (WPARAM)0, // index
725 0);
726 }
727
728
729 static VOID
730 SetLocalTimeZone(HWND hwnd, PSETUPDATA SetupData)
731 {
732 TIME_ZONE_INFORMATION TimeZoneInformation;
733 PTIMEZONE_ENTRY Entry;
734 DWORD dwIndex;
735 DWORD i;
736
737 dwIndex = SendMessage(hwnd,
738 CB_GETCURSEL,
739 0,
740 0);
741
742 i = 0;
743 Entry = SetupData->TimeZoneListHead;
744 while (i < dwIndex)
745 {
746 if (Entry == NULL)
747 return;
748
749 i++;
750 Entry = Entry->Next;
751 }
752
753 wcscpy(TimeZoneInformation.StandardName,
754 Entry->StandardName);
755 wcscpy(TimeZoneInformation.DaylightName,
756 Entry->DaylightName);
757
758 TimeZoneInformation.Bias = Entry->TimezoneInfo.Bias;
759 TimeZoneInformation.StandardBias = Entry->TimezoneInfo.StandardBias;
760 TimeZoneInformation.DaylightBias = Entry->TimezoneInfo.DaylightBias;
761
762 memcpy(&TimeZoneInformation.StandardDate,
763 &Entry->TimezoneInfo.StandardDate,
764 sizeof(SYSTEMTIME));
765 memcpy(&TimeZoneInformation.DaylightDate,
766 &Entry->TimezoneInfo.DaylightDate,
767 sizeof(SYSTEMTIME));
768
769 /* Set time zone information */
770 SetTimeZoneInformation(&TimeZoneInformation);
771 }
772
773
774 static BOOL
775 GetLocalSystemTime(HWND hwnd, PSETUPDATA SetupData)
776 {
777 SYSTEMTIME Date;
778 SYSTEMTIME Time;
779
780 if (DateTime_GetSystemTime(GetDlgItem(hwnd, IDC_DATEPICKER), &Date) != GDT_VALID)
781 {
782 return FALSE;
783 }
784
785 if (DateTime_GetSystemTime(GetDlgItem(hwnd, IDC_TIMEPICKER), &Time) != GDT_VALID)
786 {
787 return FALSE;
788 }
789
790 SetupData->SystemTime.wYear = Date.wYear;
791 SetupData->SystemTime.wMonth = Date.wMonth;
792 SetupData->SystemTime.wDayOfWeek = Date.wDayOfWeek;
793 SetupData->SystemTime.wDay = Date.wDay;
794 SetupData->SystemTime.wHour = Time.wHour;
795 SetupData->SystemTime.wMinute = Time.wMinute;
796 SetupData->SystemTime.wSecond = Time.wSecond;
797 SetupData->SystemTime.wMilliseconds = Time.wMilliseconds;
798
799 return TRUE;
800 }
801
802
803 INT_PTR CALLBACK
804 DateTimePageDlgProc(HWND hwndDlg,
805 UINT uMsg,
806 WPARAM wParam,
807 LPARAM lParam)
808 {
809 PSETUPDATA SetupData;
810
811 /* Retrieve pointer to the global setup data */
812 SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
813
814 switch (uMsg)
815 {
816 case WM_INITDIALOG:
817 {
818 /* Save pointer to the global setup data */
819 SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
820 SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
821
822 CreateTimeZoneList(SetupData);
823
824 ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
825 SetupData);
826 }
827 break;
828
829
830 case WM_NOTIFY:
831 {
832 LPNMHDR lpnm = (LPNMHDR)lParam;
833
834 switch (lpnm->code)
835 {
836 case PSN_SETACTIVE:
837 /* Enable the Back and Next buttons */
838 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
839 break;
840
841 case PSN_WIZNEXT:
842 {
843 GetLocalSystemTime(hwndDlg, SetupData);
844 SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
845 SetupData);
846 SetLocalTime(&SetupData->SystemTime);
847 }
848 break;
849
850 default:
851 break;
852 }
853 }
854 break;
855
856 default:
857 break;
858 }
859
860 return FALSE;
861 }
862
863
864 INT_PTR CALLBACK
865 ProcessPageDlgProc(HWND hwndDlg,
866 UINT uMsg,
867 WPARAM wParam,
868 LPARAM lParam)
869 {
870 PSETUPDATA SetupData;
871
872 /* Retrieve pointer to the global setup data */
873 SetupData = (PSETUPDATA)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
874
875 switch (uMsg)
876 {
877 case WM_INITDIALOG:
878 {
879 /* Save pointer to the global setup data */
880 SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
881 SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
882 }
883 break;
884
885 case WM_TIMER:
886 {
887 INT Position;
888 HWND hWndProgress;
889
890 hWndProgress = GetDlgItem(hwndDlg, IDC_PROCESSPROGRESS);
891 Position = SendMessage(hWndProgress, PBM_GETPOS, 0, 0);
892 if (Position == 300)
893 {
894 PropSheet_PressButton(GetParent(hwndDlg), PSBTN_NEXT);
895 }
896 else
897 {
898 SendMessage(hWndProgress, PBM_SETPOS, Position + 1, 0);
899 }
900 }
901 return TRUE;
902
903 case WM_NOTIFY:
904 {
905 LPNMHDR lpnm = (LPNMHDR)lParam;
906
907 switch (lpnm->code)
908 {
909 case PSN_SETACTIVE:
910 /* Disable the Back and Next buttons */
911 PropSheet_SetWizButtons(GetParent(hwndDlg), 0);
912
913 SendDlgItemMessage(hwndDlg, IDC_PROCESSPROGRESS, PBM_SETRANGE, 0,
914 MAKELPARAM(0, 300));
915 SetTimer(hwndDlg, 0, 50, NULL);
916 break;
917
918 case PSN_WIZNEXT:
919
920 /* Enable the Back and Next buttons */
921 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
922 break;
923
924 default:
925 break;
926 }
927 }
928 break;
929
930 default:
931 break;
932 }
933
934 return FALSE;
935 }
936
937
938
939 INT_PTR CALLBACK
940 FinishDlgProc(HWND hwndDlg,
941 UINT uMsg,
942 WPARAM wParam,
943 LPARAM lParam)
944 {
945
946 switch (uMsg)
947 {
948 case WM_INITDIALOG:
949 {
950 PSETUPDATA SetupData;
951
952 /* Get pointer to the global setup data */
953 SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
954
955 /* Set title font */
956 SendDlgItemMessage(hwndDlg,
957 IDC_FINISHTITLE,
958 WM_SETFONT,
959 (WPARAM)SetupData->hTitleFont,
960 (LPARAM)TRUE);
961 }
962 break;
963
964 case WM_NOTIFY:
965 {
966 LPNMHDR lpnm = (LPNMHDR)lParam;
967
968 switch (lpnm->code)
969 {
970 case PSN_SETACTIVE:
971 /* Enable the correct buttons on for the active page */
972 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH);
973 break;
974
975 case PSN_WIZBACK:
976 /* Handle a Back button click, if necessary */
977 break;
978
979 case PSN_WIZFINISH:
980 /* Handle a Finish button click, if necessary */
981 break;
982
983 default:
984 break;
985 }
986 }
987 break;
988
989 default:
990 break;
991 }
992
993 return FALSE;
994 }
995
996
997 VOID
998 InstallWizard(VOID)
999 {
1000 PROPSHEETHEADER psh;
1001 HPROPSHEETPAGE ahpsp[6];
1002 PROPSHEETPAGE psp;
1003
1004 /* Clear setup data */
1005 ZeroMemory(&SetupData, sizeof(SETUPDATA));
1006
1007 /* Create the Welcome page */
1008 ZeroMemory (&psp, sizeof(PROPSHEETPAGE));
1009 psp.dwSize = sizeof(PROPSHEETPAGE);
1010 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
1011 psp.hInstance = hDllInstance;
1012 psp.lParam = (LPARAM)&SetupData;
1013 psp.pfnDlgProc = WelcomeDlgProc;
1014 psp.pszTemplate = MAKEINTRESOURCE(IDD_WELCOMEPAGE);
1015 ahpsp[0] = CreatePropertySheetPage(&psp);
1016
1017 /* Create the Owner page */
1018 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
1019 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_OWNERTITLE);
1020 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_OWNERSUBTITLE);
1021 psp.pszTemplate = MAKEINTRESOURCE(IDD_OWNERPAGE);
1022 psp.pfnDlgProc = OwnerPageDlgProc;
1023 ahpsp[1] = CreatePropertySheetPage(&psp);
1024
1025 /* Create the Computer page */
1026 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
1027 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_COMPUTERTITLE);
1028 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE);
1029 psp.pfnDlgProc = ComputerPageDlgProc;
1030 psp.pszTemplate = MAKEINTRESOURCE(IDD_COMPUTERPAGE);
1031 ahpsp[2] = CreatePropertySheetPage(&psp);
1032
1033
1034 /* Create the Locale page */
1035 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
1036 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_LOCALETITLE);
1037 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_LOCALESUBTITLE);
1038 psp.pfnDlgProc = LocalePageDlgProc;
1039 psp.pszTemplate = MAKEINTRESOURCE(IDD_LOCALEPAGE);
1040 ahpsp[3] = CreatePropertySheetPage(&psp);
1041
1042
1043 /* Create the DateTime page */
1044 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
1045 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_DATETIMETITLE);
1046 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DATETIMESUBTITLE);
1047 psp.pfnDlgProc = DateTimePageDlgProc;
1048 psp.pszTemplate = MAKEINTRESOURCE(IDD_DATETIMEPAGE);
1049 ahpsp[4] = CreatePropertySheetPage(&psp);
1050
1051
1052 /* Create the Process page */
1053 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
1054 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_PROCESSTITLE);
1055 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_PROCESSSUBTITLE);
1056 psp.pfnDlgProc = ProcessPageDlgProc;
1057 psp.pszTemplate = MAKEINTRESOURCE(IDD_PROCESSPAGE);
1058 ahpsp[5] = CreatePropertySheetPage(&psp);
1059
1060
1061 /* Create the Finish page */
1062 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
1063 psp.pfnDlgProc = FinishDlgProc;
1064 psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE);
1065 ahpsp[6] = CreatePropertySheetPage(&psp);
1066
1067 /* Create the property sheet */
1068 psh.dwSize = sizeof(PROPSHEETHEADER);
1069 psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
1070 psh.hInstance = hDllInstance;
1071 psh.hwndParent = NULL;
1072 psh.nPages = 7;
1073 psh.nStartPage = 0;
1074 psh.phpage = ahpsp;
1075 psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
1076 psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
1077
1078 /* Create title font */
1079 SetupData.hTitleFont = CreateTitleFont();
1080
1081 /* Display the wizard */
1082 PropertySheet(&psh);
1083
1084 DeleteObject(SetupData.hTitleFont);
1085 }
1086
1087 /* EOF */