X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/c1f5f956448a2bd052e71ee1a57f48d9327f2741..4644b0ce3adad5efe574dc125bc3b0cd8f6c2aa7:/windlg.c diff --git a/windlg.c b/windlg.c index d15ebb24..757300dc 100644 --- a/windlg.c +++ b/windlg.c @@ -95,17 +95,13 @@ static void gppi(HKEY key, LPCTSTR name, int def, int *i) { *i = val; } -typedef struct { - void *posn; - void *temp; - char dataspace[2048]; -} DTemplate; - static HINSTANCE hinst; static char **sessions; static int nsessions; +static int readytogo; + static void save_settings (char *section, int do_host) { int i; HKEY subkey1, sesskey; @@ -217,14 +213,17 @@ static void load_settings (char *section, int do_host) { p = malloc(3*strlen(section)+1); mungestr(section, p); - - if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS || - RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) { + + if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &subkey1) != ERROR_SUCCESS) { sesskey = NULL; + } else { + if (RegOpenKey(subkey1, p, &sesskey) != ERROR_SUCCESS) { + sesskey = NULL; + } + RegCloseKey(subkey1); } free(p); - RegCloseKey(subkey1); if (do_host) { char prot[10]; @@ -361,6 +360,27 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, return 0; } +static int CALLBACK LicenceProc (HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { + switch (msg) { + case WM_INITDIALOG: + return 1; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + abtbox = NULL; + DestroyWindow (hwnd); + return 0; + } + return 0; + case WM_CLOSE: + abtbox = NULL; + DestroyWindow (hwnd); + return 0; + } + return 0; +} + static int CALLBACK AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -381,7 +401,7 @@ static int CALLBACK AboutProc (HWND hwnd, UINT msg, case IDA_LICENCE: EnableWindow(hwnd, 0); DialogBox (hinst, MAKEINTRESOURCE(IDD_LICENCEBOX), - NULL, AboutProc); + NULL, LicenceProc); EnableWindow(hwnd, 1); return 0; } @@ -428,6 +448,15 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, cfg.protocol==PROT_SSH ? IDC0_PROTSSH : IDC0_PROTTELNET); CheckDlgButton (hwnd, IDC0_CLOSEEXIT, cfg.close_on_exit); break; + case WM_LBUTTONUP: + /* + * Button release should trigger WM_OK if there was a + * previous double click on the session list. + */ + ReleaseCapture(); + if (readytogo) + SendMessage (GetParent(hwnd), WM_COMMAND, IDOK, 0); + break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC0_PROTTELNET: @@ -525,8 +554,10 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg, * Unless it's Default Settings or some other * host-less set of saved settings. */ - if (*cfg.host) - SendMessage (GetParent(hwnd), WM_COMMAND, IDOK, 0); + if (*cfg.host) { + readytogo = TRUE; + SetCapture(hwnd); + } } break; case IDC0_SESSDEL: @@ -1031,7 +1062,6 @@ static int CALLBACK ColourProc (HWND hwnd, UINT msg, return GeneralPanelProc (hwnd, msg, wParam, lParam); } -static DTemplate negot, main, reconf, panels[NPANELS]; static DLGPROC panelproc[NPANELS] = { ConnectionProc, KeyboardProc, TerminalProc, TelnetProc, SshProc, SelectionProc, ColourProc