From 80f062d8cefdb550083a382fb25e0f08073ed0c9 Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 1 Oct 2004 13:14:13 +0000 Subject: [PATCH] - fixed bug #1022399 - Only initial banner is in foreground - added a few more checks git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3690 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/Banner/Banner.c | 25 +++++++++++++++++-------- Plugins/Banner.dll | Bin 4096 -> 4096 bytes 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Contrib/Banner/Banner.c b/Contrib/Banner/Banner.c index 7278d044..2baf3319 100644 --- a/Contrib/Banner/Banner.c +++ b/Contrib/Banner/Banner.c @@ -15,6 +15,7 @@ HINSTANCE hInstance; HWND hwBanner; HANDLE hThread; +BOOL bFailed; char buf[1024]; @@ -59,7 +60,6 @@ DWORD WINAPI BannerThread(LPVOID lpParameter) HWND hwndParent = (HWND) lpParameter; HWND lhwBanner; MSG msg; - //BOOL bRet; lhwBanner = CreateDialog( GetModuleHandle(0), @@ -67,6 +67,13 @@ DWORD WINAPI BannerThread(LPVOID lpParameter) hwndParent, BannerProc ); + if (!lhwBanner) + { + bFailed = TRUE; + return 0; + } + + SetForegroundWindow(lhwBanner); while (IsWindow(lhwBanner)) { @@ -95,10 +102,15 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable hwBanner = NULL; + if (!IsWindowVisible(hwndParent)) + hwndParent = 0; + + bFailed = FALSE; + hThread = CreateThread(0, 0, BannerThread, (LPVOID) hwndParent, 0, &dwThreadId); // wait for the window to initalize and for the stack operations to finish - while (hThread && !hwBanner) + while (hThread && !hwBanner && !bFailed) { Sleep(10); } @@ -124,12 +136,11 @@ void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *varia if (!hwndParent) { - // create a dummy window on the thread the NSIS window will be created on and set it - // as the foreground window so this thread will return to be the foreground window + // reset the thread that called banner::Show to be the foreground thread. + // if banner was called from .onInit, this will make sure the NSIS dialog + // will still be created on the foreground HWND hwTemp; - AttachThreadInput(GetWindowThreadProcessId(hwndParent, 0), GetCurrentThreadId(), TRUE); - hwTemp = CreateWindowEx( WS_EX_TOOLWINDOW, "STATIC", @@ -146,8 +157,6 @@ void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *varia ); SetForegroundWindow(hwTemp); DestroyWindow(hwTemp); - - AttachThreadInput(GetWindowThreadProcessId(hwndParent, 0), GetCurrentThreadId(), FALSE); } // Wait for the thread to finish diff --git a/Plugins/Banner.dll b/Plugins/Banner.dll index 28c2257a12cfaf2682c81a3a0d6e0c312a85d002..3488fe0e0f1ae35a7d4ff9cc23b4632c74d95aef 100644 GIT binary patch delta 1163 zcmcJO-%lJ>6vyvOXJHpdJJ6j*teAmLp^a7N-d)8le(!?%7kHD; zoO{mso^#Kg%#0eN##<-$eXwn&X|`kPKc1a>6#n$(z*Gb5!0(xC^Wc`NFgSqrj4mrj@ zmzt!z`2wES#cDY$*F_DYU8+zBDMd%)rbRU3ZMWygAhzeP^2d~IlEq(9jQXw6siR5v zrsM0Iu`en4VN-o=*wi$y5;2p1s_Ywy+^|y_^w4}S==P?3JqT&i*Z0HZms)Ol>P*0h z5=}z?(jLe5_1z*9Zx1B5M!3ur4XkP;!mFM>uUTDe3IAm z`SN_8_w%_=+A(QNI{n6h3$53--t3tDkC$hoh~NLAYPJzJ_lG{a1@`;jUoG30`g?V^ zmQY*a7OJf zxUF1=y^Ov2Vy!3OY1knV@$+h)kWzRoDl0@J=60<(iDIpI!`{uea$$RfmqH5agfTU9 zuiXhY!!PmHs4R?+%A#nlL9WUEls}NyT7GIz>JSkf)0-JgIzcaLRVR25#)>}g?klAy zGh8xxDzT*DAdb}JydfY&v=cl zADwv19ix_U2cV-mV#r=|Bzd^qic0P)oO9c1=!2)CzgyN*J+A94YR3^{;F!^2d{cTnAZq_gDBY*_t}%7?9VEm(1xFSs%-^N}jIC1Y(Qj^_mx ztJr3H*Zh?y^&vu@0Igs@=m0%n2#kVh;I0p0FN1HvFW^s5jo(`UG=Uu;4qgE|Fu*i; z7hC|>fxAAC%BH-X3DvNF<0h(SP$8Q5+mK-KhQUL zA~75zH6&&jsb0NucVNgg$VpdowPZD|W(RxIxty!~rvLGX`=55F(YlEc4)&1>b%