3 typedef struct CPStruct
9 struct CPStruct
*NextItem
;
12 static LPCPAGE PCPage
= NULL
;
14 static BOOL bSpain
= FALSE
;
15 static HWND hLangList
;
26 //TCHAR Section[MAX_PATH];
28 Count
= SetupGetLineCount(hIntlInf
, _T("CodePages"));
29 if (Count
<= 0) return FALSE
;
31 for (Number
= 0; Number
< (UINT
)Count
; Number
++)
33 if (SetupGetLineByIndex(hIntlInf
, _T("CodePages"), Number
, &infCont
) &&
34 SetupGetIntField(&infCont
, 0, (PINT
)&uiCPage
))
36 if (!(hCPage
= GlobalAlloc(GHND
, sizeof(CPAGE
)))) return FALSE
;
38 lpCPage
= GlobalLock(hCPage
);
39 lpCPage
->CPage
= uiCPage
;
40 lpCPage
->hCPage
= hCPage
;
42 (lpCPage
->Name
)[0] = 0;
44 if (GetCPInfoEx(uiCPage
, 0, &cpInfEx
))
46 _tcscpy(lpCPage
->Name
, cpInfEx
.CodePageName
);
48 else if (!SetupGetStringField(&infCont
, 1, lpCPage
->Name
, MAX_PATH
, NULL
))
55 lpCPage
->NextItem
= PCPage
;
64 InstalledCPProc(LPTSTR lpStr
)
75 if (lpCP
->CPage
== uiCP
)
77 lpCP
->Status
|= 0x0001;
80 lpCP
= lpCP
->NextItem
;
87 InitCodePagesList(HWND hwndDlg
)
96 hList
= GetDlgItem(hwndDlg
, IDC_CONV_TABLES
);
98 hIntlInf
= SetupOpenInfFile(_T("intl.inf"), NULL
, INF_STYLE_WIN4
, NULL
);
100 if (hIntlInf
== INVALID_HANDLE_VALUE
)
103 if (!SetupOpenAppendInfFile(NULL
, hIntlInf
, NULL
))
105 SetupCloseInfFile(hIntlInf
);
110 if (!GetSupportedCP())
113 SetupCloseInfFile(hIntlInf
);
115 if (!EnumSystemCodePages(InstalledCPProc
, CP_INSTALLED
))
118 ZeroMemory(&column
, sizeof(LV_COLUMN
));
119 column
.mask
= LVCF_FMT
|LVCF_TEXT
|LVCF_WIDTH
;
120 column
.fmt
= LVCFMT_LEFT
;
121 GetClientRect(hList
, &ListRect
);
122 column
.cx
= ListRect
.right
- GetSystemMetrics(SM_CYHSCROLL
);
123 (VOID
) ListView_InsertColumn(hList
, 0, &column
);
125 (VOID
) ListView_SetExtendedListViewStyle(hList
, LVS_EX_CHECKBOXES
|LVS_EX_FULLROWSELECT
);
132 ZeroMemory(&item
, sizeof(LV_ITEM
));
133 item
.mask
= LVIF_TEXT
|LVIF_PARAM
|LVIF_STATE
;
135 item
.stateMask
= LVIS_STATEIMAGEMASK
;
136 item
.pszText
= lpCPage
->Name
;
137 item
.lParam
= (LPARAM
)lpCPage
;
139 ItemIndex
= ListView_InsertItem(hList
, &item
);
143 if (lpCPage
->Status
& 0x0001)
145 ListView_SetItemState(hList
, ItemIndex
,
146 INDEXTOSTATEIMAGEMASK(LVIS_SELECTED
),
147 LVIS_STATEIMAGEMASK
);
151 ListView_SetItemState(hList
, ItemIndex
,
152 INDEXTOSTATEIMAGEMASK(LVIS_FOCUSED
),
153 LVIS_STATEIMAGEMASK
);
157 lpCPage
= lpCPage
->NextItem
;
162 LocalesEnumProc(LPTSTR lpLocale
)
167 BOOL bNoShow
= FALSE
;
169 lcid
= _tcstoul(lpLocale
, NULL
, 16);
171 if (lcid
== MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH
), SORT_DEFAULT
) ||
172 lcid
== MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH_MODERN
), SORT_DEFAULT
))
176 LoadString(hApplet
, IDS_SPAIN
, lang
, 255);
186 GetLocaleInfo(lcid
, LOCALE_SLANGUAGE
, lang
, sizeof(lang
)/sizeof(TCHAR
));
189 if (bNoShow
== FALSE
)
191 index
= SendMessage(hLangList
,
196 SendMessage(hLangList
,
206 InitLanguagesList(HWND hwndDlg
)
210 hLangList
= GetDlgItem(hwndDlg
, IDC_LANGUAGE_COMBO
);
213 EnumSystemLocales(LocalesEnumProc
, LCID_SUPPORTED
);
215 /* Select current locale */
216 GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SLANGUAGE
, langSel
, sizeof(langSel
)/sizeof(TCHAR
));
218 SendMessage(hLangList
, CB_SELECTSTRING
, -1, (LPARAM
)langSel
);
222 GetCurrentDPI(LPTSTR szDPI
)
224 DWORD dwType
, dwSize
, dwDPI
, dwDefDPI
= 0x00000060; // Default 96 DPI
227 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE
, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontDPI"), 0, NULL
,
228 REG_OPTION_NON_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
230 _tcscpy(szDPI
, _T("96"));
235 dwSize
= sizeof(DWORD
);
237 if (RegQueryValueEx(hKey
, _T("LogPixels"), NULL
, &dwType
, (LPBYTE
)&dwDPI
, &dwSize
) != ERROR_SUCCESS
)
239 if (RegSetValueEx(hKey
, _T("LogPixels"), 0, REG_DWORD
, (LPBYTE
)&dwDefDPI
, sizeof(DWORD
)) == ERROR_SUCCESS
)
241 _tcscpy(szDPI
, _T("96"));
246 else wsprintf(szDPI
, _T("%d"), dwDPI
);
252 SetNonUnicodeLang(HWND hwnd
, LCID lcid
)
254 TCHAR szDefCP
[5 + 1], szSection
[MAX_PATH
], szDPI
[3 + 1];
258 GetLocaleInfo(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_IDEFAULTCODEPAGE
, szDefCP
, sizeof(szDefCP
) / sizeof(TCHAR
));
259 GetCurrentDPI(szDPI
);
261 wsprintf(szSection
, _T("Font.CP%s.%s"), szDefCP
, szDPI
);
263 hFontInf
= SetupOpenInfFile(_T("font.inf"), NULL
, INF_STYLE_WIN4
, NULL
);
265 if (hFontInf
== INVALID_HANDLE_VALUE
)
268 if (!SetupOpenAppendInfFile(NULL
, hFontInf
, NULL
))
270 SetupCloseInfFile(hFontInf
);
274 Count
= (UINT
) SetupGetLineCount(hFontInf
, szSection
);
275 if (Count
<= 0) return;
277 if (!SetupInstallFromInfSection(hwnd
, hFontInf
, szSection
, SPINST_REGISTRY
& ~SPINST_FILES
,
278 NULL
, NULL
, 0, NULL
, NULL
, NULL
, NULL
))
279 MessageBox(hwnd
, _T("Unable to install a new language for programs don't support unicode!"),
280 NULL
, MB_ICONERROR
| MB_OK
);
282 SetupCloseInfFile(hFontInf
);
285 /* Property page dialog callback */
287 AdvancedPageProc(HWND hwndDlg
,
296 InitLanguagesList(hwndDlg
);
297 InitCodePagesList(hwndDlg
);
303 switch (LOWORD(wParam
))
305 case IDC_LANGUAGE_COMBO
:
307 if (HIWORD(wParam
) == CBN_SELCHANGE
)
308 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
317 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
319 if (lpnm
->code
== (UINT
)PSN_APPLY
)
324 PropSheet_UnChanged(GetParent(hwndDlg
), hwndDlg
);
326 iIndex
= SendMessage(hLangList
, CB_GETCURSEL
, 0, 0);
327 if (iIndex
== CB_ERR
)
330 lcid
= SendMessage(hLangList
, CB_GETITEMDATA
, iIndex
, 0);
331 if (lcid
== (LCID
)CB_ERR
)
334 SetNonUnicodeLang(hwndDlg
, lcid
);