12 typedef struct CPStruct
18 struct CPStruct
*NextItem
;
21 static LPCPAGE PCPage
= NULL
;
23 static BOOL bSpain
= FALSE
;
24 static HWND hLangList
;
35 //TCHAR Section[MAX_PATH];
37 Count
= SetupGetLineCount(hIntlInf
, _T("CodePages"));
38 if (Count
<= 0) return FALSE
;
40 for (Number
= 0; Number
< (UINT
)Count
; Number
++)
42 if (SetupGetLineByIndex(hIntlInf
, _T("CodePages"), Number
, &infCont
) &&
43 SetupGetIntField(&infCont
, 0, (PINT
)&uiCPage
))
45 if (!(hCPage
= GlobalAlloc(GHND
, sizeof(CPAGE
)))) return FALSE
;
47 lpCPage
= GlobalLock(hCPage
);
48 lpCPage
->CPage
= uiCPage
;
49 lpCPage
->hCPage
= hCPage
;
51 (lpCPage
->Name
)[0] = 0;
53 if (GetCPInfoEx(uiCPage
, 0, &cpInfEx
))
55 _tcscpy(lpCPage
->Name
, cpInfEx
.CodePageName
);
57 else if (!SetupGetStringField(&infCont
, 1, lpCPage
->Name
, MAX_PATH
, NULL
))
64 lpCPage
->NextItem
= PCPage
;
73 InstalledCPProc(LPTSTR lpStr
)
84 if (lpCP
->CPage
== uiCP
)
86 lpCP
->Status
|= 0x0001;
89 lpCP
= lpCP
->NextItem
;
96 InitCodePagesList(HWND hwndDlg
)
105 hList
= GetDlgItem(hwndDlg
, IDC_CONV_TABLES
);
107 hIntlInf
= SetupOpenInfFile(_T("intl.inf"), NULL
, INF_STYLE_WIN4
, NULL
);
109 if (hIntlInf
== INVALID_HANDLE_VALUE
)
112 if (!SetupOpenAppendInfFile(NULL
, hIntlInf
, NULL
))
114 SetupCloseInfFile(hIntlInf
);
119 if (!GetSupportedCP())
122 SetupCloseInfFile(hIntlInf
);
124 if (!EnumSystemCodePages(InstalledCPProc
, CP_INSTALLED
))
127 ZeroMemory(&column
, sizeof(LV_COLUMN
));
128 column
.mask
= LVCF_FMT
|LVCF_TEXT
|LVCF_WIDTH
;
129 column
.fmt
= LVCFMT_LEFT
;
130 GetClientRect(hList
, &ListRect
);
131 column
.cx
= ListRect
.right
- GetSystemMetrics(SM_CYHSCROLL
);
132 (VOID
) ListView_InsertColumn(hList
, 0, &column
);
134 (VOID
) ListView_SetExtendedListViewStyle(hList
, LVS_EX_CHECKBOXES
|LVS_EX_FULLROWSELECT
);
141 ZeroMemory(&item
, sizeof(LV_ITEM
));
142 item
.mask
= LVIF_TEXT
|LVIF_PARAM
|LVIF_STATE
;
144 item
.stateMask
= LVIS_STATEIMAGEMASK
;
145 item
.pszText
= lpCPage
->Name
;
146 item
.lParam
= (LPARAM
)lpCPage
;
148 ItemIndex
= ListView_InsertItem(hList
, &item
);
152 if (lpCPage
->Status
& 0x0001)
154 ListView_SetItemState(hList
, ItemIndex
,
155 INDEXTOSTATEIMAGEMASK(LVIS_SELECTED
),
156 LVIS_STATEIMAGEMASK
);
160 ListView_SetItemState(hList
, ItemIndex
,
161 INDEXTOSTATEIMAGEMASK(LVIS_FOCUSED
),
162 LVIS_STATEIMAGEMASK
);
166 lpCPage
= lpCPage
->NextItem
;
171 LocalesEnumProc(LPTSTR lpLocale
)
176 BOOL bNoShow
= FALSE
;
178 lcid
= _tcstoul(lpLocale
, NULL
, 16);
180 if (lcid
== MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH
), SORT_DEFAULT
) ||
181 lcid
== MAKELCID(MAKELANGID(LANG_SPANISH
, SUBLANG_SPANISH_MODERN
), SORT_DEFAULT
))
185 LoadString(hApplet
, IDS_SPAIN
, lang
, 255);
195 GetLocaleInfo(lcid
, LOCALE_SLANGUAGE
, lang
, sizeof(lang
)/sizeof(TCHAR
));
198 if (bNoShow
== FALSE
)
200 index
= SendMessage(hLangList
,
205 SendMessage(hLangList
,
215 InitLanguagesList(HWND hwndDlg
)
219 hLangList
= GetDlgItem(hwndDlg
, IDC_LANGUAGE_COMBO
);
222 EnumSystemLocales(LocalesEnumProc
, LCID_SUPPORTED
);
224 /* Select current locale */
225 GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SLANGUAGE
, langSel
, sizeof(langSel
)/sizeof(TCHAR
));
227 SendMessage(hLangList
, CB_SELECTSTRING
, -1, (LPARAM
)langSel
);
231 GetCurrentDPI(LPTSTR szDPI
)
233 DWORD dwType
, dwSize
, dwDPI
, dwDefDPI
= 0x00000060; // Default 96 DPI
236 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE
, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontDPI"), 0, NULL
,
237 REG_OPTION_NON_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
239 _tcscpy(szDPI
, _T("96"));
244 dwSize
= sizeof(DWORD
);
246 if (RegQueryValueEx(hKey
, _T("LogPixels"), NULL
, &dwType
, (LPBYTE
)&dwDPI
, &dwSize
) != ERROR_SUCCESS
)
248 if (RegSetValueEx(hKey
, _T("LogPixels"), 0, REG_DWORD
, (LPBYTE
)&dwDefDPI
, sizeof(DWORD
)) == ERROR_SUCCESS
)
250 _tcscpy(szDPI
, _T("96"));
255 else wsprintf(szDPI
, _T("%d"), dwDPI
);
261 SetNonUnicodeLang(HWND hwnd
, LCID lcid
)
263 TCHAR szDefCP
[5 + 1], szSection
[MAX_PATH
], szDPI
[3 + 1];
267 GetLocaleInfo(MAKELCID(lcid
, SORT_DEFAULT
), LOCALE_IDEFAULTCODEPAGE
, szDefCP
, sizeof(szDefCP
) / sizeof(TCHAR
));
268 GetCurrentDPI(szDPI
);
270 wsprintf(szSection
, _T("Font.CP%s.%s"), szDefCP
, szDPI
);
272 hFontInf
= SetupOpenInfFile(_T("font.inf"), NULL
, INF_STYLE_WIN4
, NULL
);
274 if (hFontInf
== INVALID_HANDLE_VALUE
)
277 if (!SetupOpenAppendInfFile(NULL
, hFontInf
, NULL
))
279 SetupCloseInfFile(hFontInf
);
283 Count
= (UINT
) SetupGetLineCount(hFontInf
, szSection
);
284 if (Count
<= 0) return;
286 if (!SetupInstallFromInfSection(hwnd
, hFontInf
, szSection
, SPINST_REGISTRY
& ~SPINST_FILES
,
287 NULL
, NULL
, 0, NULL
, NULL
, NULL
, NULL
))
288 MessageBox(hwnd
, _T("Unable to install a new language for programs don't support unicode!"),
289 NULL
, MB_ICONERROR
| MB_OK
);
291 SetupCloseInfFile(hFontInf
);
294 /* Property page dialog callback */
296 AdvancedPageProc(HWND hwndDlg
,
305 InitLanguagesList(hwndDlg
);
306 InitCodePagesList(hwndDlg
);
312 switch (LOWORD(wParam
))
314 case IDC_LANGUAGE_COMBO
:
316 if (HIWORD(wParam
) == CBN_SELCHANGE
)
317 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
326 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
328 if (lpnm
->code
== (UINT
)PSN_APPLY
)
333 PropSheet_UnChanged(GetParent(hwndDlg
), hwndDlg
);
335 iIndex
= SendMessage(hLangList
, CB_GETCURSEL
, 0, 0);
336 if (iIndex
== CB_ERR
)
339 lcid
= SendMessage(hLangList
, CB_GETITEMDATA
, iIndex
, 0);
340 if (lcid
== (LCID
)CB_ERR
)
343 SetNonUnicodeLang(hwndDlg
, lcid
);