From 60eb38ddcbeeb1a0cb79652c890ad237ef3a45bc Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 31 May 2015 11:01:10 -0400 Subject: [PATCH] Properly saved window enable state in windows/dialoghelper.c. --- redo/windows/dialoghelper.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/redo/windows/dialoghelper.c b/redo/windows/dialoghelper.c index 1330d0cf..3fe803a2 100644 --- a/redo/windows/dialoghelper.c +++ b/redo/windows/dialoghelper.c @@ -3,11 +3,10 @@ // see http://stackoverflow.com/questions/25494914/is-there-something-like-cdn-filecancel-analogous-to-cdn-fileok-for-getting-when#comment40420049_25494914 -// TODO reconcile this with users being able to enable/disable windows - struct dialogDisableWindow { HWND hwnd; uintmax_t n; + BOOL prevstate; UT_hash_handle hh; }; @@ -39,9 +38,15 @@ void dialogHelperUnregisterWindow(HWND hwnd) static void dialogBegin(void) { struct dialogDisableWindow *d; + BOOL prevstate; for (d = windows; d != NULL; d = d->hh.next) { - EnableWindow(d->hwnd, FALSE); + prevstate = EnableWindow(d->hwnd, FALSE); + // store the previous state in case the window was already disabled by the user + // (TODO test) + // note the !; EnableWindow() returns TRUE if window was previously /disabled/ + if (d->n == 0) + d->prevstate = !prevstate; d->n++; } } @@ -53,7 +58,7 @@ static void dialogEnd(void) for (d = windows; d != NULL; d = d->hh.next) { d->n--; if (d->n == 0) - EnableWindow(d->hwnd, TRUE); + EnableWindow(d->hwnd, d->prevstate); } }