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
Родитель 68da549341
Коммит 27d54e8f96
3 изменённых файлов: 54 добавлений и 6 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#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;

Просмотреть файл

@ -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
@ -63,6 +70,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.
*/
@ -307,6 +319,17 @@ void force_normal(HWND hwnd);
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.
*/