1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-05-30 00:04:49 -05:00

Fix double-keystrokes by wrapping CreateDialog

[originally from svn r3267]
This commit is contained in:
Owen Dunn 2003-06-16 23:55:26 +00:00
parent 68da549341
commit 27d54e8f96
3 changed files with 54 additions and 6 deletions

View File

@ -471,7 +471,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
*/ */
ReleaseCapture(); ReleaseCapture();
if (dp.ended) if (dp.ended)
EndDialog(hwnd, dp.endresult ? 1 : 0); SaneEndDialog(hwnd, dp.endresult ? 1 : 0);
break; break;
case WM_NOTIFY: case WM_NOTIFY:
if (LOWORD(wParam) == IDCX_TREEVIEW && if (LOWORD(wParam) == IDCX_TREEVIEW &&
@ -526,7 +526,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
if (GetWindowLong(hwnd, GWL_USERDATA) == 1) { if (GetWindowLong(hwnd, GWL_USERDATA) == 1) {
ret = winctrl_handle_command(&dp, msg, wParam, lParam); ret = winctrl_handle_command(&dp, msg, wParam, lParam);
if (dp.ended && GetCapture() != hwnd) if (dp.ended && GetCapture() != hwnd)
EndDialog(hwnd, dp.endresult ? 1 : 0); SaneEndDialog(hwnd, dp.endresult ? 1 : 0);
} else } else
ret = 0; ret = 0;
return ret; return ret;
@ -544,7 +544,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
WinHelp(hwnd, help_path, HELP_QUIT, 0); WinHelp(hwnd, help_path, HELP_QUIT, 0);
requested_help = FALSE; requested_help = FALSE;
} }
EndDialog(hwnd, 0); SaneEndDialog(hwnd, 0);
return 0; return 0;
/* Grrr Explorer will maximize Dialogs! */ /* Grrr Explorer will maximize Dialogs! */
@ -611,7 +611,7 @@ int do_config(void)
get_sesslist(&sesslist, TRUE); get_sesslist(&sesslist, TRUE);
ret = ret =
DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
GenericMainDlgProc); GenericMainDlgProc);
get_sesslist(&sesslist, FALSE); get_sesslist(&sesslist, FALSE);
@ -643,8 +643,7 @@ int do_reconfig(HWND hwnd)
dp.data = &cfg; dp.data = &cfg;
dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */ dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */
ret = ret = SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
GenericMainDlgProc); GenericMainDlgProc);
ctrl_free_box(ctrlbox); ctrl_free_box(ctrlbox);

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "putty.h" #include "putty.h"
#include "winstuff.h"
void platform_get_x11_auth(char *display, int *proto, void platform_get_x11_auth(char *display, int *proto,
unsigned char *data, int *datalen) unsigned char *data, int *datalen)
@ -36,6 +37,31 @@ int filename_is_null(Filename fn)
return !*fn.path; 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 #ifdef DEBUG
static FILE *debug_fp = NULL; static FILE *debug_fp = NULL;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE; static HANDLE debug_hdl = INVALID_HANDLE_VALUE;

View File

@ -23,6 +23,13 @@ struct FontSpec {
int charset; int charset;
}; };
struct dlgboxinfo {
int result;
int flags;
};
#define DF_END 0x0001
/* /*
* Global variables. Most modules declare these `extern', but * Global variables. Most modules declare these `extern', but
* window.c will do `#define PUTTY_DO_GLOBALS' before including this * window.c will do `#define PUTTY_DO_GLOBALS' before including this
@ -63,6 +70,11 @@ typedef HDC Context;
*/ */
GLOBAL HWND logbox; GLOBAL HWND logbox;
/*
* Global structure to hold return values from the config box.
*/
GLOBAL struct dlgboxinfo boxinfo;
/* /*
* The all-important instance handle. * The all-important instance handle.
*/ */
@ -307,6 +319,17 @@ void force_normal(HWND hwnd);
void modal_about_box(HWND hwnd); void modal_about_box(HWND hwnd);
void show_help(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. * Exports from sizetip.c.
*/ */