From: owen Date: Mon, 16 Jun 2003 23:55:26 +0000 (+0000) Subject: Fix double-keystrokes by wrapping CreateDialog X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/8ee3ff16bb05090f9812a924d7d2a085bd22d3b2 Fix double-keystrokes by wrapping CreateDialog git-svn-id: svn://svn.tartarus.org/sgt/putty@3267 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/windlg.c b/windlg.c index c9f96fec..277b2c00 100644 --- a/windlg.c +++ b/windlg.c @@ -471,7 +471,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, */ ReleaseCapture(); if (dp.ended) - EndDialog(hwnd, dp.endresult ? 1 : 0); + SaneEndDialog(hwnd, dp.endresult ? 1 : 0); break; case WM_NOTIFY: if (LOWORD(wParam) == IDCX_TREEVIEW && @@ -526,7 +526,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, if (GetWindowLong(hwnd, GWL_USERDATA) == 1) { ret = winctrl_handle_command(&dp, msg, wParam, lParam); if (dp.ended && GetCapture() != hwnd) - EndDialog(hwnd, dp.endresult ? 1 : 0); + SaneEndDialog(hwnd, dp.endresult ? 1 : 0); } else ret = 0; return ret; @@ -544,7 +544,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg, WinHelp(hwnd, help_path, HELP_QUIT, 0); requested_help = FALSE; } - EndDialog(hwnd, 0); + SaneEndDialog(hwnd, 0); return 0; /* Grrr Explorer will maximize Dialogs! */ @@ -611,7 +611,7 @@ int do_config(void) get_sesslist(&sesslist, TRUE); ret = - DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, + SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, GenericMainDlgProc); get_sesslist(&sesslist, FALSE); @@ -643,8 +643,7 @@ int do_reconfig(HWND hwnd) dp.data = &cfg; dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */ - ret = - DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, + ret = SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, GenericMainDlgProc); ctrl_free_box(ctrlbox); diff --git a/winmisc.c b/winmisc.c index 2590befe..d3d372dd 100644 --- a/winmisc.c +++ b/winmisc.c @@ -6,6 +6,7 @@ #include #include #include "putty.h" +#include "winstuff.h" void platform_get_x11_auth(char *display, int *proto, unsigned char *data, int *datalen) @@ -36,6 +37,31 @@ int filename_is_null(Filename fn) return !*fn.path; } +int SaneDialogBox(HINSTANCE hinst, + LPCTSTR tmpl, + HWND hwndparent, + DLGPROC lpDialogFunc) +{ + HWND boxhwnd; + MSG msg; + + boxhwnd = CreateDialog(hinst, tmpl, hwndparent, lpDialogFunc); + while (GetMessage(&msg, NULL, 0, 0)) { + if (!(boxinfo.flags & DF_END) && !IsDialogMessage(boxhwnd, &msg)) + DispatchMessage(&msg); + if (boxinfo.flags & DF_END) break; + } + boxinfo.flags=0; + return boxinfo.result; +} + +void SaneEndDialog(HWND hwnd, int ret) +{ + boxinfo.result = ret; + boxinfo.flags |= DF_END; + DestroyWindow(hwnd); +} + #ifdef DEBUG static FILE *debug_fp = NULL; static HANDLE debug_hdl = INVALID_HANDLE_VALUE; diff --git a/winstuff.h b/winstuff.h index 33b604ff..4bc90db2 100644 --- a/winstuff.h +++ b/winstuff.h @@ -23,6 +23,13 @@ struct FontSpec { int charset; }; +struct dlgboxinfo { + int result; + int flags; +}; + +#define DF_END 0x0001 + /* * Global variables. Most modules declare these `extern', but * window.c will do `#define PUTTY_DO_GLOBALS' before including this @@ -64,6 +71,11 @@ typedef HDC Context; GLOBAL HWND logbox; /* + * Global structure to hold return values from the config box. + */ +GLOBAL struct dlgboxinfo boxinfo; + +/* * The all-important instance handle. */ GLOBAL HINSTANCE hinst; @@ -308,6 +320,17 @@ void modal_about_box(HWND hwnd); void show_help(HWND hwnd); /* + * Exports from winmisc.c. + */ + +int SaneDialogBox(HINSTANCE hinst, + LPCTSTR tmpl, + HWND hwndparent, + DLGPROC lpDialogFunc); + +void SaneEndDialog(HWND hwnd, int ret); + +/* * Exports from sizetip.c. */ void UpdateSizeTip(HWND src, int cx, int cy);