diff --git a/redo/dialog_windows.c b/redo/dialog_windows.c index d5b69f7..fff8e95 100644 --- a/redo/dialog_windows.c +++ b/redo/dialog_windows.c @@ -6,6 +6,17 @@ // this should be reasonable #define NFILENAME 4096 +static UINT_PTR CALLBACK openSaveFileHook(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + // the hook procedure is documented as being the dialog procedure for a special child dialog box, not the main one + // as such, the WM_DESTROY here is for that child dialog box, not for the main one + // I /think/ this would be perfect for re-enabling other windows in the right order (see http://blogs.msdn.com/b/oldnewthing/archive/2004/02/27/81155.aspx) + // TODO THIS DOES NOT WORK + if (uMsg == WM_DESTROY) + SendMessageW(msgwin, msgEndModal, 0, 0); + return 0; +} + WCHAR *openFile(void) { OPENFILENAMEW ofn; @@ -28,7 +39,9 @@ WCHAR *openFile(void) ofn.lpstrTitle = NULL; // let system decide // TODO OFN_SHAREAWARE? // TODO remove OFN_NODEREFERENCELINKS? or does no filters ensure that anyway? - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_NOCHANGEDIR | OFN_NODEREFERENCELINKS | OFN_NOTESTFILECREATE | OFN_PATHMUSTEXIST; + ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_NOCHANGEDIR | OFN_NODEREFERENCELINKS | OFN_NOTESTFILECREATE | OFN_PATHMUSTEXIST; + ofn.lpfnHook = openSaveFileHook; + SendMessageW(msgwin, msgBeginModal, 0, 0); if (GetOpenFileNameW(&ofn) == FALSE) { // TODO stringify err = CommDlgExtendedError(); diff --git a/redo/uitask_windows.c b/redo/uitask_windows.c index 85203da..9b38aef 100644 --- a/redo/uitask_windows.c +++ b/redo/uitask_windows.c @@ -71,6 +71,13 @@ HWND msgwin; #define msgwinclass L"gouimsgwin" +static BOOL CALLBACK beginEndModalAll(HWND hwnd, LPARAM lParam) +{ + if (hwnd != msgwin) + SendMessageW(hwnd, (UINT) lParam, 0, 0); + return TRUE; +} + static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT shared; @@ -84,8 +91,24 @@ static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l return 0; // TODO respond to WM_THEMECHANGED case msgRequest: + // in modal? + if (GetWindowLongPtrW(hwnd, GWLP_USERDATA) != 0) { + // post again later + // TODO this chokes the message queue! + issue((void *) lParam); + return 0; + } + // nope, we can run now doissue((void *) lParam); return 0; + case msgBeginModal: + SetWindowLongPtrW(hwnd, GWLP_USERDATA, 1); + EnumThreadWindows(GetCurrentThreadId(), beginEndModalAll, msgBeginModal); + return 0; + case msgEndModal: + SetWindowLongPtrW(hwnd, GWLP_USERDATA, 0); + EnumThreadWindows(GetCurrentThreadId(), beginEndModalAll, msgEndModal); + return 0; default: return DefWindowProcW(hwnd, uMsg, wParam, lParam); }