3 * Copyright (C) 2004 ReactOS Team
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * PROJECT: ReactOS International Control Panel
22 * FILE: dll/cpl/intl/intl.c
23 * PURPOSE: Property sheet code
24 * PROGRAMMER: Eric Kohl
29 #define NUM_APPLETS (1)
32 Applet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
35 HINSTANCE hApplet
= 0;
37 HINF hSetupInf
= INVALID_HANDLE_VALUE
;
38 DWORD IsUnattendedSetupEnabled
= 0;
39 DWORD UnattendLCID
= 0;
43 APPLET Applets
[NUM_APPLETS
] =
45 {IDC_CPLICON
, IDS_CPLNAME
, IDS_CPLDESCRIPTION
, Applet
}
50 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
)
52 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
53 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
54 psp
->dwFlags
= PSP_DEFAULT
;
55 psp
->hInstance
= hApplet
;
56 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
57 psp
->pfnDlgProc
= DlgProc
;
67 lpCmdLine
= GetCommandLine();
69 lpSwitch
= _tcsstr(lpCmdLine
, _T("/f:\""));
73 len
= _tcslen(lpSwitch
);
74 if (len
< 5 || lpSwitch
[len
-1] != _T('\"'))
76 DPRINT1("Invalid switch: %ls\n", lpSwitch
);
80 lpSwitch
[len
-1] = _T('\0');
82 hSetupInf
= SetupOpenInfFile(&lpSwitch
[4], NULL
, INF_STYLE_OLDNT
, NULL
);
83 if (hSetupInf
== INVALID_HANDLE_VALUE
)
85 DPRINT1("Failed to open INF file: %ls\n", &lpSwitch
[4]);
95 INFCONTEXT InfContext
;
98 if (!SetupFindFirstLine(hSetupInf
,
103 SetupCloseInfFile(hSetupInf
);
104 DPRINT1("SetupFindFirstLine failed\n");
108 if (!SetupGetStringField(&InfContext
, 1, szBuffer
,
109 sizeof(szBuffer
) / sizeof(TCHAR
), NULL
))
111 SetupCloseInfFile(hSetupInf
);
112 DPRINT1("SetupGetStringField failed\n");
116 UnattendLCID
= _tcstoul(szBuffer
, NULL
, 16);
117 IsUnattendedSetupEnabled
= 1;
118 SetupCloseInfFile(hSetupInf
);
122 Applet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
124 PROPSHEETPAGE psp
[3];
133 LoadString(hApplet
, IDS_CPLNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
135 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
136 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
137 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_PROPTITLE
;
138 psh
.hwndParent
= hCPLWindow
;
139 psh
.hInstance
= hApplet
;
140 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON
));
141 psh
.pszCaption
= Caption
;
142 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
146 InitPropSheetPage(&psp
[0], IDD_GENERALPAGE
, GeneralPageProc
);
147 InitPropSheetPage(&psp
[1], IDD_LANGUAGESPAGE
, LanguagesPageProc
);
148 InitPropSheetPage(&psp
[2], IDD_ADVANCEDPAGE
, AdvancedPageProc
);
150 return (LONG
)(PropertySheet(&psh
) != -1);
154 /* Control Panel Callback */
156 CPlApplet(HWND hwndCpl
,
171 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
172 UINT uAppIndex
= (UINT
)lParam1
;
175 CPlInfo
->idIcon
= Applets
[uAppIndex
].idIcon
;
176 CPlInfo
->idName
= Applets
[uAppIndex
].idName
;
177 CPlInfo
->idInfo
= Applets
[uAppIndex
].idDescription
;
183 UINT uAppIndex
= (UINT
)lParam1
;
184 hCPLWindow
= hwndCpl
;
185 Applets
[uAppIndex
].AppletProc(hwndCpl
, uMsg
, lParam1
, lParam2
);
195 DllMain(HINSTANCE hinstDLL
,
201 case DLL_PROCESS_ATTACH
:
202 case DLL_THREAD_ATTACH
: