2004-10-30 12:33:51 +00:00
|
|
|
/*
|
|
|
|
* ReactOS
|
|
|
|
* Copyright (C) 2004 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-10-30 12:33:51 +00:00
|
|
|
*/
|
2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2004-10-30 12:33:51 +00:00
|
|
|
*
|
|
|
|
* PROJECT: ReactOS International Control Panel
|
2011-11-29 14:55:58 +00:00
|
|
|
* FILE: dll/cpl/intl/intl.c
|
2004-10-30 12:33:51 +00:00
|
|
|
* PURPOSE: Property sheet code
|
|
|
|
* PROGRAMMER: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "intl.h"
|
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
#define NUM_APPLETS (1)
|
2004-10-30 12:33:51 +00:00
|
|
|
|
2007-07-28 20:02:37 +00:00
|
|
|
static LONG APIENTRY
|
|
|
|
Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
|
2004-10-30 12:33:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
HINSTANCE hApplet = 0;
|
2008-05-15 05:43:01 +00:00
|
|
|
HWND hCPLWindow;
|
2006-08-12 19:32:57 +00:00
|
|
|
HINF hSetupInf = INVALID_HANDLE_VALUE;
|
2007-08-29 20:13:27 +00:00
|
|
|
DWORD IsUnattendedSetupEnabled = 0;
|
|
|
|
DWORD UnattendLCID = 0;
|
|
|
|
|
2004-10-30 12:33:51 +00:00
|
|
|
|
|
|
|
/* Applets */
|
2007-10-19 23:21:45 +00:00
|
|
|
APPLET Applets[NUM_APPLETS] =
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
{IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
|
2004-10-30 12:33:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-09-08 22:27:41 +00:00
|
|
|
static VOID
|
2004-10-30 12:33:51 +00:00
|
|
|
InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
|
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
|
|
|
|
psp->dwSize = sizeof(PROPSHEETPAGE);
|
|
|
|
psp->dwFlags = PSP_DEFAULT;
|
|
|
|
psp->hInstance = hApplet;
|
|
|
|
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
|
|
|
|
psp->pfnDlgProc = DlgProc;
|
2004-10-30 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
2006-08-12 19:32:57 +00:00
|
|
|
BOOL
|
2007-09-05 14:24:45 +00:00
|
|
|
OpenSetupInf(VOID)
|
2006-08-12 19:32:57 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
LPTSTR lpCmdLine;
|
|
|
|
LPTSTR lpSwitch;
|
|
|
|
size_t len;
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
lpCmdLine = GetCommandLine();
|
2007-09-05 14:24:45 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
lpSwitch = _tcsstr(lpCmdLine, _T("/f:\""));
|
2012-01-15 13:37:25 +00:00
|
|
|
if (!lpSwitch)
|
2008-02-23 17:48:50 +00:00
|
|
|
return FALSE;
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
len = _tcslen(lpSwitch);
|
2012-01-15 13:37:25 +00:00
|
|
|
if (len < 5 || lpSwitch[len-1] != _T('\"'))
|
2008-02-23 17:48:50 +00:00
|
|
|
{
|
2012-01-15 13:37:25 +00:00
|
|
|
DPRINT1("Invalid switch: %ls\n", lpSwitch);
|
2008-02-23 17:48:50 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2012-01-15 13:37:25 +00:00
|
|
|
lpSwitch[len-1] = _T('\0');
|
|
|
|
|
|
|
|
hSetupInf = SetupOpenInfFile(&lpSwitch[4], NULL, INF_STYLE_OLDNT, NULL);
|
|
|
|
if (hSetupInf == INVALID_HANDLE_VALUE)
|
2008-02-23 17:48:50 +00:00
|
|
|
{
|
2012-01-15 13:37:25 +00:00
|
|
|
DPRINT1("Failed to open INF file: %ls\n", &lpSwitch[4]);
|
2008-02-23 17:48:50 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2012-01-15 13:37:25 +00:00
|
|
|
return TRUE;
|
2006-08-12 19:32:57 +00:00
|
|
|
}
|
|
|
|
|
2007-08-29 20:13:27 +00:00
|
|
|
VOID
|
2007-09-05 14:24:45 +00:00
|
|
|
ParseSetupInf(VOID)
|
2006-08-12 19:32:57 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
INFCONTEXT InfContext;
|
|
|
|
TCHAR szBuffer[30];
|
|
|
|
|
|
|
|
if (!SetupFindFirstLine(hSetupInf,
|
|
|
|
_T("Unattend"),
|
|
|
|
_T("LocaleID"),
|
|
|
|
&InfContext))
|
|
|
|
{
|
|
|
|
SetupCloseInfFile(hSetupInf);
|
2012-01-15 13:37:25 +00:00
|
|
|
DPRINT1("SetupFindFirstLine failed\n");
|
2008-02-23 17:48:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetupGetStringField(&InfContext, 1, szBuffer,
|
|
|
|
sizeof(szBuffer) / sizeof(TCHAR), NULL))
|
|
|
|
{
|
|
|
|
SetupCloseInfFile(hSetupInf);
|
2012-01-15 13:37:25 +00:00
|
|
|
DPRINT1("SetupGetStringField failed\n");
|
2008-02-23 17:48:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
UnattendLCID = _tcstoul(szBuffer, NULL, 16);
|
|
|
|
IsUnattendedSetupEnabled = 1;
|
|
|
|
SetupCloseInfFile(hSetupInf);
|
2006-08-12 19:32:57 +00:00
|
|
|
}
|
2004-10-30 12:33:51 +00:00
|
|
|
|
2007-07-28 20:02:37 +00:00
|
|
|
static LONG APIENTRY
|
|
|
|
Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
PROPSHEETPAGE psp[3];
|
|
|
|
PROPSHEETHEADER psh;
|
|
|
|
TCHAR Caption[256];
|
|
|
|
|
|
|
|
if (OpenSetupInf())
|
|
|
|
{
|
|
|
|
ParseSetupInf();
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
|
|
|
|
|
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
|
2008-05-15 05:43:01 +00:00
|
|
|
psh.hwndParent = hCPLWindow;
|
2008-02-23 17:48:50 +00:00
|
|
|
psh.hInstance = hApplet;
|
|
|
|
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
|
|
|
|
psh.pszCaption = Caption;
|
|
|
|
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = psp;
|
|
|
|
|
|
|
|
InitPropSheetPage(&psp[0], IDD_GENERALPAGE, GeneralPageProc);
|
|
|
|
InitPropSheetPage(&psp[1], IDD_LANGUAGESPAGE, LanguagesPageProc);
|
|
|
|
InitPropSheetPage(&psp[2], IDD_ADVANCEDPAGE, AdvancedPageProc);
|
|
|
|
|
|
|
|
return (LONG)(PropertySheet(&psh) != -1);
|
2004-10-30 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Control Panel Callback */
|
2007-10-19 23:21:45 +00:00
|
|
|
LONG APIENTRY
|
2004-10-30 12:33:51 +00:00
|
|
|
CPlApplet(HWND hwndCpl,
|
2008-02-23 17:48:50 +00:00
|
|
|
UINT uMsg,
|
|
|
|
LPARAM lParam1,
|
|
|
|
LPARAM lParam2)
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
switch(uMsg)
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
case CPL_INIT:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case CPL_GETCOUNT:
|
|
|
|
return NUM_APPLETS;
|
|
|
|
|
|
|
|
case CPL_INQUIRE:
|
|
|
|
{
|
|
|
|
CPLINFO *CPlInfo = (CPLINFO*)lParam2;
|
|
|
|
UINT uAppIndex = (UINT)lParam1;
|
|
|
|
|
|
|
|
CPlInfo->lData = 0;
|
|
|
|
CPlInfo->idIcon = Applets[uAppIndex].idIcon;
|
|
|
|
CPlInfo->idName = Applets[uAppIndex].idName;
|
|
|
|
CPlInfo->idInfo = Applets[uAppIndex].idDescription;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CPL_DBLCLK:
|
|
|
|
{
|
|
|
|
UINT uAppIndex = (UINT)lParam1;
|
2008-05-15 05:43:01 +00:00
|
|
|
hCPLWindow = hwndCpl;
|
2008-02-23 17:48:50 +00:00
|
|
|
Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
|
|
|
|
break;
|
|
|
|
}
|
2004-10-30 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
return FALSE;
|
2004-10-30 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2004-10-30 12:33:51 +00:00
|
|
|
DllMain(HINSTANCE hinstDLL,
|
2008-02-23 17:48:50 +00:00
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpReserved)
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
2008-02-23 17:48:50 +00:00
|
|
|
switch(dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
hApplet = hinstDLL;
|
|
|
|
break;
|
|
|
|
}
|
2004-10-30 12:33:51 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|