ダイアログ上のチェックボックスの機能を一通り実装した
- クリップボードからのペースト後にクリップボードをクリアする/しない
- パスフレーズで制御文字を使用する/しない
- パスフレーズを表示する/しない
- ユーザー名にwindowsのユーザー名をペーストするボタンを追加
@@ -37,6 +37,7 @@ | ||
37 | 37 | #include <fcntl.h> |
38 | 38 | #include <stdlib.h> |
39 | 39 | #include <errno.h> |
40 | +#include <Lmcons.h> // for UNLEN | |
40 | 41 | |
41 | 42 | #include "resource.h" |
42 | 43 | #include "keyfiles.h" |
@@ -66,6 +67,7 @@ | ||
66 | 67 | -1, -1, -1, -1, -1, -1, -1, -1, -1, IDC_SSHUSEPAGEANT, -1 |
67 | 68 | }; |
68 | 69 | static TipWin *tipwin; |
70 | +static BOOL UseControlChar = TRUE; | |
69 | 71 | |
70 | 72 | LRESULT CALLBACK password_wnd_proc(HWND control, UINT msg, |
71 | 73 | WPARAM wParam, LPARAM lParam) |
@@ -72,6 +74,10 @@ | ||
72 | 74 | { |
73 | 75 | switch (msg) { |
74 | 76 | case WM_CHAR: |
77 | + if (!UseControlChar) { | |
78 | + // 制御文字は使用しない | |
79 | + break; | |
80 | + } | |
75 | 81 | if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) { |
76 | 82 | TCHAR chars[] = { (TCHAR) wParam, 0 }; |
77 | 83 |
@@ -807,6 +813,9 @@ | ||
807 | 813 | else { |
808 | 814 | DlgAuthFont = NULL; |
809 | 815 | } |
816 | + UseControlChar = TRUE; | |
817 | + CheckDlgButton(dlg, IDC_USE_CONTROL_CHARACTER, UseControlChar ? BST_CHECKED : BST_UNCHECKED); | |
818 | + CheckDlgButton(dlg, IDC_CLEAR_CLIPBOARD, BST_UNCHECKED); | |
810 | 819 | |
811 | 820 | // SSH2 autologinが有効の場合は、タイマを仕掛ける。 (2004.12.1 yutaka) |
812 | 821 | if (pvar->ssh2_autologin == 1) { |
@@ -1013,16 +1022,64 @@ | ||
1013 | 1022 | return TRUE; |
1014 | 1023 | |
1015 | 1024 | case IDC_FROM_CLIPBOARD: { |
1016 | - char *clipboard = GetClipboardTextA(dlg, TRUE); | |
1025 | + char *clipboard = GetClipboardTextA(dlg, IsDlgButtonChecked(dlg, IDC_CLEAR_CLIPBOARD) != BST_UNCHECKED); | |
1017 | 1026 | if (clipboard != NULL) { |
1018 | 1027 | SetDlgItemTextA(dlg, IDC_SSHPASSWORD, clipboard); |
1019 | 1028 | free(clipboard); |
1020 | - SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDOK), TRUE); | |
1029 | + SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1); | |
1030 | + SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE); | |
1021 | 1031 | return FALSE; |
1022 | 1032 | } |
1023 | 1033 | return TRUE; |
1024 | 1034 | } |
1025 | 1035 | |
1036 | + case IDC_SHOW_PASSPHRASE: { | |
1037 | + // 伏せ字 on/off を切り替える | |
1038 | + HWND hWnd = GetDlgItem(dlg, IDC_SSHPASSWORD); | |
1039 | + static wchar_t password_char; | |
1040 | + if (password_char == 0) { | |
1041 | + wchar_t c = (wchar_t)SendMessage(hWnd, EM_GETPASSWORDCHAR, 0, 0); | |
1042 | + password_char = c; | |
1043 | + } | |
1044 | + if (IsDlgButtonChecked(dlg, IDC_SHOW_PASSPHRASE) != BST_UNCHECKED) { | |
1045 | + SendMessage(hWnd, EM_SETPASSWORDCHAR, 0, 0); | |
1046 | + } else { | |
1047 | +#if !defined(UNICODE) | |
1048 | + if (password_char < 0x100) { | |
1049 | + SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0); | |
1050 | + } else { | |
1051 | + // TODO W系直呼び ↓うまくいかない | |
1052 | + //SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0); | |
1053 | + SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)'*', 0); | |
1054 | + } | |
1055 | +#else | |
1056 | + SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0); | |
1057 | +#endif | |
1058 | + } | |
1059 | + //InvalidateRect(hWnd, NULL, TRUE); | |
1060 | + SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1); | |
1061 | + SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE); | |
1062 | + return TRUE; | |
1063 | + } | |
1064 | + | |
1065 | + case IDC_FROM_GETUSERNAME: { | |
1066 | + TCHAR user_name[UNLEN+1]; | |
1067 | + DWORD len = _countof(user_name); | |
1068 | + BOOL r = GetUserName(user_name, &len); | |
1069 | + if (r != 0) { | |
1070 | + SetDlgItemText(dlg, IDC_SSHUSERNAME, user_name); | |
1071 | + SendDlgItemMessage(dlg, IDC_SSHUSERNAME, EM_SETSEL, 0, -1); | |
1072 | + SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHUSERNAME), TRUE); | |
1073 | + } | |
1074 | + return TRUE; | |
1075 | + } | |
1076 | + | |
1077 | + case IDC_USE_CONTROL_CHARACTER: { | |
1078 | + UseControlChar = | |
1079 | + (IsDlgButtonChecked(dlg, IDC_USE_CONTROL_CHARACTER) != BST_UNCHECKED) ? | |
1080 | + TRUE : FALSE; | |
1081 | + break; | |
1082 | + } | |
1026 | 1083 | default: |
1027 | 1084 | return FALSE; |
1028 | 1085 | } |
@@ -230,12 +230,13 @@ | ||
230 | 230 | #define IDC_USE_CONTROL_CHARACTER 1234 |
231 | 231 | #define IDC_HOSTRSAFILENAMELABEL 1235 |
232 | 232 | #define IDC_RSAFILENAMELABEL 1236 |
233 | +#define IDC_FROM_GETUSERNAME 1237 | |
233 | 234 | |
234 | 235 | // Next default values for new objects |
235 | 236 | // |
236 | 237 | #ifdef APSTUDIO_INVOKED |
237 | 238 | #ifndef APSTUDIO_READONLY_SYMBOLS |
238 | -#define _APS_NEXT_RESOURCE_VALUE 116 | |
239 | +#define _APS_NEXT_RESOURCE_VALUE 117 | |
239 | 240 | #define _APS_NEXT_COMMAND_VALUE 40001 |
240 | 241 | #define _APS_NEXT_CONTROL_VALUE 1237 |
241 | 242 | #define _APS_NEXT_SYMED_VALUE 101 |