New and improved banner:
- No more crashes - Responds to messages (and thus redraws itself) - Doesn't put the main window on the background - Some new /set tricks by brainsucker git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2909 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
370071e60a
commit
a488b62950
4 changed files with 125 additions and 15 deletions
|
@ -14,28 +14,75 @@
|
||||||
|
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
HWND hwBanner;
|
HWND hwBanner;
|
||||||
|
HANDLE hThread;
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
unsigned int myatoi(char *s);
|
unsigned int myatoi(char *s);
|
||||||
|
|
||||||
BOOL CALLBACK bannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (uMsg == WM_INITDIALOG)
|
if (uMsg == WM_INITDIALOG)
|
||||||
{
|
{
|
||||||
|
int iMainStringSet = 0;
|
||||||
|
|
||||||
popstring(buf);
|
popstring(buf);
|
||||||
while (*(int*)buf == CHAR4_TO_DWORD('/','s','e','t')) {
|
while (*(int*)buf == CHAR4_TO_DWORD('/','s','e','t') && !buf[4])
|
||||||
|
{
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
popstring(buf);
|
popstring(buf);
|
||||||
id = myatoi(buf);
|
id = myatoi(buf);
|
||||||
popstring(buf);
|
popstring(buf);
|
||||||
SetDlgItemText(hwndDlg,id,buf);
|
SetDlgItemText(hwndDlg, id, buf);
|
||||||
popstring(buf);
|
popstring(buf);
|
||||||
|
|
||||||
|
if (id == IDC_STR)
|
||||||
|
iMainStringSet++;
|
||||||
}
|
}
|
||||||
SetWindowText(hwndDlg,buf);
|
|
||||||
SetDlgItemText(hwndDlg,IDC_STR,buf);
|
SetWindowText(hwndDlg, buf);
|
||||||
ShowWindow(hwndDlg,SW_SHOW);
|
if (!iMainStringSet)
|
||||||
|
SetDlgItemText(hwndDlg, IDC_STR, buf);
|
||||||
|
|
||||||
|
if (!*buf)
|
||||||
|
SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
|
||||||
}
|
}
|
||||||
|
if (uMsg == WM_CLOSE)
|
||||||
|
{
|
||||||
|
DestroyWindow(hwndDlg);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI BannerThread(LPVOID lpParameter)
|
||||||
|
{
|
||||||
|
HWND hwndParent = (HWND) lpParameter;
|
||||||
|
HWND lhwBanner;
|
||||||
|
MSG msg;
|
||||||
|
//BOOL bRet;
|
||||||
|
|
||||||
|
lhwBanner = CreateDialog(
|
||||||
|
GetModuleHandle(0),
|
||||||
|
MAKEINTRESOURCE(IDD_VERIFY),
|
||||||
|
hwndParent,
|
||||||
|
BannerProc
|
||||||
|
);
|
||||||
|
|
||||||
|
while (IsWindow(lhwBanner))
|
||||||
|
{
|
||||||
|
if (PeekMessage(&msg, lhwBanner, 0, 0, PM_REMOVE))
|
||||||
|
{
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hwBanner = lhwBanner;
|
||||||
|
WaitMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hwBanner = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,21 +90,72 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
hwBanner = CreateDialog(
|
{
|
||||||
GetModuleHandle(0),
|
DWORD dwThreadId;
|
||||||
MAKEINTRESOURCE(IDD_VERIFY),
|
|
||||||
hwndParent,
|
hwBanner = NULL;
|
||||||
bannerProc
|
|
||||||
);
|
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)
|
||||||
|
{
|
||||||
|
Sleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hThread);
|
||||||
|
|
||||||
|
ShowWindow(hwBanner, SW_SHOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
DestroyWindow(hwBanner);
|
if (!hwBanner)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PostMessage(hwBanner, WM_CLOSE, 0, 0);
|
||||||
|
|
||||||
|
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
|
||||||
|
HWND hwTemp;
|
||||||
|
|
||||||
|
AttachThreadInput(GetWindowThreadProcessId(hwndParent, 0), GetCurrentThreadId(), TRUE);
|
||||||
|
|
||||||
|
hwTemp = CreateWindowEx(
|
||||||
|
WS_EX_TOOLWINDOW,
|
||||||
|
"STATIC",
|
||||||
|
"",
|
||||||
|
WS_VISIBLE | WS_POPUP,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
hInstance,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
SetForegroundWindow(hwTemp);
|
||||||
|
DestroyWindow(hwTemp);
|
||||||
|
|
||||||
|
AttachThreadInput(GetWindowThreadProcessId(hwndParent, 0), GetCurrentThreadId(), FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for the thread to finish
|
||||||
|
while (hwBanner)
|
||||||
|
Sleep(25);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
|
hInstance = hInst;
|
||||||
|
if (hwBanner && ul_reason_for_call == DLL_PROCESS_DETACH)
|
||||||
|
{
|
||||||
|
destroy(0, 0, 0, 0);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /entry:"_DllMainCRTStartup" /dll /machine:I386 /nodefaultlib /out:"../../Plugins/Banner.dll" /opt:nowin98
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /entry:"_DllMainCRTStartup" /dll /map /machine:I386 /nodefaultlib /out:"../../Plugins/Banner.dll" /opt:nowin98
|
||||||
# SUBTRACT LINK32 /pdb:none
|
# SUBTRACT LINK32 /pdb:none
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "Banner - Win32 Debug"
|
!ELSEIF "$(CFG)" == "Banner - Win32 Debug"
|
||||||
|
|
|
@ -30,4 +30,16 @@ Example:
|
||||||
|
|
||||||
Banner::show /NOUNLOAD /set 76 "bah #1" /set 54 "bah #2" "Normal text"
|
Banner::show /NOUNLOAD /set 76 "bah #1" /set 54 "bah #2" "Normal text"
|
||||||
|
|
||||||
The second parameter for /set is the ID of the control.
|
The second parameter for /set is the ID of the control.
|
||||||
|
|
||||||
|
Some More Tricks
|
||||||
|
----------------
|
||||||
|
|
||||||
|
If you use /set to set the main string (IDC_STR, 1030) you can specify a different string for the window's caption and for the main string.
|
||||||
|
|
||||||
|
If you use an empty string as the main string (Banner::show /NOUNLOAD "") the banner window will not show on the taskbar.
|
||||||
|
|
||||||
|
Credits
|
||||||
|
-------
|
||||||
|
|
||||||
|
A joint effort of brainsucker and kichik in honor of the messages dropped during the battle
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue