X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/12745e35f6aa5ba7b1a89afe6d5249d8ca46dd37..798a50bf16c5c2b5c304643a77851d41088f5c16:/windows/windlg.c diff --git a/windows/windlg.c b/windows/windlg.c index 91bf7565..7377cd3a 100644 --- a/windows/windlg.c +++ b/windows/windlg.c @@ -1,3 +1,7 @@ +/* + * windlg.c - dialogs for PuTTY(tel), including the configuration dialog. + */ + #include #include #include @@ -240,7 +244,7 @@ static int SaneDialogBox(HINSTANCE hinst, wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW; wc.lpfnWndProc = DefDlgProc; wc.cbClsExtra = 0; - wc.cbWndExtra = DLGWINDOWEXTRA + 8; + wc.cbWndExtra = DLGWINDOWEXTRA + 2*sizeof(LONG_PTR); wc.hInstance = hinst; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -251,11 +255,11 @@ static int SaneDialogBox(HINSTANCE hinst, hwnd = CreateDialog(hinst, tmpl, hwndparent, lpDialogFunc); - SetWindowLong(hwnd, BOXFLAGS, 0); /* flags */ - SetWindowLong(hwnd, BOXRESULT, 0); /* result from SaneEndDialog */ + SetWindowLongPtr(hwnd, BOXFLAGS, 0); /* flags */ + SetWindowLongPtr(hwnd, BOXRESULT, 0); /* result from SaneEndDialog */ while ((gm=GetMessage(&msg, NULL, 0, 0)) > 0) { - flags=GetWindowLong(hwnd, BOXFLAGS); + flags=GetWindowLongPtr(hwnd, BOXFLAGS); if (!(flags & DF_END) && !IsDialogMessage(hwnd, &msg)) DispatchMessage(&msg); if (flags & DF_END) @@ -265,15 +269,15 @@ static int SaneDialogBox(HINSTANCE hinst, if (gm == 0) PostQuitMessage(msg.wParam); /* We got a WM_QUIT, pass it on */ - ret=GetWindowLong(hwnd, BOXRESULT); + ret=GetWindowLongPtr(hwnd, BOXRESULT); DestroyWindow(hwnd); return ret; } static void SaneEndDialog(HWND hwnd, int ret) { - SetWindowLong(hwnd, BOXRESULT, ret); - SetWindowLong(hwnd, BOXFLAGS, DF_END); + SetWindowLongPtr(hwnd, BOXRESULT, ret); + SetWindowLongPtr(hwnd, BOXFLAGS, DF_END); } /* @@ -318,7 +322,7 @@ static HTREEITEM treeview_insert(struct treeview_faff *faff, newitem = TreeView_InsertItem(faff->treeview, &ins); if (level > 0) TreeView_Expand(faff->treeview, faff->lastat[level - 1], - TVE_EXPAND); + (level > 1 ? TVE_COLLAPSE : TVE_EXPAND)); faff->lastat[level] = newitem; for (i = level + 1; i < 4; i++) faff->lastat[i] = NULL; @@ -375,16 +379,16 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, dp.hwnd = hwnd; create_controls(hwnd, ""); /* Open and Cancel buttons etc */ SetWindowText(hwnd, dp.wintitle); - SetWindowLong(hwnd, GWL_USERDATA, 0); - if (help_path) - SetWindowLong(hwnd, GWL_EXSTYLE, - GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + if (has_help()) + SetWindowLongPtr(hwnd, GWL_EXSTYLE, + GetWindowLongPtr(hwnd, GWL_EXSTYLE) | + WS_EX_CONTEXTHELP); else { HWND item = GetDlgItem(hwnd, IDC_HELPBTN); if (item) DestroyWindow(item); } - requested_help = FALSE; SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON))); /* @@ -512,7 +516,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, } } - SetWindowLong(hwnd, GWL_USERDATA, 1); + SetWindowLongPtr(hwnd, GWLP_USERDATA, 1); return 0; case WM_LBUTTONUP: /* @@ -573,7 +577,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, /* * Only process WM_COMMAND once the dialog is fully formed. */ - if (GetWindowLong(hwnd, GWL_USERDATA) == 1) { + if (GetWindowLongPtr(hwnd, GWLP_USERDATA) == 1) { ret = winctrl_handle_command(&dp, msg, wParam, lParam); if (dp.ended && GetCapture() != hwnd) SaneEndDialog(hwnd, dp.endresult ? 1 : 0); @@ -581,19 +585,12 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, ret = 0; return ret; case WM_HELP: - if (help_path) { - if (winctrl_context_help(&dp, hwnd, - ((LPHELPINFO)lParam)->iCtrlId)) - requested_help = TRUE; - else - MessageBeep(0); - } + if (!winctrl_context_help(&dp, hwnd, + ((LPHELPINFO)lParam)->iCtrlId)) + MessageBeep(0); break; case WM_CLOSE: - if (requested_help) { - WinHelp(hwnd, help_path, HELP_QUIT, 0); - requested_help = FALSE; - } + quit_help(hwnd); SaneEndDialog(hwnd, 0); return 0; @@ -617,12 +614,7 @@ void modal_about_box(HWND hwnd) void show_help(HWND hwnd) { - if (help_path) { - WinHelp(hwnd, help_path, - help_has_contents ? HELP_FINDER : HELP_CONTENTS, - 0); - requested_help = TRUE; - } + launch_help(hwnd, NULL); } void defuse_showwindow(void) @@ -648,7 +640,7 @@ int do_config(void) ctrlbox = ctrl_new_box(); setup_config_box(ctrlbox, FALSE, 0, 0); - win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), FALSE); + win_setup_config_box(ctrlbox, &dp.hwnd, has_help(), FALSE, 0); dp_init(&dp); winctrl_init(&ctrls_base); winctrl_init(&ctrls_panel); @@ -657,6 +649,7 @@ int do_config(void) dp.wintitle = dupprintf("%s Configuration", appname); dp.errtitle = dupprintf("%s Error", appname); dp.data = &cfg; + dlg_auto_set_fixed_pitch_flag(&dp); dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */ ret = @@ -680,7 +673,8 @@ int do_reconfig(HWND hwnd, int protcfginfo) ctrlbox = ctrl_new_box(); setup_config_box(ctrlbox, TRUE, cfg.protocol, protcfginfo); - win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), TRUE); + win_setup_config_box(ctrlbox, &dp.hwnd, has_help(), TRUE, + cfg.protocol); dp_init(&dp); winctrl_init(&ctrls_base); winctrl_init(&ctrls_panel); @@ -689,6 +683,7 @@ int do_reconfig(HWND hwnd, int protcfginfo) dp.wintitle = dupprintf("%s Reconfiguration", appname); dp.errtitle = dupprintf("%s Error", appname); dp.data = &cfg; + dlg_auto_set_fixed_pitch_flag(&dp); dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */ ret = SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, @@ -793,7 +788,7 @@ int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, if (ret == 0) /* success - key matched OK */ return 1; - if (ret == 2) { /* key was different */ + else if (ret == 2) { /* key was different */ int mbret; char *text = dupprintf(wrongmsg, appname, keytype, fingerprint, appname); @@ -809,9 +804,7 @@ int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, return 1; } else if (mbret == IDNO) return 1; - return 0; - } - if (ret == 1) { /* key was absent */ + } else if (ret == 1) { /* key was absent */ int mbret; char *text = dupprintf(absentmsg, keytype, fingerprint, appname); char *caption = dupprintf(mbtitle, appname); @@ -826,8 +819,8 @@ int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, return 1; } else if (mbret == IDNO) return 1; - return 0; } + return 0; /* abandon the connection */ } /* @@ -850,6 +843,7 @@ int askalg(void *frontend, const char *algtype, const char *algname, title = dupprintf(mbtitle, appname); mbret = MessageBox(NULL, message, title, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + socket_reselect_all(); sfree(message); sfree(title); if (mbret == IDYES) @@ -882,6 +876,8 @@ int askappend(void *frontend, Filename filename, mbret = MessageBox(NULL, message, mbtitle, MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON3); + socket_reselect_all(); + sfree(message); sfree(mbtitle); @@ -923,6 +919,8 @@ void old_keyfile_warning(void) MessageBox(NULL, msg, title, MB_OK); + socket_reselect_all(); + sfree(msg); sfree(title); }