+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);
+}
+