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
|
|
|
*/
|
2013-03-16 20:25:38 +00:00
|
|
|
/*
|
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"
|
|
|
|
|
2014-01-19 10:31:28 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
#define NUM_APPLETS (1)
|
2004-10-30 12:33:51 +00:00
|
|
|
|
2014-02-02 19:31:07 +00:00
|
|
|
#define BUFFERSIZE 512
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-02-02 19:31:07 +00:00
|
|
|
VOID
|
|
|
|
PrintErrorMsgBox(UINT msg)
|
|
|
|
{
|
2017-04-30 15:39:41 +00:00
|
|
|
WCHAR szErrorText[BUFFERSIZE];
|
|
|
|
WCHAR szErrorCaption[BUFFERSIZE];
|
2014-02-02 19:31:07 +00:00
|
|
|
|
2017-04-30 15:39:41 +00:00
|
|
|
LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
|
|
|
LoadStringW(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
|
2014-02-02 19:31:07 +00:00
|
|
|
|
2017-04-30 15:39:41 +00:00
|
|
|
MessageBoxW(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
|
2014-02-02 19:31:07 +00:00
|
|
|
}
|
2004-10-30 12:33:51 +00:00
|
|
|
|
2017-04-30 15:39:41 +00:00
|
|
|
INT
|
2015-09-19 12:14:35 +00:00
|
|
|
ResourceMessageBox(
|
|
|
|
HWND hwnd,
|
|
|
|
UINT uType,
|
|
|
|
UINT uCaptionId,
|
|
|
|
UINT uMessageId)
|
|
|
|
{
|
|
|
|
WCHAR szErrorText[BUFFERSIZE];
|
|
|
|
WCHAR szErrorCaption[BUFFERSIZE];
|
|
|
|
|
|
|
|
LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
|
|
|
LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
|
|
|
|
|
2017-04-30 15:39:41 +00:00
|
|
|
return MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
|
2015-09-19 12:14:35 +00:00
|
|
|
}
|
|
|
|
|
2007-09-08 22:27:41 +00:00
|
|
|
static VOID
|
2017-12-23 13:07:33 +00:00
|
|
|
InitIntlPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPARAM lParam)
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
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;
|
2015-09-19 12:14:35 +00:00
|
|
|
psp->lParam = lParam;
|
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
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
PWSTR lpCmdLine;
|
|
|
|
PWSTR lpSwitch;
|
2008-02-23 17:48:50 +00:00
|
|
|
size_t len;
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
lpCmdLine = GetCommandLineW();
|
2007-09-05 14:24:45 +00:00
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
lpSwitch = wcsstr(lpCmdLine, L"/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
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
len = wcslen(lpSwitch);
|
|
|
|
if (len < 5 || lpSwitch[len-1] != L'\"')
|
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
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
lpSwitch[len-1] = L'\0';
|
2012-01-15 13:37:25 +00:00
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
hSetupInf = SetupOpenInfFileW(&lpSwitch[4], NULL, INF_STYLE_OLDNT, NULL);
|
2012-01-15 13:37:25 +00:00
|
|
|
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;
|
2015-09-20 19:00:10 +00:00
|
|
|
WCHAR szBuffer[30];
|
2008-02-23 17:48:50 +00:00
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
if (!SetupFindFirstLineW(hSetupInf,
|
|
|
|
L"Unattend",
|
|
|
|
L"LocaleID",
|
|
|
|
&InfContext))
|
2008-02-23 17:48:50 +00:00
|
|
|
{
|
|
|
|
SetupCloseInfFile(hSetupInf);
|
2012-01-15 13:37:25 +00:00
|
|
|
DPRINT1("SetupFindFirstLine failed\n");
|
2008-02-23 17:48:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext, 1, szBuffer,
|
|
|
|
sizeof(szBuffer) / sizeof(WCHAR), NULL))
|
2008-02-23 17:48:50 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
UnattendLCID = wcstoul(szBuffer, NULL, 16);
|
2008-02-23 17:48:50 +00:00
|
|
|
IsUnattendedSetupEnabled = 1;
|
|
|
|
SetupCloseInfFile(hSetupInf);
|
2006-08-12 19:32:57 +00:00
|
|
|
}
|
2004-10-30 12:33:51 +00:00
|
|
|
|
2018-12-14 11:06:57 +00:00
|
|
|
static int CALLBACK
|
|
|
|
PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
|
|
|
|
{
|
|
|
|
// NOTE: This callback is needed to set large icon correctly.
|
|
|
|
HICON hIcon;
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case PSCB_INITIALIZED:
|
|
|
|
{
|
|
|
|
hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDC_CPLICON));
|
|
|
|
SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-09-19 12:14:35 +00:00
|
|
|
TCHAR Caption[BUFFERSIZE];
|
2008-02-23 17:48:50 +00:00
|
|
|
PROPSHEETPAGE psp[3];
|
|
|
|
PROPSHEETHEADER psh;
|
2015-09-19 12:14:35 +00:00
|
|
|
PGLOBALDATA pGlobalData;
|
|
|
|
LONG ret;
|
2008-02-23 17:48:50 +00:00
|
|
|
|
|
|
|
if (OpenSetupInf())
|
|
|
|
{
|
|
|
|
ParseSetupInf();
|
|
|
|
}
|
|
|
|
|
2015-09-19 12:14:35 +00:00
|
|
|
pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBALDATA));
|
2015-10-10 13:54:00 +00:00
|
|
|
if (pGlobalData == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pGlobalData->SystemLCID = GetSystemDefaultLCID();
|
2016-01-10 21:12:23 +00:00
|
|
|
pGlobalData->bIsUserAdmin = IsUserAdmin();
|
2015-09-19 12:14:35 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
|
|
|
|
|
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
2018-12-14 11:06:57 +00:00
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
|
2008-05-15 05:43:01 +00:00
|
|
|
psh.hwndParent = hCPLWindow;
|
2008-02-23 17:48:50 +00:00
|
|
|
psh.hInstance = hApplet;
|
2018-12-14 11:06:57 +00:00
|
|
|
psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON);
|
2008-02-23 17:48:50 +00:00
|
|
|
psh.pszCaption = Caption;
|
2016-01-10 21:12:23 +00:00
|
|
|
psh.nPages = 0; //sizeof(psp) / sizeof(PROPSHEETPAGE);
|
2008-02-23 17:48:50 +00:00
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = psp;
|
2018-12-14 11:06:57 +00:00
|
|
|
psh.pfnCallback = PropSheetProc;
|
2008-02-23 17:48:50 +00:00
|
|
|
|
2017-12-23 13:07:33 +00:00
|
|
|
InitIntlPropSheetPage(&psp[0], IDD_GENERALPAGE, GeneralPageProc, (LPARAM)pGlobalData);
|
2016-01-10 21:12:23 +00:00
|
|
|
psh.nPages++;
|
2017-12-23 13:07:33 +00:00
|
|
|
InitIntlPropSheetPage(&psp[1], IDD_LANGUAGESPAGE, LanguagesPageProc, (LPARAM)pGlobalData);
|
2016-01-10 21:12:23 +00:00
|
|
|
psh.nPages++;
|
|
|
|
|
|
|
|
if (pGlobalData->bIsUserAdmin)
|
|
|
|
{
|
2017-12-23 13:07:33 +00:00
|
|
|
InitIntlPropSheetPage(&psp[2], IDD_ADVANCEDPAGE, AdvancedPageProc, (LPARAM)pGlobalData);
|
2016-01-10 21:12:23 +00:00
|
|
|
psh.nPages++;
|
|
|
|
}
|
2015-09-19 12:14:35 +00:00
|
|
|
|
|
|
|
ret = (LONG)(PropertySheet(&psh) != -1);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pGlobalData);
|
2008-02-23 17:48:50 +00:00
|
|
|
|
2015-09-19 12:14:35 +00:00
|
|
|
return ret;
|
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;
|
|
|
|
}
|