From a5b216a7825eb6e5bdcf04900423263e474c5be9 Mon Sep 17 00:00:00 2001 From: kichik Date: Tue, 26 Jun 2007 19:00:14 +0000 Subject: [PATCH] fixed bug #1743801 - Banner can hang when called form custom page git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5173 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/Banner/Banner.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Contrib/Banner/Banner.c b/Contrib/Banner/Banner.c index f2d4817d..22e7fbcc 100644 --- a/Contrib/Banner/Banner.c +++ b/Contrib/Banner/Banner.c @@ -55,11 +55,24 @@ BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } +BOOL ProcessMessages() +{ + BOOL processed = FALSE; + MSG msg; + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + DispatchMessage(&msg); + processed = TRUE; + } + + return processed; +} + DWORD WINAPI BannerThread(LPVOID lpParameter) { HWND hwndParent = (HWND) lpParameter; HWND lhwBanner; - MSG msg; lhwBanner = CreateDialog( GetModuleHandle(0), @@ -75,11 +88,7 @@ DWORD WINAPI BannerThread(LPVOID lpParameter) while (IsWindow(lhwBanner)) { - if (PeekMessage(&msg, lhwBanner, 0, 0, PM_REMOVE)) - { - DispatchMessage(&msg); - } - else + if (!ProcessMessages()) { hwBanner = lhwBanner; WaitMessage(); @@ -111,6 +120,7 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable // wait for the window to initalize and for the stack operations to finish while (hThread && !hwBanner && !bFailed) { + ProcessMessages(); Sleep(10); } @@ -142,7 +152,10 @@ void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *varia // Wait for the thread to finish while (hwBanner) + { + ProcessMessages(); Sleep(25); + } } BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)