don't relay on the order in the combo box
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4352 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
7fa7361447
commit
e225eea343
1 changed files with 18 additions and 9 deletions
|
@ -31,24 +31,26 @@ struct lang {
|
||||||
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int i, size;
|
int i, size;
|
||||||
|
char *selected_language;
|
||||||
static HFONT font;
|
static HFONT font;
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
// add languages
|
// add languages
|
||||||
for (i = langs_num - 1; i >= 0; i--) {
|
for (i = langs_num - 1; i >= 0; i--) {
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name);
|
int cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
|
||||||
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
|
||||||
|
|
||||||
|
// remember selected language
|
||||||
|
if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) {
|
||||||
|
selected_language = langs[i].name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// select the current language
|
||||||
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SELECTSTRING, -1, (LPARAM) selected_language);
|
||||||
// set texts
|
// set texts
|
||||||
SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext);
|
SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext);
|
||||||
SetWindowText(hwndDlg, g_wndtitle);
|
SetWindowText(hwndDlg, g_wndtitle);
|
||||||
SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0);
|
SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0);
|
||||||
// select the current language
|
|
||||||
for (i = 0; i < langs_num; i++) {
|
|
||||||
if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) {
|
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, langs_num-i-1, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// set font
|
// set font
|
||||||
if (dofont && !popstring(temp)) {
|
if (dofont && !popstring(temp)) {
|
||||||
size = myatoi(temp);
|
size = myatoi(temp);
|
||||||
|
@ -73,7 +75,14 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
// push result on the stack
|
// push result on the stack
|
||||||
pushstring(langs[langs_num-SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)-1].id);
|
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
|
||||||
|
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0);
|
||||||
|
if (i) {
|
||||||
|
pushstring((char *) i);
|
||||||
|
} else {
|
||||||
|
// ?!
|
||||||
|
pushstring("cancel");
|
||||||
|
}
|
||||||
// end dialog
|
// end dialog
|
||||||
EndDialog(hwndDlg, 0);
|
EndDialog(hwndDlg, 0);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue