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.
|
|
|
|
*
|
|
|
|
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2004-10-30 12:33:51 +00:00
|
|
|
*
|
|
|
|
* PROJECT: ReactOS International Control Panel
|
|
|
|
* FILE: lib/cpl/intl/intl.c
|
|
|
|
* PURPOSE: Property sheet code
|
|
|
|
* PROGRAMMER: Eric Kohl
|
|
|
|
*/
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <cpl.h>
|
2006-08-12 19:32:57 +00:00
|
|
|
#include <setupapi.h>
|
|
|
|
#include <tchar.h>
|
2004-10-30 12:33:51 +00:00
|
|
|
|
|
|
|
#include "intl.h"
|
|
|
|
#include "resource.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:\""));
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
if(!lpSwitch)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
len = _tcslen(lpSwitch);
|
|
|
|
if (len < 5)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
if(lpSwitch[len-1] != _T('\"'))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
lpSwitch[len-1] = _T('\0');
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
hSetupInf = SetupOpenInfFile(&lpSwitch[4], NULL,
|
|
|
|
INF_STYLE_OLDNT, NULL);
|
2006-08-12 19:32:57 +00:00
|
|
|
|
2008-02-23 17:48:50 +00:00
|
|
|
return (hSetupInf != INVALID_HANDLE_VALUE);
|
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);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetupGetStringField(&InfContext, 1, szBuffer,
|
|
|
|
sizeof(szBuffer) / sizeof(TCHAR), NULL))
|
|
|
|
{
|
|
|
|
SetupCloseInfFile(hSetupInf);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL STDCALL
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|