- 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
This commit is contained in:
parent
6427fe2c78
commit
80f062d8ce
2 changed files with 17 additions and 8 deletions
|
@ -15,6 +15,7 @@
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
HWND hwBanner;
|
HWND hwBanner;
|
||||||
HANDLE hThread;
|
HANDLE hThread;
|
||||||
|
BOOL bFailed;
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
|
@ -59,7 +60,6 @@ DWORD WINAPI BannerThread(LPVOID lpParameter)
|
||||||
HWND hwndParent = (HWND) lpParameter;
|
HWND hwndParent = (HWND) lpParameter;
|
||||||
HWND lhwBanner;
|
HWND lhwBanner;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
//BOOL bRet;
|
|
||||||
|
|
||||||
lhwBanner = CreateDialog(
|
lhwBanner = CreateDialog(
|
||||||
GetModuleHandle(0),
|
GetModuleHandle(0),
|
||||||
|
@ -67,6 +67,13 @@ DWORD WINAPI BannerThread(LPVOID lpParameter)
|
||||||
hwndParent,
|
hwndParent,
|
||||||
BannerProc
|
BannerProc
|
||||||
);
|
);
|
||||||
|
if (!lhwBanner)
|
||||||
|
{
|
||||||
|
bFailed = TRUE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetForegroundWindow(lhwBanner);
|
||||||
|
|
||||||
while (IsWindow(lhwBanner))
|
while (IsWindow(lhwBanner))
|
||||||
{
|
{
|
||||||
|
@ -95,10 +102,15 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable
|
||||||
|
|
||||||
hwBanner = NULL;
|
hwBanner = NULL;
|
||||||
|
|
||||||
|
if (!IsWindowVisible(hwndParent))
|
||||||
|
hwndParent = 0;
|
||||||
|
|
||||||
|
bFailed = FALSE;
|
||||||
|
|
||||||
hThread = CreateThread(0, 0, BannerThread, (LPVOID) hwndParent, 0, &dwThreadId);
|
hThread = CreateThread(0, 0, BannerThread, (LPVOID) hwndParent, 0, &dwThreadId);
|
||||||
|
|
||||||
// wait for the window to initalize and for the stack operations to finish
|
// wait for the window to initalize and for the stack operations to finish
|
||||||
while (hThread && !hwBanner)
|
while (hThread && !hwBanner && !bFailed)
|
||||||
{
|
{
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
}
|
}
|
||||||
|
@ -124,12 +136,11 @@ void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *varia
|
||||||
|
|
||||||
if (!hwndParent)
|
if (!hwndParent)
|
||||||
{
|
{
|
||||||
// create a dummy window on the thread the NSIS window will be created on and set it
|
// reset the thread that called banner::Show to be the foreground thread.
|
||||||
// as the foreground window so this thread will return to be the foreground window
|
// if banner was called from .onInit, this will make sure the NSIS dialog
|
||||||
|
// will still be created on the foreground
|
||||||
HWND hwTemp;
|
HWND hwTemp;
|
||||||
|
|
||||||
AttachThreadInput(GetWindowThreadProcessId(hwndParent, 0), GetCurrentThreadId(), TRUE);
|
|
||||||
|
|
||||||
hwTemp = CreateWindowEx(
|
hwTemp = CreateWindowEx(
|
||||||
WS_EX_TOOLWINDOW,
|
WS_EX_TOOLWINDOW,
|
||||||
"STATIC",
|
"STATIC",
|
||||||
|
@ -146,8 +157,6 @@ void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *varia
|
||||||
);
|
);
|
||||||
SetForegroundWindow(hwTemp);
|
SetForegroundWindow(hwTemp);
|
||||||
DestroyWindow(hwTemp);
|
DestroyWindow(hwTemp);
|
||||||
|
|
||||||
AttachThreadInput(GetWindowThreadProcessId(hwndParent, 0), GetCurrentThreadId(), FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the thread to finish
|
// Wait for the thread to finish
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue