Alternate doc path points to docs on nsis.sf.net not cvs; Use smaller logo.bmp; Removed background color code from about dialog; Stupid typo in about box (thanks joost); Created some structs for globals

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1361 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
rainwater 2002-10-09 20:41:37 +00:00
parent 30e2d57957
commit b014c64356
4 changed files with 220 additions and 223 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Before After
Before After

View file

@ -24,47 +24,36 @@
#include "resource.h"
#include "noclib.h"
static RECT resizeRect;
static RECT g_griprect;
static int dx;
static int dy;
char *g_script;
int g_retcode;
HINSTANCE g_hInstance;
HWND g_hwnd;
HANDLE g_hThread;
BOOL g_warnings;
FINDREPLACE fr;
UINT uFindReplaceMsg=0;
HWND hwndFind=0;
CHARRANGE g_chrg;
HMENU g_submnu;
HMENU g_mnu;
NSCRIPTDATA g_sdata;
NRESIZEDATA g_resize;
NFINDREPLACE g_find;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow) {
MSG msg;
int status;
HACCEL haccel;
g_hInstance=GetModuleHandle(0);
g_script=GetCommandLine();
if (*g_script=='"') { g_script++; while (*g_script && *g_script++!='"' ); }
else while (*g_script!=' ' && *g_script) g_script++;
while (*g_script==' ') g_script++;
ZeroMemory(&g_sdata,sizeof(NSCRIPTDATA));
ZeroMemory(&g_resize,sizeof(NRESIZEDATA));
ZeroMemory(&g_find,sizeof(NFINDREPLACE));
g_sdata.hInstance=GetModuleHandle(0);
g_sdata.script=GetCommandLine();
if (*g_sdata.script=='"') { g_sdata.script++; while (*g_sdata.script && *g_sdata.script++!='"' ); }
else while (*g_sdata.script!=' ' && *g_sdata.script) g_sdata.script++;
while (*g_sdata.script==' ') g_sdata.script++;
if (!InitBranding()) {
MessageBox(0,NSISERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
return 1;
}
ResetObjects();
HWND hDialog = CreateDialog(g_hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
HWND hDialog = CreateDialog(g_sdata.hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
if (!hDialog) {
MessageBox(0,DLGERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
return 1;
}
haccel = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDK_ACCEL));
haccel = LoadAccelerators(g_sdata.hInstance, MAKEINTRESOURCE(IDK_ACCEL));
while ((status=GetMessage(&msg,0,0,0))!=0) {
if (status==-1) return -1;
if (!IsDialogMessage(hwndFind, &msg)) {
if (!IsDialogMessage(g_find.hwndFind, &msg)) {
if (!TranslateAccelerator(hDialog,haccel,&msg)) {
if (!IsDialogMessage(hDialog,&msg)) {
TranslateMessage(&msg);
@ -83,44 +72,44 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_INITDIALOG:
{
g_hwnd=hwndDlg;
HICON hIcon = LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON));
g_sdata.hwnd=hwndDlg;
HICON hIcon = LoadIcon(g_sdata.hInstance,MAKEINTRESOURCE(IDI_ICON));
SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
SendMessage(GetDlgItem(hwndDlg,IDC_LOGWIN),EM_SETEVENTMASK,NULL,ENM_SELCHANGE);
DragAcceptFiles(g_hwnd,FALSE);
InitTooltips(g_hwnd);
g_mnu = GetMenu(hwndDlg);
g_submnu = GetSubMenu(g_mnu,1);
SetBranding(g_hwnd);
DragAcceptFiles(g_sdata.hwnd,FALSE);
InitTooltips(g_sdata.hwnd);
g_sdata.menu = GetMenu(g_sdata.hwnd);
g_sdata.submenu = GetSubMenu(g_sdata.menu,1);
SetBranding(g_sdata.hwnd);
HFONT hFont = CreateFont(14,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH|FF_DONTCARE,"Courier New");
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,WM_SETFONT,(WPARAM)hFont,0);
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,EM_SETBKGNDCOLOR,0,GetSysColor(COLOR_BTNFACE));
RestoreWindowPos(g_hwnd);
RestoreWindowPos(g_sdata.hwnd);
CompileNSISScript();
return TRUE;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
GetClientRect(g_hwnd, &g_griprect);
HDC hdc = BeginPaint(g_hwnd, &ps);
g_griprect.left = g_griprect.right - GetSystemMetrics(SM_CXVSCROLL);
g_griprect.top = g_griprect.bottom - GetSystemMetrics(SM_CYVSCROLL);
DrawFrameControl(hdc, &g_griprect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
EndPaint(g_hwnd,&ps);
GetClientRect(g_sdata.hwnd, &g_resize.griprect);
HDC hdc = BeginPaint(g_sdata.hwnd, &ps);
g_resize.griprect.left = g_resize.griprect.right - GetSystemMetrics(SM_CXVSCROLL);
g_resize.griprect.top = g_resize.griprect.bottom - GetSystemMetrics(SM_CYVSCROLL);
DrawFrameControl(hdc, &g_resize.griprect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
EndPaint(g_sdata.hwnd,&ps);
return TRUE;
}
case WM_DESTROY:
{
SaveWindowPos(g_hwnd);
SaveWindowPos(g_sdata.hwnd);
DestroyTooltips();
PostQuitMessage(0);
return TRUE;
}
case WM_CLOSE:
{
if (!g_hThread) {
DragAcceptFiles(g_hwnd,FALSE);
if (!g_sdata.thread) {
DragAcceptFiles(g_sdata.hwnd,FALSE);
DestroyWindow(hwndDlg);
FreeLibrary(hRichEditDLL);
}
@ -128,8 +117,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case WM_CONTEXTMENU:
{
if ((HWND)wParam==GetDlgItem(g_hwnd,IDC_LOGWIN)) {
TrackPopupMenu(g_submnu,NULL,(int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam),0,g_hwnd,0);
if ((HWND)wParam==GetDlgItem(g_sdata.hwnd,IDC_LOGWIN)) {
TrackPopupMenu(g_sdata.submenu,NULL,(int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam),0,g_sdata.hwnd,0);
}
return TRUE;
}
@ -140,8 +129,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (num==1) {
DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH);
if (lstrlen(szTmp)>0) {
g_script = (char *)GlobalAlloc(GPTR,sizeof(szTmp)+7);
wsprintf(g_script,"/CD \"%s\"",szTmp);
g_sdata.script = (char *)GlobalAlloc(GPTR,sizeof(szTmp)+7);
wsprintf(g_sdata.script,"/CD \"%s\"",szTmp);
ResetObjects();
CompileNSISScript();
}
@ -155,55 +144,55 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case WM_ENTERSIZEMOVE:
{
GetClientRect(g_hwnd, &resizeRect);
GetClientRect(g_sdata.hwnd, &g_resize.resizeRect);
return TRUE;
}
case WM_SIZE:
{
if ((wParam == SIZE_MAXHIDE)||(wParam == SIZE_MAXSHOW)) return TRUE;
RECT rSize;
if (hwndDlg == g_hwnd) {
GetClientRect(g_hwnd, &rSize);
if (((rSize.right==0)&&(rSize.bottom==0))||((resizeRect.right==0)&&(resizeRect.bottom==0))) return TRUE;
dx = rSize.right - resizeRect.right;
dy = rSize.bottom - resizeRect.bottom;
EnumChildWindows(g_hwnd, DialogResize, (LPARAM)0);
resizeRect = rSize;
if (hwndDlg == g_sdata.hwnd) {
GetClientRect(g_sdata.hwnd, &rSize);
if (((rSize.right==0)&&(rSize.bottom==0))||((g_resize.resizeRect.right==0)&&(g_resize.resizeRect.bottom==0))) return TRUE;
g_resize.dx = rSize.right - g_resize.resizeRect.right;
g_resize.dy = rSize.bottom - g_resize.resizeRect.bottom;
EnumChildWindows(g_sdata.hwnd, DialogResize, (LPARAM)0);
g_resize.resizeRect = rSize;
}
return TRUE;
}
case WM_SIZING:
{
InvalidateRect(g_hwnd,&g_griprect,TRUE);
GetClientRect(g_hwnd, &g_griprect);
g_griprect.left = g_griprect.right - GetSystemMetrics(SM_CXVSCROLL);
g_griprect.top = g_griprect.bottom - GetSystemMetrics(SM_CYVSCROLL);
InvalidateRect(g_sdata.hwnd,&g_resize.griprect,TRUE);
GetClientRect(g_sdata.hwnd, &g_resize.griprect);
g_resize.griprect.left = g_resize.griprect.right - GetSystemMetrics(SM_CXVSCROLL);
g_resize.griprect.top = g_resize.griprect.bottom - GetSystemMetrics(SM_CYVSCROLL);
return TRUE;
}
case WM_MAKENSIS_PROCESSCOMPLETE:
{
if (g_hThread) {
CloseHandle(g_hThread);
g_hThread=0;
if (g_sdata.thread) {
CloseHandle(g_sdata.thread);
g_sdata.thread=0;
}
EnableItems(g_hwnd);
if (g_retcode==0) {
EnableItems(g_sdata.hwnd);
if (g_sdata.retcode==0) {
MessageBeep(MB_ICONASTERISK);
if (g_warnings) SetTitle(g_hwnd,"Finished with Warnings");
else SetTitle(g_hwnd,"Finished Sucessfully");
if (g_sdata.warnings) SetTitle(g_sdata.hwnd,"Finished with Warnings");
else SetTitle(g_sdata.hwnd,"Finished Sucessfully");
}
else {
MessageBeep(MB_ICONEXCLAMATION);
SetTitle(g_hwnd,"Compile Error: See Log for Details");
SetTitle(g_sdata.hwnd,"Compile Error: See Log for Details");
}
DragAcceptFiles(g_hwnd,TRUE);
DragAcceptFiles(g_sdata.hwnd,TRUE);
return TRUE;
}
case WM_NOTIFY:
switch (((NMHDR*)lParam)->code ) {
case EN_SELCHANGE:
SendDlgItemMessage(hwndDlg,IDC_LOGWIN, EM_EXGETSEL, 0, (LPARAM) &g_chrg);
EnableMenuItem(g_mnu,IDM_COPYSELECTED,(g_chrg.cpMax-g_chrg.cpMin<=0?MF_GRAYED:MF_ENABLED));
SendDlgItemMessage(hwndDlg,IDC_LOGWIN, EM_EXGETSEL, 0, (LPARAM) &g_sdata.textrange);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,(g_sdata.textrange.cpMax-g_sdata.textrange.cpMin<=0?MF_GRAYED:MF_ENABLED));
break;
}
return TRUE;
@ -211,33 +200,33 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
{
switch (LOWORD(wParam)) {
case IDM_BROWSESCR: {
if (g_input_script) {
if (g_sdata.input_script) {
char str[MAX_PATH],*str2;
lstrcpy(str,g_input_script);
lstrcpy(str,g_sdata.input_script);
str2=strrchr(str,'\\');
if(str2!=NULL) *str2=0;
ShellExecute(g_hwnd,"open",str,NULL,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,"open",str,NULL,NULL,SW_SHOWNORMAL);
}
return TRUE;
}
case IDM_ABOUT:
{
DialogBox(g_hInstance,MAKEINTRESOURCE(DLG_ABOUT),g_hwnd,(DLGPROC)AboutProc);
DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_ABOUT),g_sdata.hwnd,(DLGPROC)AboutProc);
return TRUE;
}
case IDM_NSISHOME:
{
ShellExecute(g_hwnd,"open",NSIS_URL,NULL,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,"open",NSIS_URL,NULL,NULL,SW_SHOWNORMAL);
return TRUE;
}
case IDM_NSISDEV:
{
ShellExecute(g_hwnd,"open",NSIS_DEV,NULL,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,"open",NSIS_DEV,NULL,NULL,SW_SHOWNORMAL);
return TRUE;
}
case IDM_SELECTALL:
{
SendDlgItemMessage(g_hwnd, IDC_LOGWIN, EM_SETSEL, 0, -1);
SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_SETSEL, 0, -1);
return TRUE;
}
case IDM_DOCS:
@ -247,7 +236,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case IDM_LOADSCRIPT:
{
if (!g_hThread) {
if (!g_sdata.thread) {
OPENFILENAME l={sizeof(l),};
char buf[MAX_STRING];
l.hwndOwner = hwndDlg;
@ -261,8 +250,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
lstrcpy(buf,"");
if (GetOpenFileName(&l)) {
g_script = (char *)GlobalAlloc(GPTR,sizeof(buf)+7);
wsprintf(g_script,"/CD \"%s\"",buf);
g_sdata.script = (char *)GlobalAlloc(GPTR,sizeof(buf)+7);
wsprintf(g_sdata.script,"/CD \"%s\"",buf);
ResetObjects();
CompileNSISScript();
}
@ -271,9 +260,9 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case IDM_CLEARLOG:
{
if (!g_hThread) {
ClearLog(g_hwnd);
LogMessage(g_hwnd,USAGE);
if (!g_sdata.thread) {
ClearLog(g_sdata.hwnd);
LogMessage(g_sdata.hwnd,USAGE);
}
return TRUE;
}
@ -285,19 +274,19 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case IDM_TEST:
case IDC_TEST:
{
if (g_output_exe) {
ShellExecute(g_hwnd,"open",g_output_exe,NULL,NULL,SW_SHOWNORMAL);
if (g_sdata.output_exe) {
ShellExecute(g_sdata.hwnd,"open",g_sdata.output_exe,NULL,NULL,SW_SHOWNORMAL);
}
return TRUE;
}
case IDM_EDITSCRIPT:
{
if (g_input_script) {
if ((int)ShellExecute(g_hwnd,"open",g_input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
if (g_sdata.input_script) {
if ((int)ShellExecute(g_sdata.hwnd,"open",g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
char path[MAX_PATH];
if (GetWindowsDirectory(path,sizeof(path))) {
lstrcat(path,"\\notepad.exe");
ShellExecute(g_hwnd,"open",path,g_input_script,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,"open",path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
}
}
}
@ -306,19 +295,19 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case IDC_CLOSE:
case IDM_EXIT:
{
if (!g_hThread) {
DestroyWindow(hwndDlg);
if (!g_sdata.thread) {
DestroyWindow(g_sdata.hwnd);
}
return TRUE;
}
case IDM_COPY:
{
CopyToClipboard(g_hwnd);
CopyToClipboard(g_sdata.hwnd);
return TRUE;
}
case IDM_COPYSELECTED:
{
SendDlgItemMessage(g_hwnd,IDC_LOGWIN, WM_COPY, 0, 0);
SendDlgItemMessage(g_sdata.hwnd,IDC_LOGWIN, WM_COPY, 0, 0);
return TRUE;
}
case IDM_SAVE:
@ -337,10 +326,10 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (GetSaveFileName(&l)) {
HANDLE hFile = CreateFile(buf,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
if (hFile) {
int len=SendDlgItemMessage(g_hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
int len=SendDlgItemMessage(g_sdata.hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
char *existing_text=(char*)GlobalAlloc(GPTR,len);
existing_text[0]=0;
GetDlgItemText(g_hwnd, IDC_LOGWIN, existing_text, len);
GetDlgItemText(g_sdata.hwnd, IDC_LOGWIN, existing_text, len);
DWORD dwWritten = 0;
WriteFile(hFile,existing_text,len,&dwWritten,0);
CloseHandle(hFile);
@ -351,21 +340,21 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case IDM_FIND:
{
if (!uFindReplaceMsg) uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
my_memset(&fr, 0, sizeof(FINDREPLACE));
fr.lStructSize = sizeof(FINDREPLACE);
fr.hwndOwner = hwndDlg;
fr.Flags = FR_NOUPDOWN;
fr.lpstrFindWhat = (char *)GlobalAlloc(GPTR, 128);
if (!fr.lpstrFindWhat) return TRUE;
fr.wFindWhatLen = 128;
hwndFind = FindText(&fr);
if (!g_find.uFindReplaceMsg) g_find.uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
my_memset(&g_find.fr, 0, sizeof(FINDREPLACE));
g_find.fr.lStructSize = sizeof(FINDREPLACE);
g_find.fr.hwndOwner = hwndDlg;
g_find.fr.Flags = FR_NOUPDOWN;
g_find.fr.lpstrFindWhat = (char *)GlobalAlloc(GPTR, 128);
if (!g_find.fr.lpstrFindWhat) return TRUE;
g_find.fr.wFindWhatLen = 128;
g_find.hwndFind = FindText(&g_find.fr);
return TRUE;
}
}
}
}
if (uFindReplaceMsg && msg == uFindReplaceMsg) {
if (g_find.uFindReplaceMsg && msg == g_find.uFindReplaceMsg) {
LPFINDREPLACE lpfr = (LPFINDREPLACE)lParam;
if (lpfr->Flags & FR_FINDNEXT) {
WPARAM flags = FR_DOWN;
@ -381,7 +370,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (ft.chrg.cpMin != -1) SendDlgItemMessage(hwndDlg, IDC_LOGWIN, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax);
else MessageBeep(MB_ICONASTERISK);
}
if (lpfr->Flags & FR_DIALOGTERM) hwndFind = 0;
if (lpfr->Flags & FR_DIALOGTERM) g_find.hwndFind = 0;
return TRUE;
}
return 0;
@ -403,8 +392,8 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
else sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = true;
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
ErrorMessage(g_hwnd,"There was an error creating the pipe.");
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
ErrorMessage(g_sdata.hwnd,"There was an error creating the pipe.");
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 1;
}
GetStartupInfo(&si);
@ -412,13 +401,13 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
si.wShowWindow = SW_HIDE;
si.hStdOutput = newstdout;
si.hStdError = newstdout;
if (!CreateProcess(NULL,g_script,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
if (!CreateProcess(NULL,g_sdata.script,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
char buf[MAX_STRING];
wsprintf(buf,"Could not execute:\r\n %s.",g_script);
ErrorMessage(g_hwnd,buf);
wsprintf(buf,"Could not execute:\r\n %s.",g_sdata.script);
ErrorMessage(g_sdata.hwnd,buf);
CloseHandle(newstdout);
CloseHandle(read_stdout);
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 1;
}
char szBuf[1024];
@ -429,7 +418,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
if (dwRead) {
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
szBuf[dwRead] = 0;
LogMessage(g_hwnd, szBuf);
LogMessage(g_sdata.hwnd, szBuf);
}
else Sleep(TIMEOUT);
GetExitCodeProcess(pi.hProcess, &dwExit);
@ -439,12 +428,12 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
}
}
g_retcode = dwExit;
g_sdata.retcode = dwExit;
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
CloseHandle(newstdout);
CloseHandle(read_stdout);
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 0;
}
@ -452,28 +441,25 @@ BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused */)
{
RECT r;
GetWindowRect(hWnd, &r);
ScreenToClient(g_hwnd, (LPPOINT)&r);
ScreenToClient(g_hwnd, ((LPPOINT)&r)+1);
ScreenToClient(g_sdata.hwnd, (LPPOINT)&r);
ScreenToClient(g_sdata.hwnd, ((LPPOINT)&r)+1);
switch (GetDlgCtrlID(hWnd)) {
case IDC_LOGWIN:
SetWindowPos(hWnd, 0, r.left, r.top,r.right - r.left + dx, r.bottom - r.top + dy, SWP_NOZORDER|SWP_NOMOVE);
SetWindowPos(hWnd, 0, r.left, r.top,r.right - r.left + g_resize.dx, r.bottom - r.top + g_resize.dy, SWP_NOZORDER|SWP_NOMOVE);
break;
case IDC_TEST:
case IDC_CLOSE:
SetWindowPos(hWnd, 0, r.left + dx, r.top + dy, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
SetWindowPos(hWnd, 0, r.left + g_resize.dx, r.top + g_resize.dy, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
break;
default:
SetWindowPos(hWnd, 0, r.left, r.top + dy, r.right - r.left + dx, r.bottom - r.top, SWP_NOZORDER);
SetWindowPos(hWnd, 0, r.left, r.top + g_resize.dy, r.right - r.left + g_resize.dx, r.bottom - r.top, SWP_NOZORDER);
break;
}
RedrawWindow(hWnd,NULL,NULL,RDW_INVALIDATE);
return TRUE;
}
extern char *g_branding;
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
static HBRUSH hBrush;
switch(msg) {
case WM_INITDIALOG:
{
@ -503,21 +489,12 @@ BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
SendDlgItemMessage(hwndDlg, IDC_NSISVER, WM_SETFONT, (WPARAM)rfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_OTHERCONTRIB, WM_SETFONT, (WPARAM)rfont, FALSE);
}
SetDlgItemText(hwndDlg,IDC_NSISVER,g_branding);
SetDlgItemText(hwndDlg,IDC_NSISVER,g_sdata.branding);
SetDlgItemText(hwndDlg,IDC_ABOUTVERSION,NSISW_VERSION);
SetDlgItemText(hwndDlg,IDC_ABOUTCOPY,COPYRIGHT);
SetDlgItemText(hwndDlg,IDC_OTHERCONTRIB,CONTRIB);
break;
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORLISTBOX:
{
if(!hBrush) hBrush=CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
SetBkColor((HDC)wParam, GetSysColor(COLOR_BTNFACE));
SelectObject((HDC)wParam, hBrush);
return((LONG)hBrush);
}
case WM_COMMAND:
{
switch (LOWORD(wParam)) {

View file

@ -35,7 +35,7 @@
#define USAGE "Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSI\""
#define COPYRIGHT "Copyright © 2002 Robert Rainwater"
#define CONTRIB "Fritz Elfert, Justin Frankel, Amir Szekely"
#define DOCPATH "http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/nsis/NSIS/docs/index.html?rev=HEAD"
#define DOCPATH "http://nsis.sourceforge.net/Docs/"
#define LOCALDOCS "\\docs\\index.html"
#define NSISERROR "Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe."
#define DLGERROR "Unable to intialize MakeNSISW."
@ -55,12 +55,6 @@
// Extern Variables
extern const char* NSISW_VERSION;
extern char* g_script;
extern HWND g_hwnd;
extern HANDLE g_hThread;
extern char * g_output_exe;
extern char * g_input_script;
extern int g_retcode;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow);
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -70,4 +64,39 @@ BOOL CALLBACK AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void CompileNSISScript();
typedef struct NSISScriptData {
char *script;
char *output_exe;
char *input_script;
char *branding;
int retcode;
BOOL warnings;
BOOL appended;
HINSTANCE hInstance;
HWND hwnd;
HMENU menu;
HMENU submenu;
HANDLE thread;
CHARRANGE textrange;
} NSCRIPTDATA;
typedef struct ResizeData {
RECT resizeRect;
RECT griprect;
int dx;
int dy;
} NRESIZEDATA;
typedef struct FindReplaceDialog {
FINDREPLACE fr;
UINT uFindReplaceMsg;
HWND hwndFind;
} NFINDREPLACE;
typedef struct ToolTipStruct {
HWND tip;
HWND tip_p;
HHOOK hook;
} NTOOLTIP;
#endif

View file

@ -24,21 +24,11 @@
#include "makensisw.h"
#include "noclib.h"
char *g_branding;
char *g_output_exe;
char *g_input_script;
HWND g_tip;
HWND g_tip_p;
HHOOK g_hook;
DWORD g_dwLength;
NTOOLTIP g_tip;
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
extern BOOL g_warnings;
extern HANDLE g_hThread;
extern int g_retcode;
extern HMENU g_mnu;
static BOOL g_appended = FALSE;
extern NSCRIPTDATA g_sdata;
void SetTitle(HWND hwnd,char *substr) {
char title[64];
@ -48,7 +38,7 @@ void SetTitle(HWND hwnd,char *substr) {
}
void SetBranding(HWND hwnd) {
SetDlgItemText(hwnd, IDC_VERSION, g_branding);
SetDlgItemText(hwnd, IDC_VERSION, g_sdata.branding);
}
void CopyToClipboard(HWND hwnd) {
@ -87,29 +77,29 @@ void ErrorMessage(HWND hwnd,const char *str) {
void DisableItems(HWND hwnd) {
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),0);
EnableWindow(GetDlgItem(hwnd,IDC_TEST),0);
EnableMenuItem(g_mnu,IDM_SAVE,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_EXIT,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_LOADSCRIPT,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_COPY,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_COPYSELECTED,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_CLEARLOG,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_BROWSESCR,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_SAVE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EXIT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_COPY,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_GRAYED);
}
void EnableItems(HWND hwnd) {
#define MSG(a) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,0,0)
#define MSG1(a,b) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,0)
#define MSG2(a,b,c) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,c)
if (g_input_script) {
GlobalFree(g_input_script);
g_input_script = 0;
if (g_sdata.input_script) {
GlobalFree(g_sdata.input_script);
g_sdata.input_script = 0;
}
if (g_output_exe) {
GlobalFree(g_output_exe);
g_output_exe = 0;
if (g_sdata.output_exe) {
GlobalFree(g_sdata.output_exe);
g_sdata.output_exe = 0;
}
TEXTRANGE tr;
FINDTEXT ft;
@ -121,8 +111,8 @@ void EnableItems(HWND hwnd) {
ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Processing script file: \"");
ft.lpstrText = "\"";
tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft);
if (tr.chrg.cpMin == lstrlen("Processing script file: \"") - 1) tr.chrg.cpMax = tr.chrg.cpMin = 0;
tr.lpstrText = g_input_script = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1);
if (tr.chrg.cpMin == lstrlen("Processing script file: \"") - 1) tr.chrg.cpMax = tr.chrg.cpMin = 0;
tr.lpstrText = g_sdata.input_script = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1);
MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr);
// find output exe
@ -132,60 +122,60 @@ void EnableItems(HWND hwnd) {
ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Output: \"");
ft.lpstrText = "\"";
tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft);
if (tr.chrg.cpMin == lstrlen("Output: \"") - 1) tr.chrg.cpMax = tr.chrg.cpMin = 0;
tr.lpstrText = g_output_exe = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1);
if (tr.chrg.cpMin == lstrlen("Output: \"") - 1) tr.chrg.cpMax = tr.chrg.cpMin = 0;
tr.lpstrText = g_sdata.output_exe = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1);
MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr);
g_warnings = FALSE;
g_sdata.warnings = FALSE;
ft.lpstrText = "warning:";
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++;
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_sdata.warnings++;
ft.lpstrText = "warnings:";
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++;
if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_sdata.warnings++;
if (g_output_exe && !g_retcode) {
if (g_sdata.output_exe && !g_sdata.retcode) {
EnableWindow(GetDlgItem(hwnd,IDC_TEST),1);
EnableMenuItem(g_mnu,IDM_TEST,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_ENABLED);
}
EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),1);
EnableMenuItem(g_mnu,IDM_SAVE,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_EXIT,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_LOADSCRIPT,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_RECOMPILE,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_COPY,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_COPYSELECTED,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_EDITSCRIPT,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_CLEARLOG,MF_ENABLED);
EnableMenuItem(g_mnu,IDM_BROWSESCR,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_SAVE,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_EXIT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_COPY,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,MF_ENABLED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_ENABLED);
}
void CompileNSISScript() {
static char *s;
DragAcceptFiles(g_hwnd,FALSE);
ClearLog(g_hwnd);
SetTitle(g_hwnd,NULL);
if (lstrlen(g_script)==0) {
LogMessage(g_hwnd,USAGE);
EnableMenuItem(g_mnu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_mnu,IDM_BROWSESCR,MF_GRAYED);
EnableWindow(GetDlgItem(g_hwnd,IDC_TEST),0);
DragAcceptFiles(g_hwnd,TRUE);
DragAcceptFiles(g_sdata.hwnd,FALSE);
ClearLog(g_sdata.hwnd);
SetTitle(g_sdata.hwnd,NULL);
if (lstrlen(g_sdata.script)==0) {
LogMessage(g_sdata.hwnd,USAGE);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_TEST,MF_GRAYED);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,MF_GRAYED);
EnableWindow(GetDlgItem(g_sdata.hwnd,IDC_TEST),0);
DragAcceptFiles(g_sdata.hwnd,TRUE);
return;
}
if (!g_appended) {
if (!g_sdata.appended) {
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_appended = TRUE;
s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+lstrlen(EXENAME)+2);
wsprintf(s,"%s %s",EXENAME,g_sdata.script);
g_sdata.script = s;
g_sdata.appended = TRUE;
}
g_dwLength = 0;
// Disable buttons during compile
DisableItems(g_hwnd);
DisableItems(g_sdata.hwnd);
DWORD id;
g_hThread=CreateThread(NULL,0,MakeNSISProc,0,0,&id);
g_sdata.thread=CreateThread(NULL,0,MakeNSISProc,0,0,&id);
}
void RestoreWindowPos(HWND hwnd) {
@ -214,10 +204,10 @@ void SaveWindowPos(HWND hwnd) {
}
void ResetObjects() {
g_appended = FALSE;
g_warnings = FALSE;
g_retcode = -1;
g_hThread = NULL;
g_sdata.appended = FALSE;
g_sdata.warnings = FALSE;
g_sdata.retcode = -1;
g_sdata.thread = NULL;
}
int InitBranding() {
@ -262,8 +252,8 @@ int InitBranding() {
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);
g_sdata.branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
wsprintf(g_sdata.branding,"NSIS %s",szBuf);
GlobalFree(s);
}
return 1;
@ -271,45 +261,46 @@ int InitBranding() {
void InitTooltips(HWND h) {
if (h == NULL) return;
g_tip_p = h;
ZeroMemory(&g_tip,sizeof(NTOOLTIP));
g_tip.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());
g_tip.tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
if (!g_tip.tip) return;
g_tip.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);
UnhookWindowsHookEx(g_tip.hook);
}
void AddTip(HWND hWnd,LPSTR lpszToolTip) {
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND;
ti.hwnd = g_tip_p;
ti.hwnd = g_tip.tip_p;
ti.uId = (UINT) hWnd;
ti.lpszText = lpszToolTip;
SendMessage(g_tip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
SendMessage(g_tip.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);
if (nCode < 0) return CallNextHookEx(g_tip.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);
if (IsChild(g_tip.tip_p,((MSG*)lParam)->hwnd))
SendMessage(g_tip.tip, TTM_RELAYEVENT, 0,lParam);
break;
default:
break;
}
return CallNextHookEx(g_hook, nCode, wParam, lParam);
return CallNextHookEx(g_tip.hook, nCode, wParam, lParam);
}
void ShowDocs() {
@ -318,6 +309,6 @@ void ShowDocs() {
path=my_strrchr(pathf,'\\');
if(path!=NULL) *path=0;
lstrcat(pathf,LOCALDOCS);
if ((int)ShellExecute(g_hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
ShellExecute(g_hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
}
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
}