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.
20 * PROJECT: ReactOS International Control Panel
21 * FILE: dll/cpl/intl/intl.c
22 * PURPOSE: Property sheet code
23 * PROGRAMMER: Eric Kohl
30 #define NUM_APPLETS (1)
32 #define BUFFERSIZE 512
35 Applet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
38 HINSTANCE hApplet
= 0;
40 HINF hSetupInf
= INVALID_HANDLE_VALUE
;
41 DWORD IsUnattendedSetupEnabled
= 0;
42 DWORD UnattendLCID
= 0;
46 APPLET Applets
[NUM_APPLETS
] =
48 {IDC_CPLICON
, IDS_CPLNAME
, IDS_CPLDESCRIPTION
, Applet
}
52 PrintErrorMsgBox(UINT msg
)
54 TCHAR szErrorText
[BUFFERSIZE
];
55 TCHAR szErrorCaption
[BUFFERSIZE
];
57 LoadString(hApplet
, msg
, szErrorText
, sizeof(szErrorText
)/sizeof(TCHAR
));
58 LoadString(hApplet
, IDS_ERROR
, szErrorCaption
, sizeof(szErrorCaption
)/sizeof(TCHAR
));
60 MessageBox(NULL
, szErrorText
, szErrorCaption
, MB_OK
| MB_ICONERROR
);
64 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
)
66 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
67 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
68 psp
->dwFlags
= PSP_DEFAULT
;
69 psp
->hInstance
= hApplet
;
70 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
71 psp
->pfnDlgProc
= DlgProc
;
81 lpCmdLine
= GetCommandLine();
83 lpSwitch
= _tcsstr(lpCmdLine
, _T("/f:\""));
87 len
= _tcslen(lpSwitch
);
88 if (len
< 5 || lpSwitch
[len
-1] != _T('\"'))
90 DPRINT1("Invalid switch: %ls\n", lpSwitch
);
94 lpSwitch
[len
-1] = _T('\0');
96 hSetupInf
= SetupOpenInfFile(&lpSwitch
[4], NULL
, INF_STYLE_OLDNT
, NULL
);
97 if (hSetupInf
== INVALID_HANDLE_VALUE
)
99 DPRINT1("Failed to open INF file: %ls\n", &lpSwitch
[4]);
109 INFCONTEXT InfContext
;
112 if (!SetupFindFirstLine(hSetupInf
,
117 SetupCloseInfFile(hSetupInf
);
118 DPRINT1("SetupFindFirstLine failed\n");
122 if (!SetupGetStringField(&InfContext
, 1, szBuffer
,
123 sizeof(szBuffer
) / sizeof(TCHAR
), NULL
))
125 SetupCloseInfFile(hSetupInf
);
126 DPRINT1("SetupGetStringField failed\n");
130 UnattendLCID
= _tcstoul(szBuffer
, NULL
, 16);
131 IsUnattendedSetupEnabled
= 1;
132 SetupCloseInfFile(hSetupInf
);
136 Applet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
138 PROPSHEETPAGE psp
[3];
140 TCHAR Caption
[BUFFERSIZE
];
147 LoadString(hApplet
, IDS_CPLNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
149 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
150 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
151 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_PROPTITLE
;
152 psh
.hwndParent
= hCPLWindow
;
153 psh
.hInstance
= hApplet
;
154 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON
));
155 psh
.pszCaption
= Caption
;
156 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
160 InitPropSheetPage(&psp
[0], IDD_GENERALPAGE
, GeneralPageProc
);
161 InitPropSheetPage(&psp
[1], IDD_LANGUAGESPAGE
, LanguagesPageProc
);
162 InitPropSheetPage(&psp
[2], IDD_ADVANCEDPAGE
, AdvancedPageProc
);
164 return (LONG
)(PropertySheet(&psh
) != -1);
168 /* Control Panel Callback */
170 CPlApplet(HWND hwndCpl
,
185 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
186 UINT uAppIndex
= (UINT
)lParam1
;
189 CPlInfo
->idIcon
= Applets
[uAppIndex
].idIcon
;
190 CPlInfo
->idName
= Applets
[uAppIndex
].idName
;
191 CPlInfo
->idInfo
= Applets
[uAppIndex
].idDescription
;
197 UINT uAppIndex
= (UINT
)lParam1
;
198 hCPLWindow
= hwndCpl
;
199 Applets
[uAppIndex
].AppletProc(hwndCpl
, uMsg
, lParam1
, lParam2
);
209 DllMain(HINSTANCE hinstDLL
,
215 case DLL_PROCESS_ATTACH
:
216 case DLL_THREAD_ATTACH
: