Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenintl.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS 00003 * Copyright (C) 2004 ReactOS Team 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 /* $Id: intl.c 54972 2012-01-15 13:37:25Z rharabien $ 00020 * 00021 * PROJECT: ReactOS International Control Panel 00022 * FILE: dll/cpl/intl/intl.c 00023 * PURPOSE: Property sheet code 00024 * PROGRAMMER: Eric Kohl 00025 */ 00026 00027 #include "intl.h" 00028 00029 #define NUM_APPLETS (1) 00030 00031 static LONG APIENTRY 00032 Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam); 00033 00034 00035 HINSTANCE hApplet = 0; 00036 HWND hCPLWindow; 00037 HINF hSetupInf = INVALID_HANDLE_VALUE; 00038 DWORD IsUnattendedSetupEnabled = 0; 00039 DWORD UnattendLCID = 0; 00040 00041 00042 /* Applets */ 00043 APPLET Applets[NUM_APPLETS] = 00044 { 00045 {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet} 00046 }; 00047 00048 00049 static VOID 00050 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc) 00051 { 00052 ZeroMemory(psp, sizeof(PROPSHEETPAGE)); 00053 psp->dwSize = sizeof(PROPSHEETPAGE); 00054 psp->dwFlags = PSP_DEFAULT; 00055 psp->hInstance = hApplet; 00056 psp->pszTemplate = MAKEINTRESOURCE(idDlg); 00057 psp->pfnDlgProc = DlgProc; 00058 } 00059 00060 BOOL 00061 OpenSetupInf(VOID) 00062 { 00063 LPTSTR lpCmdLine; 00064 LPTSTR lpSwitch; 00065 size_t len; 00066 00067 lpCmdLine = GetCommandLine(); 00068 00069 lpSwitch = _tcsstr(lpCmdLine, _T("/f:\"")); 00070 if (!lpSwitch) 00071 return FALSE; 00072 00073 len = _tcslen(lpSwitch); 00074 if (len < 5 || lpSwitch[len-1] != _T('\"')) 00075 { 00076 DPRINT1("Invalid switch: %ls\n", lpSwitch); 00077 return FALSE; 00078 } 00079 00080 lpSwitch[len-1] = _T('\0'); 00081 00082 hSetupInf = SetupOpenInfFile(&lpSwitch[4], NULL, INF_STYLE_OLDNT, NULL); 00083 if (hSetupInf == INVALID_HANDLE_VALUE) 00084 { 00085 DPRINT1("Failed to open INF file: %ls\n", &lpSwitch[4]); 00086 return FALSE; 00087 } 00088 00089 return TRUE; 00090 } 00091 00092 VOID 00093 ParseSetupInf(VOID) 00094 { 00095 INFCONTEXT InfContext; 00096 TCHAR szBuffer[30]; 00097 00098 if (!SetupFindFirstLine(hSetupInf, 00099 _T("Unattend"), 00100 _T("LocaleID"), 00101 &InfContext)) 00102 { 00103 SetupCloseInfFile(hSetupInf); 00104 DPRINT1("SetupFindFirstLine failed\n"); 00105 return; 00106 } 00107 00108 if (!SetupGetStringField(&InfContext, 1, szBuffer, 00109 sizeof(szBuffer) / sizeof(TCHAR), NULL)) 00110 { 00111 SetupCloseInfFile(hSetupInf); 00112 DPRINT1("SetupGetStringField failed\n"); 00113 return; 00114 } 00115 00116 UnattendLCID = _tcstoul(szBuffer, NULL, 16); 00117 IsUnattendedSetupEnabled = 1; 00118 SetupCloseInfFile(hSetupInf); 00119 } 00120 00121 static LONG APIENTRY 00122 Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam) 00123 { 00124 PROPSHEETPAGE psp[3]; 00125 PROPSHEETHEADER psh; 00126 TCHAR Caption[256]; 00127 00128 if (OpenSetupInf()) 00129 { 00130 ParseSetupInf(); 00131 } 00132 00133 LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR)); 00134 00135 ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); 00136 psh.dwSize = sizeof(PROPSHEETHEADER); 00137 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE; 00138 psh.hwndParent = hCPLWindow; 00139 psh.hInstance = hApplet; 00140 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON)); 00141 psh.pszCaption = Caption; 00142 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); 00143 psh.nStartPage = 0; 00144 psh.ppsp = psp; 00145 00146 InitPropSheetPage(&psp[0], IDD_GENERALPAGE, GeneralPageProc); 00147 InitPropSheetPage(&psp[1], IDD_LANGUAGESPAGE, LanguagesPageProc); 00148 InitPropSheetPage(&psp[2], IDD_ADVANCEDPAGE, AdvancedPageProc); 00149 00150 return (LONG)(PropertySheet(&psh) != -1); 00151 } 00152 00153 00154 /* Control Panel Callback */ 00155 LONG APIENTRY 00156 CPlApplet(HWND hwndCpl, 00157 UINT uMsg, 00158 LPARAM lParam1, 00159 LPARAM lParam2) 00160 { 00161 switch(uMsg) 00162 { 00163 case CPL_INIT: 00164 return TRUE; 00165 00166 case CPL_GETCOUNT: 00167 return NUM_APPLETS; 00168 00169 case CPL_INQUIRE: 00170 { 00171 CPLINFO *CPlInfo = (CPLINFO*)lParam2; 00172 UINT uAppIndex = (UINT)lParam1; 00173 00174 CPlInfo->lData = 0; 00175 CPlInfo->idIcon = Applets[uAppIndex].idIcon; 00176 CPlInfo->idName = Applets[uAppIndex].idName; 00177 CPlInfo->idInfo = Applets[uAppIndex].idDescription; 00178 break; 00179 } 00180 00181 case CPL_DBLCLK: 00182 { 00183 UINT uAppIndex = (UINT)lParam1; 00184 hCPLWindow = hwndCpl; 00185 Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2); 00186 break; 00187 } 00188 } 00189 00190 return FALSE; 00191 } 00192 00193 00194 BOOL WINAPI 00195 DllMain(HINSTANCE hinstDLL, 00196 DWORD dwReason, 00197 LPVOID lpReserved) 00198 { 00199 switch(dwReason) 00200 { 00201 case DLL_PROCESS_ATTACH: 00202 case DLL_THREAD_ATTACH: 00203 hApplet = hinstDLL; 00204 break; 00205 } 00206 00207 return TRUE; 00208 } Generated on Fri May 25 2012 04:19:04 for ReactOS by
1.7.6.1
|