Makensisw now uses nsis version as branding. Added tooltips, updated icon.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1042 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
debe068a54
commit
2c31e3a8e0
7 changed files with 139 additions and 14 deletions
|
@ -24,6 +24,8 @@
|
|||
#include "makensisw.h"
|
||||
#include "noclib.h"
|
||||
|
||||
char *g_branding;
|
||||
|
||||
void SetTitle(HWND hwnd,char *substr) {
|
||||
char title[64];
|
||||
if (substr==NULL) wsprintf(title,"MakeNSISW");
|
||||
|
@ -32,7 +34,7 @@ void SetTitle(HWND hwnd,char *substr) {
|
|||
}
|
||||
|
||||
void SetBranding(HWND hwnd) {
|
||||
SetDlgItemText(hwnd, IDC_VERSION, NSISW_VERSION);
|
||||
SetDlgItemText(hwnd, IDC_VERSION, g_branding);
|
||||
}
|
||||
|
||||
void CopyToClipboard(HWND hwnd) {
|
||||
|
@ -164,10 +166,10 @@ void CompileNSISScript() {
|
|||
return;
|
||||
}
|
||||
if (!g_appended) {
|
||||
if (s) GlobalFree(s);
|
||||
s = (char *)GlobalAlloc(GPTR, lstrlen(g_script)+lstrlen(EXENAME)+2);
|
||||
if (s) GlobalFree(s);
|
||||
s = (char *)GlobalAlloc(GPTR, lstrlen(g_script)+lstrlen(EXENAME)+2);
|
||||
wsprintf(s,"%s %s",EXENAME,g_script);
|
||||
g_script = s;
|
||||
g_script = s;
|
||||
g_appended = TRUE;
|
||||
}
|
||||
// Disable buttons during compile
|
||||
|
@ -209,4 +211,107 @@ void ResetObjects() {
|
|||
g_warnings = FALSE;
|
||||
g_retcode = -1;
|
||||
g_hThread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int InitBranding() {
|
||||
char *s;
|
||||
s = (char *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
|
||||
wsprintf(s,"%s /version",EXENAME);
|
||||
{
|
||||
STARTUPINFO si={sizeof(si),};
|
||||
SECURITY_ATTRIBUTES sa={sizeof(sa),};
|
||||
SECURITY_DESCRIPTOR sd={0,};
|
||||
PROCESS_INFORMATION pi={0,};
|
||||
HANDLE newstdout=0,read_stdout=0;
|
||||
|
||||
OSVERSIONINFO osv={sizeof(osv)};
|
||||
GetVersionEx(&osv);
|
||||
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
||||
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
|
||||
SetSecurityDescriptorDacl(&sd,true,NULL,false);
|
||||
sa.lpSecurityDescriptor = &sd;
|
||||
}
|
||||
else sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = true;
|
||||
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
|
||||
return 0;
|
||||
}
|
||||
GetStartupInfo(&si);
|
||||
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_HIDE;
|
||||
si.hStdOutput = newstdout;
|
||||
si.hStdError = newstdout;
|
||||
if (!CreateProcess(NULL,s,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
|
||||
CloseHandle(newstdout);
|
||||
CloseHandle(read_stdout);
|
||||
return 0;
|
||||
}
|
||||
char szBuf[1024];
|
||||
DWORD dwRead = 1;
|
||||
DWORD dwExit = !STILL_ACTIVE;
|
||||
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
|
||||
return 0;
|
||||
}
|
||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
||||
szBuf[dwRead] = 0;
|
||||
if (lstrlen(szBuf)==0) return 0;
|
||||
g_branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
|
||||
wsprintf(g_branding,"NSIS %s",szBuf);
|
||||
GlobalFree(s);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
HWND g_tip;
|
||||
HWND g_tip_p;
|
||||
HHOOK g_hook;
|
||||
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void InitTooltips(HWND h) {
|
||||
if (h == NULL) return;
|
||||
g_tip_p = h;
|
||||
INITCOMMONCONTROLSEX icx;
|
||||
icx.dwSize = sizeof(icx);
|
||||
icx.dwICC = ICC_BAR_CLASSES;
|
||||
InitCommonControlsEx(&icx);
|
||||
DWORD dwStyle = WS_POPUP | WS_BORDER | TTS_ALWAYSTIP;
|
||||
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
g_tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,
|
||||
NULL,dwStyle,0,0,0,0,
|
||||
h, NULL,
|
||||
GetModuleHandle(NULL),NULL);
|
||||
if (!g_tip) {
|
||||
return;
|
||||
}
|
||||
g_hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
|
||||
AddTip(GetDlgItem(h,IDC_CLOSE),TEXT("Close MakeNSISW"));
|
||||
AddTip(GetDlgItem(h,IDC_TEST),TEXT("Test the installer generated by MakeNSISW"));
|
||||
}
|
||||
|
||||
void DestroyTooltips() {
|
||||
UnhookWindowsHookEx(g_hook);
|
||||
}
|
||||
|
||||
void AddTip(HWND hWnd,LPSTR lpszToolTip) {
|
||||
TOOLINFO ti;
|
||||
ti.cbSize = sizeof(TOOLINFO);
|
||||
ti.uFlags = TTF_IDISHWND;
|
||||
ti.hwnd = g_tip_p;
|
||||
ti.uId = (UINT) hWnd;
|
||||
ti.lpszText = lpszToolTip;
|
||||
SendMessage(g_tip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||
if (nCode < 0) return CallNextHookEx(g_hook, nCode, wParam, lParam);
|
||||
switch (((MSG*)lParam)->message) {
|
||||
case WM_MOUSEMOVE:
|
||||
if (IsChild(g_tip_p,((MSG*)lParam)->hwnd))
|
||||
SendMessage(g_tip, TTM_RELAYEVENT, 0,lParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return CallNextHookEx(g_hook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue