- if (HIWORD(wParam) == EN_CHANGE)
- GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
- sizeof(cfg.line_codepage) - 1);
- if (HIWORD(wParam) == EN_KILLFOCUS) {
- int cp = decode_codepage(cfg.line_codepage);
- char buf[256];
- if (cp < -1) {
- if (cp == -2)
- sprintf(buf,
- "Unable to identify character set '%s', "
- "translation disabled.",
- cfg.line_codepage);
- if (cp == -3)
- sprintf(buf,
- "Character set '%s' is a DBCS, "
- "translation is not available.",
- cfg.line_codepage);
- MessageBox(hwnd, buf, "PuTTY Error",
- MB_ICONERROR | MB_OK);
- }
- strcpy(cfg.line_codepage, cp_name(cp));
- SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
+ CB_GETCURSEL, 0, 0);
+ SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
+ index, (LPARAM)cfg.line_codepage);