MakeNsisW: Functional size gripper and other minor fixes

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6368 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-05-26 19:47:22 +00:00
parent cc796c202d
commit 1cf3d5cb22
8 changed files with 202 additions and 237 deletions

View file

@ -191,11 +191,16 @@ Version History
2.3.1
- Fixed broken command line parameter handling
2.3.2
- The size gripper can be used to resize the window
Copyright Information
---------------------
Copyright (c) 2002 Robert Rainwater
Contributors: Justin Frankel, Fritz Elfert, Amir Szekely, Sunil Kamath, Joost Verburg
Contributors: Justin Frankel, Fritz Elfert, Amir Szekely,
Sunil Kamath, Joost Verburg, Anders Kjersem.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View file

@ -53,7 +53,7 @@ BuildUtil(
res = res,
resources = resources,
entry = None,
defines = ['RELEASE=2.3'],
defines = ['RELEASE=2.3.2'],
docs = docs,
root_util = True
)

View file

@ -30,12 +30,6 @@
#include "toolbar.h"
#include "update.h"
#ifdef _countof
#define COUNTOF _countof
#else
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#endif
namespace MakensisAPI {
const TCHAR* SigintEventNameFmt = _T("makensis win32 sigint event %u");
const TCHAR* SigintEventNameLegacy = _T("makensis win32 signint event");
@ -44,6 +38,7 @@ namespace MakensisAPI {
NSCRIPTDATA g_sdata;
NRESIZEDATA g_resize;
NFINDREPLACE g_find;
TCHAR g_findbuf[128];
extern NTOOLBAR g_toolbar;
int g_symbol_set_mode;
@ -64,13 +59,13 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
HINSTANCE hRichEditDLL = LoadLibrary(_T("RichEd20.dll"));
if (!InitBranding()) {
MessageBox(0,NSISERROR,_T("Error"),MB_ICONEXCLAMATION|MB_OK);
MessageBox(0,NSISERROR,ERRBOXTITLE,MB_ICONEXCLAMATION|MB_OK);
return 1;
}
ResetObjects();
HWND hDialog = CreateDialog(g_sdata.hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
if (!hDialog) {
MessageBox(0,DLGERROR,_T("Error"),MB_ICONEXCLAMATION|MB_OK);
MessageBox(0,DLGERROR,ERRBOXTITLE,MB_ICONEXCLAMATION|MB_OK);
return 1;
}
haccel = LoadAccelerators(g_sdata.hInstance, MAKEINTRESOURCE(IDK_ACCEL));
@ -85,7 +80,7 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
}
}
}
if (g_sdata.script) GlobalFree(g_sdata.script);
MemSafeFree(g_sdata.script);
if (g_sdata.script_cmd_args) GlobalFree(g_sdata.script_cmd_args);
if (g_sdata.sigint_event) CloseHandle(g_sdata.sigint_event);
if (g_sdata.sigint_event_legacy) CloseHandle(g_sdata.sigint_event_legacy);
@ -96,10 +91,7 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
void SetScript(const TCHAR *script, bool clearArgs /*= true*/)
{
if (g_sdata.script)
{
GlobalFree(g_sdata.script);
}
MemSafeFree(g_sdata.script);
if (clearArgs)
{
@ -112,7 +104,7 @@ void SetScript(const TCHAR *script, bool clearArgs /*= true*/)
g_sdata.script_cmd_args = GlobalAlloc(GHND, sizeof(TCHAR));
}
g_sdata.script = (TCHAR *) GlobalAlloc(GPTR, (lstrlen(script) + 1)*sizeof(TCHAR));
g_sdata.script = (TCHAR*) MemAlloc((lstrlen(script) + 1)*sizeof(TCHAR));
lstrcpy(g_sdata.script, script);
}
@ -173,12 +165,10 @@ void ProcessCommandLine()
}
}
}
if (argv)
GlobalFree(argv);
MemSafeFree(argv);
}
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_INITDIALOG:
{
@ -196,15 +186,15 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
RestoreMRUList();
CreateToolBar();
InitTooltips(g_sdata.hwnd);
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,_T("Courier New"));
SetDlgItemText(g_sdata.hwnd,IDC_VERSION,g_sdata.branding);
HFONT hFont = CreateFont(14,FW_NORMAL,FIXED_PITCH|FF_DONTCARE,_T("Courier New"));
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,WM_SETFONT,(WPARAM)hFont,0);
RestoreWindowPos(g_sdata.hwnd);
RestoreCompressor();
SetScript(_T(""));
g_sdata.compressor = COMPRESSOR_NONE_SELECTED;
g_sdata.userSelectCompressor = FALSE;
ProcessCommandLine();
if(g_sdata.compressor == COMPRESSOR_NONE_SELECTED) {
@ -224,12 +214,10 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case WM_PAINT:
{
PAINTSTRUCT 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);
GetGripperPos(hwndDlg, g_resize.griprect);
HDC hdc = BeginPaint(hwndDlg, &ps);
DrawFrameControl(hdc, &g_resize.griprect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
EndPaint(g_sdata.hwnd,&ps);
EndPaint(hwndDlg, &ps);
return TRUE;
}
case WM_DESTROY:
@ -266,7 +254,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
CompileNSISScript();
}
} else {
MessageBox(hwndDlg,MULTIDROPERROR,_T("Error"),MB_OK|MB_ICONSTOP);
MessageBox(hwndDlg,MULTIDROPERROR,ERRBOXTITLE,MB_OK|MB_ICONSTOP);
}
DragFinish((HDROP)wParam);
break;
@ -297,12 +285,22 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case WM_SIZING:
{
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);
InvalidateRect(hwndDlg, &g_resize.griprect, TRUE);
GetGripperPos(hwndDlg, g_resize.griprect);
return TRUE;
}
case WM_NCHITTEST:
{
RECT r = g_resize.griprect;
MapWindowPoints(hwndDlg, 0, (POINT*)&r, 2);
POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
if (PtInRect(&r, pt))
{
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, HTBOTTOMRIGHT);
return TRUE;
}
return FALSE;
}
case WM_MAKENSIS_PROCESSCOMPLETE:
{
if (g_sdata.thread) {
@ -472,8 +470,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
PCOPYDATASTRUCT cds = PCOPYDATASTRUCT(lParam);
switch (cds->dwData) {
case MakensisAPI::NOTIFY_SCRIPT:
if (g_sdata.input_script) GlobalFree(g_sdata.input_script);
g_sdata.input_script = (TCHAR *)GlobalAlloc(GPTR, cds->cbData * sizeof(TCHAR));
MemSafeFree(g_sdata.input_script);
g_sdata.input_script = (TCHAR*) MemAlloc(cds->cbData * sizeof(TCHAR));
lstrcpy(g_sdata.input_script, (TCHAR *)cds->lpData);
break;
case MakensisAPI::NOTIFY_WARNING:
@ -482,8 +480,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case MakensisAPI::NOTIFY_ERROR:
break;
case MakensisAPI::NOTIFY_OUTPUT:
if (g_sdata.output_exe) GlobalFree(g_sdata.output_exe);
g_sdata.output_exe = (TCHAR *)GlobalAlloc(GPTR, cds->cbData * sizeof(TCHAR));
MemSafeFree(g_sdata.output_exe);
g_sdata.output_exe = (TCHAR*) MemAlloc(cds->cbData * sizeof(TCHAR));
lstrcpy(g_sdata.output_exe, (TCHAR *)cds->lpData);
break;
}
@ -656,15 +654,17 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
lstrcpy(buf,_T("output"));
if (GetSaveFileName(&l)) {
HANDLE hFile = CreateFile(buf,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
if (hFile) {
if (INVALID_HANDLE_VALUE != hFile) {
int len=SendDlgItemMessage(g_sdata.hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
TCHAR *existing_text=(TCHAR*)GlobalAlloc(GPTR,len * sizeof(TCHAR));
existing_text[0]=0;
GetDlgItemText(g_sdata.hwnd, IDC_LOGWIN, existing_text, len);
DWORD dwWritten = 0;
WriteFile(hFile,existing_text,len,&dwWritten,0);
TCHAR *existing_text=(TCHAR*) MemAlloc(len * sizeof(TCHAR));
if (existing_text) { // BUGBUG:TODO: Error message for bad hFile and existing_text?
existing_text[0]=0;
GetDlgItemText(g_sdata.hwnd, IDC_LOGWIN, existing_text, len);
DWORD dwWritten = 0;
WriteFile(hFile,existing_text,len,&dwWritten,0);
MemFree(existing_text);
}
CloseHandle(hFile);
GlobalFree(existing_text);
}
}
return TRUE;
@ -676,9 +676,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
g_find.fr.lStructSize = sizeof(FINDREPLACE);
g_find.fr.hwndOwner = hwndDlg;
g_find.fr.Flags = FR_NOUPDOWN;
g_find.fr.lpstrFindWhat = (TCHAR *)GlobalAlloc(GPTR, 128 * sizeof(TCHAR));
if (!g_find.fr.lpstrFindWhat) return TRUE;
g_find.fr.wFindWhatLen = 128;
g_find.fr.lpstrFindWhat = g_findbuf;
g_find.fr.wFindWhatLen = COUNTOF(g_findbuf);
g_find.hwndFind = FindText(&g_find.fr);
return TRUE;
}
@ -815,50 +814,34 @@ BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused */)
return TRUE;
}
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_INITDIALOG:
{
HFONT bfont = CreateFont(13,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, _T("Tahoma"));
HFONT bfontb = CreateFont(13,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, _T("Tahoma"));
HFONT rfont = CreateFont(12,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
HFONT rfontb = CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
if (bfont&&bfontb) {
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)bfontb, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)bfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTPORTIONS, WM_SETFONT, (WPARAM)bfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_NSISVER, WM_SETFONT, (WPARAM)bfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_OTHERCONTRIB, WM_SETFONT, (WPARAM)bfont, FALSE);
HFONT fontnorm = CreateFont(13, FW_NORMAL, FIXED_PITCH|FF_DONTCARE, _T("Tahoma")),
fontbold = CreateFont(13, FW_BOLD, FIXED_PITCH|FF_DONTCARE, _T("Tahoma"));
if (!fontbold) {
fontnorm = CreateFont(12, FW_NORMAL, FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
fontbold = CreateFont(12, FW_BOLD, FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
}
else if (rfont&&rfontb) {
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)rfontb, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)rfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTPORTIONS, WM_SETFONT, (WPARAM)rfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_NSISVER, WM_SETFONT, (WPARAM)rfont, FALSE);
SendDlgItemMessage(hwndDlg, IDC_OTHERCONTRIB, WM_SETFONT, (WPARAM)rfont, FALSE);
}
SetDlgItemText(hwndDlg,IDC_NSISVER,g_sdata.branding);
SetDlgItemText(hwndDlg,IDC_ABOUTVERSION,NSISW_VERSION);
SetDlgItemText(hwndDlg,IDC_ABOUTCOPY,COPYRIGHT);
SetDlgItemText(hwndDlg,IDC_OTHERCONTRIB,CONTRIB);
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)fontbold, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTPORTIONS, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_NSISVER, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_OTHERCONTRIB, WM_SETFONT, (WPARAM)fontnorm, FALSE);
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_COMMAND:
{
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hwndDlg, TRUE);
break;
}
}
if (IDOK == LOWORD(wParam)) EndDialog(hwndDlg, TRUE);
break;
case WM_DESTROY:
DeleteObject((HGDIOBJ)SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_GETFONT, 0, 0));
DeleteObject((HGDIOBJ)SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_GETFONT, 0, 0));
break;
}
return FALSE;
}
@ -918,7 +901,7 @@ TCHAR **GetSymbols(HWND hwndDlg)
symbols = (TCHAR **)GlobalLock(hMem);
for (int i = 0; i < n; i++) {
int len = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)i, 0);
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, (len+1)*sizeof(TCHAR));
symbols[i] = (TCHAR*) MemAllocZI((len+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)i, (LPARAM)symbols[i]);
}
symbols[n] = NULL;
@ -927,7 +910,7 @@ TCHAR **GetSymbols(HWND hwndDlg)
return symbols;
}
BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
INT_PTR CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_INITDIALOG:
{
@ -997,23 +980,23 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXTLENGTH, 0, 0);
if(n > 0) {
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
TCHAR *buf = (TCHAR*) MemAllocZI((n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
if(_tcsstr(buf,_T(" ")) || _tcsstr(buf,_T("\t"))) {
MessageBox(hwndDlg,SYMBOLSERROR,_T("Error"),MB_OK|MB_ICONSTOP);
GlobalFree(buf);
MessageBox(hwndDlg,SYMBOLSERROR,ERRBOXTITLE,MB_OK|MB_ICONSTOP);
MemFree(buf);
break;
}
n = SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXTLENGTH, 0, 0);
if(n > 0) {
TCHAR *buf2 = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
TCHAR *buf2 = (TCHAR*) MemAllocZI((n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXT, n+1, (LPARAM)buf2);
TCHAR *buf3 = (TCHAR *)GlobalAlloc(GPTR, (lstrlen(buf)+lstrlen(buf2)+2)*sizeof(TCHAR));
TCHAR *buf3 = (TCHAR*) MemAllocZI((lstrlen(buf)+lstrlen(buf2)+2)*sizeof(TCHAR));
wsprintf(buf3,_T("%s=%s"),buf,buf2);
GlobalFree(buf);
MemFree(buf);
buf = buf3;
GlobalFree(buf2);
MemFree(buf2);
}
int idx = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_ADDSTRING, 0, (LPARAM)buf);
if (idx >= 0)
@ -1024,7 +1007,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
EnableSymbolEditButtons(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_SETTEXT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, 0);
GlobalFree(buf);
MemFree(buf);
EnableSymbolSetButtons(hwndDlg);
}
}
@ -1039,7 +1022,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if(num == 1) {
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)index, 0);
if(n > 0) {
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
TCHAR *buf = (TCHAR*) MemAllocZI((n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
TCHAR *p = _tcsstr(buf,_T("="));
if(p) {
@ -1047,7 +1030,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
*p=0;
}
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_SETTEXT, 0, (LPARAM)buf);
GlobalFree(buf);
MemFree(buf);
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_DELETESTRING, (WPARAM)index, 0);
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
@ -1063,25 +1046,21 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
case IDLOAD:
{
g_symbol_set_mode=1;
DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_SYMBOLSET),hwndDlg,(DLGPROC)SymbolSetProc);
}
break;
case IDSAVE:
{
g_symbol_set_mode=2;
g_symbol_set_mode = IDLOAD == LOWORD(wParam) ? 1 : 2;
DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_SYMBOLSET),hwndDlg,(DLGPROC)SymbolSetProc);
}
break;
case IDDEL:
{
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETSELCOUNT, 0, 0);
int *items = (int *)GlobalAlloc(GPTR, n*sizeof(int));
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETSELITEMS, (WPARAM)n, (LPARAM)items);
int i;
for(i=n-1;i>=0;i--) {
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_DELETESTRING, (WPARAM)items[i], 0);
int *items = (int*) MemAllocZI(n*sizeof(int));
if (items) {
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETSELITEMS, (WPARAM)n, (LPARAM)items);
for(int i=n-1;i>=0;i--)
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_DELETESTRING, (WPARAM)items[i], 0);
MemFree(items);
}
EnableSymbolEditButtons(hwndDlg);
EnableSymbolSetButtons(hwndDlg);
@ -1116,7 +1095,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
INT_PTR CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_INITDIALOG:
{
@ -1160,7 +1139,7 @@ BOOL CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
return FALSE;
}
BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_INITDIALOG:
{
@ -1239,12 +1218,12 @@ BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0);
if(n != CB_ERR) {
long len = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXTLEN, (WPARAM)n, 0);
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (len+1)*sizeof(TCHAR));
TCHAR *buf = (TCHAR*) MemAllocZI((len+1)*sizeof(TCHAR));
if(SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXT, (WPARAM)n, (LPARAM)buf) != CB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_DELETESTRING, n, 0);
DeleteSymbolSet(buf);
}
GlobalFree(buf);
MemFree(buf);
}
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
break;
@ -1254,12 +1233,7 @@ BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
if(HIWORD(wParam) == CBN_SELCHANGE)
{
int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0);
if(n == CB_ERR) {
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
}
else {
EnableWindow(GetDlgItem(hwndDlg, IDDEL), TRUE);
}
EnableWindow(GetDlgItem(hwndDlg, IDDEL), CB_ERR != n);
}
else if(HIWORD(wParam) == CBN_DBLCLK)
{

View file

@ -39,9 +39,10 @@
#define NSIS_DL_URL "http://nsis.sourceforge.net/download/"
#define USAGE _T("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 NSIS Script\"")
#define COPYRIGHT _T("Copyright (C) 2002 Robert Rainwater")
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg")
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg, Anders Kjersem")
#define DOCPATH "http://nsis.sourceforge.net/Docs/"
#define LOCALDOCS _T("\\NSIS.chm")
#define ERRBOXTITLE 0 //_T("Error")
#define NSISERROR _T("Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe.")
#define DLGERROR _T("Unable to intialize MakeNSISW.")
#define SYMBOLSERROR _T("Symbol cannot contain whitespace characters")
@ -155,14 +156,13 @@ int compressor_strings[] = {IDS_SCRIPT,
extern const TCHAR* NSISW_VERSION;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
DWORD WINAPI MakeNSISProc(LPVOID p);
BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
BOOL CALLBACK AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void SetScript(const TCHAR *script, bool clearArgs = true);
void CompileNSISScript();
TCHAR* BuildSymbols();

View file

@ -27,12 +27,6 @@
#include "resource.h"
#include "toolbar.h"
#ifdef _countof
#define COUNTOF _countof
#else
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#endif
NTOOLBAR g_toolbar;
extern NSCRIPTDATA g_sdata;
extern NTOOLTIP g_tip;

View file

@ -49,8 +49,7 @@ int getProxyInfo(char *out) {
DWORD CALLBACK UpdateThread(LPVOID v) {
#define RSZ 30
int len;
char *response = (char *)GlobalAlloc(GPTR,RSZ);
char *r;
char response[RSZ], *r;
char url[300];
BOOL error = FALSE;
static char pbuf[8192];
@ -72,7 +71,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
InitializeUpdate();
JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL);;
JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL);
lstrcpyA(url,NSIS_UPDATE);
lstrcatA(url,g_sdata.brandingv);
@ -107,36 +106,32 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
}
else if (*response=='1'&&lstrlenA(response)>2) {
char buf[200];
response+=2;
wsprintfA(buf, "NSIS %s is now available. Would you like to download it now?",response);
wsprintfA(buf, "NSIS %s is now available. Would you like to download it now?",response+2);
if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
ShellExecuteA(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
}
}
else if (*response=='2'&&lstrlenA(response)>2) {
char buf[200];
response+=2;
wsprintfA(buf,"NSIS %s is now available. Would you like to download this preview release now?",response);
wsprintfA(buf,"NSIS %s is now available. Would you like to download this preview release now?",response+2);
if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
ShellExecuteA(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
}
}
else MessageBoxA(g_sdata.hwnd,"There is no update available for NSIS at this time.","NSIS Update",MB_OK|MB_ICONINFORMATION);
GlobalFree(response);
delete get;
EnableMenuItem(g_sdata.menu,IDM_NSISUPDATE,MF_ENABLED);
return 0;
}
void Update() {
DWORD dwThreadId;
if (strstr(g_sdata.brandingv,"cvs"))
{
MessageBox(g_sdata.hwnd,_T("Cannot check for new version of nightly builds. To update, download a new nightly build."),_T("NSIS Update"),MB_OK|MB_ICONSTOP);
MessageBoxA(g_sdata.hwnd,"Cannot check for new version of nightly builds. To update, download a new nightly build.","NSIS Update",MB_OK|MB_ICONSTOP);
return;
}
EnableMenuItem(g_sdata.menu,IDM_NSISUPDATE,MF_GRAYED);
CloseHandle(CreateThread(NULL,0,UpdateThread,(LPVOID)NULL,0,&dwThreadId));
DWORD tid;
CloseHandle(CreateThread(NULL,0,UpdateThread,NULL,0,&tid));
}

View file

@ -27,12 +27,6 @@
#include "toolbar.h"
#include <shlwapi.h>
#ifdef _countof
#define COUNTOF _countof
#else
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#endif
NTOOLTIP g_tip;
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
@ -41,8 +35,10 @@ TCHAR g_mru_list[MRU_LIST_SIZE][MAX_PATH] = { _T(""), _T(""), _T(""), _T(""), _T
extern NSCRIPTDATA g_sdata;
extern const TCHAR *compressor_names[];
int SetArgv(const TCHAR *cmdLine, TCHAR ***argv)
{
void MemSafeFree(void*mem) { if (mem) GlobalFree(mem); }
void*MemAllocZI(SIZE_T cb) { return GlobalAlloc(GPTR, cb); }
int SetArgv(const TCHAR *cmdLine, TCHAR ***argv) {
const TCHAR *p;
TCHAR *arg, *argSpace;
int size, argSpaceSize, inquote, copy, slashes;
@ -61,7 +57,7 @@ int SetArgv(const TCHAR *cmdLine, TCHAR ***argv)
}
argSpaceSize = (size+1) * sizeof(TCHAR *) + (lstrlen(cmdLine) + 1) * sizeof(TCHAR);
argSpace = (TCHAR *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
argSpace = (TCHAR *) MemAlloc(argSpaceSize);
*argv = (TCHAR **) argSpace;
if (!argSpace)
return 0;
@ -132,10 +128,6 @@ void SetTitle(HWND hwnd,const TCHAR *substr) {
SetWindowText(hwnd,title);
}
void SetBranding(HWND hwnd) {
SetDlgItemText(hwnd, IDC_VERSION, g_sdata.branding);
}
void CopyToClipboard(HWND hwnd) {
if (!hwnd||!OpenClipboard(hwnd)) return;
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
@ -174,7 +166,7 @@ void ErrorMessage(HWND hwnd,const TCHAR *str) {
}
// Altered by Darren Owen (DrO) on 1/10/2003
void Items(HWND hwnd, int on){
void Items(HWND hwnd, int on) {
UINT mf = (!on ? MF_GRAYED : MF_ENABLED);
UINT nmf = (!on ? MF_ENABLED : MF_GRAYED);
@ -190,26 +182,25 @@ void Items(HWND hwnd, int on){
EnableWindow(GetDlgItem(hwnd,IDC_TEST),on);
EnableWindow(GetDlgItem(hwnd,IDC_RECOMPILE_TEST),on);
EnableMenuItem(g_sdata.menu,IDM_SAVE,mf);
const HMENU menu = g_sdata.menu;
EnableMenuItem(menu,IDM_CANCEL,nmf);
// Altered by Darren Owen (DrO) on 6/10/2003
if((!g_sdata.retcode && on) || !on)
EnableMenuItem(g_sdata.menu,IDM_TEST,mf);
EnableMenuItem(g_sdata.menu,IDM_EXIT,mf);
EnableMenuItem(g_sdata.menu,IDM_LOADSCRIPT,mf);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE,mf);
EnableMenuItem(g_sdata.menu,IDM_COPY,mf);
EnableMenuItem(g_sdata.menu,IDM_COPYSELECTED,mf);
EnableMenuItem(g_sdata.menu,IDM_EDITSCRIPT,mf);
EnableMenuItem(g_sdata.menu,IDM_CLEARLOG,mf);
EnableMenuItem(g_sdata.menu,IDM_BROWSESCR,mf);
EnableMenuItem(g_sdata.menu,IDM_RECOMPILE_TEST,mf);
EnableMenuItem(g_sdata.menu,IDM_COMPRESSOR,mf);
EnableMenuItem(g_sdata.menu,IDM_CANCEL,nmf);
EnableMenuItem(menu,IDM_TEST,mf);
const UINT mcmdbase = IDM_COMPRESSOR;
static const UINT8 mcmds [] = {
UINT8(IDM_SAVE-mcmdbase), UINT8(IDM_EXIT-mcmdbase), UINT8(IDM_LOADSCRIPT-mcmdbase),
UINT8(IDM_RECOMPILE-mcmdbase), UINT8(IDM_COPY-mcmdbase), UINT8(IDM_COPYSELECTED-mcmdbase),
UINT8(IDM_EDITSCRIPT-mcmdbase), UINT8(IDM_CLEARLOG-mcmdbase), UINT8(IDM_BROWSESCR-mcmdbase),
UINT8(IDM_RECOMPILE_TEST-mcmdbase), UINT8(IDM_COMPRESSOR-mcmdbase)
};
for (UINT i = 0; i < COUNTOF(mcmds); ++i)
EnableMenuItem(menu,mcmdbase+mcmds[i],mf);
EnableToolBarButton(IDM_SAVE,on);
// Altered by Darren Owen (DrO) on 6/10/2003
if((!g_sdata.retcode && on) || !on)
EnableToolBarButton(IDM_TEST,on);
EnableToolBarButton(IDM_SAVE,on);
EnableToolBarButton(IDM_EXIT,on);
EnableToolBarButton(IDM_LOADSCRIPT,on);
EnableToolBarButton(IDM_RECOMPILE,on);
@ -258,7 +249,6 @@ void SetCompressorStats()
}
void CompileNSISScript() {
static TCHAR *s;
DragAcceptFiles(g_sdata.hwnd,FALSE);
ClearLog(g_sdata.hwnd);
SetTitle(g_sdata.hwnd,NULL);
@ -282,10 +272,9 @@ void CompileNSISScript() {
return;
}
if (!g_sdata.compile_command) {
if (s) GlobalFree(s);
TCHAR *symbols = BuildSymbols();
TCHAR compressor[40];
if(lstrlen(g_sdata.compressor_name)) {
wsprintf(compressor,_T("/X\"SetCompressor /FINAL %s\""),g_sdata.compressor_name);
}
@ -304,7 +293,7 @@ void CompileNSISScript() {
/* /NOTIFYHWND + HWND */ COUNTOF(_T("/NOTIFYHWND -4294967295")) + /* space */ 1
+6); /* for -- \"\" and NULL */
g_sdata.compile_command = (TCHAR *) GlobalAlloc(GPTR, byteSize);
g_sdata.compile_command = (TCHAR*) MemAlloc(byteSize);
wsprintf(
g_sdata.compile_command,
@ -318,18 +307,18 @@ void CompileNSISScript() {
);
GlobalUnlock(g_sdata.script_cmd_args);
GlobalFree(symbols);
MemFree(symbols);
}
GlobalFree(g_sdata.input_script);
GlobalFree(g_sdata.output_exe);
MemSafeFree(g_sdata.input_script);
MemSafeFree(g_sdata.output_exe);
g_sdata.input_script = 0;
g_sdata.output_exe = 0;
g_sdata.warnings = 0;
g_sdata.logLength = 0;
// Disable buttons during compile
DisableItems(g_sdata.hwnd);
DWORD id;
g_sdata.thread=CreateThread(NULL,0,MakeNSISProc,0,0,&id);
DWORD tid;
g_sdata.thread=CreateThread(NULL,0,MakeNSISProc,0,0,&tid);
}
static bool InternalOpenRegSettingsKey(HKEY root, HKEY &key, bool create) {
@ -470,7 +459,7 @@ TCHAR** LoadSymbolSet(TCHAR *name)
if(symbols) {
l++;
DWORD bytes = sizeof(TCHAR) * l;
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, bytes);
symbols[i] = (TCHAR*) MemAllocZI(bytes);
if (symbols[i]) {
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&bytes);
}
@ -541,16 +530,11 @@ void SaveSymbolSet(TCHAR *name, TCHAR **symbols)
}
void ResetObjects() {
if (g_sdata.compile_command)
{
GlobalFree(g_sdata.compile_command);
g_sdata.compile_command = 0;
}
MemSafeFree(g_sdata.compile_command);
g_sdata.compile_command = NULL;
g_sdata.warnings = FALSE;
g_sdata.retcode = -1;
g_sdata.thread = NULL;
g_sdata.compile_command = NULL;
}
void ResetSymbols() {
@ -558,7 +542,7 @@ void ResetSymbols() {
HGLOBAL hMem;
int i = 0;
while(g_sdata.symbols[i]) {
GlobalFree(g_sdata.symbols[i]);
MemFree(g_sdata.symbols[i]);
i++;
}
hMem = GlobalHandle(g_sdata.symbols);
@ -605,39 +589,35 @@ BOOL InitSpawn(STARTUPINFO &si, HANDLE &hRd, HANDLE &hWr) {
int InitBranding() {
const TCHAR *opt = _T(" /version");
UINT cch = lstrlen(EXENAME) + lstrlen(opt) + 1;
TCHAR *s = (TCHAR *)GlobalAlloc(GPTR, cch*sizeof(TCHAR));
if (s) {
lstrcpy(s, EXENAME);
lstrcat(s, opt);
STARTUPINFO si;
HANDLE newstdout, read_stdout;
if (!InitSpawn(si, read_stdout, newstdout)) return 0;
PROCESS_INFORMATION pi;
if (!CreateProcess(0, s, 0, 0, TRUE, CREATE_NEW_CONSOLE, 0, 0, &si, &pi)) {
FreeSpawn(0, read_stdout, newstdout);
return 0;
TCHAR *cmd = (TCHAR*) MemAlloc(cch*sizeof(TCHAR));
if (!cmd) return 0;
lstrcpy(cmd, EXENAME);
lstrcat(cmd, opt);
STARTUPINFO si;
HANDLE newstdout, read_stdout;
char szBuf[1024], retval = 0;
if (InitSpawn(si, read_stdout, newstdout)) {
PROCESS_INFORMATION pi, *ppi = 0;
if (CreateProcess(0, cmd, 0, 0, TRUE, CREATE_NEW_CONSOLE, 0, 0, &si, &pi)) {
DWORD dwRead = 0;
if (WAIT_OBJECT_0 == WaitForSingleObject(pi.hProcess, 10000)) {
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
retval = 1;
}
szBuf[dwRead] = 0, ppi = &pi;
int len = lstrlenA(szBuf);
if (!len) retval = 0;
g_sdata.branding = (TCHAR*) MemAlloc((len+6)*sizeof(TCHAR)); // LEAKED
wsprintf(g_sdata.branding, _T("NSIS %hs"), szBuf);
g_sdata.brandingv = (char*) MemAlloc(len+1); // LEAKED
lstrcpyA(g_sdata.brandingv, szBuf);
}
char szBuf[1024], retval = 0;
DWORD dwRead = 0;
if (WAIT_OBJECT_0 == WaitForSingleObject(pi.hProcess, 10000)) {
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
retval = 1;
}
FreeSpawn(&pi, read_stdout, newstdout);
szBuf[dwRead] = 0;
int len = lstrlenA(szBuf);
if (len==0) retval = 0;
g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR, (len+6)*sizeof(TCHAR)); // LEAKED
wsprintf(g_sdata.branding, _T("NSIS %hs"), szBuf);
g_sdata.brandingv = (char *)GlobalAlloc(GPTR, len+1); // LEAKED
lstrcpyA(g_sdata.brandingv, szBuf);
GlobalFree(s);
return retval;
FreeSpawn(ppi, read_stdout, newstdout);
}
return 0;
MemFree(cmd);
return retval;
}
void InitTooltips(HWND h) {
if (h == NULL) return;
memset(&g_tip,0,sizeof(NTOOLTIP));
@ -701,20 +681,20 @@ TCHAR* BuildSymbols()
int i=0;
while(g_sdata.symbols[i]) {
if(buf) {
TCHAR *buf3 = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(TCHAR));
TCHAR *buf3 = (TCHAR*) MemAlloc((lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(TCHAR));
wsprintf(buf3,_T("%s \"/D%s\""),buf,g_sdata.symbols[i]);
GlobalFree(buf);
MemFree(buf);
buf = buf3;
}
else {
buf = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(g_sdata.symbols[i])+5)*sizeof(TCHAR));
buf = (TCHAR*) MemAlloc((lstrlen(g_sdata.symbols[i])+5)*sizeof(TCHAR));
wsprintf(buf,_T("\"/D%s\""),g_sdata.symbols[i]);
}
i++;
}
}
else {
buf = (TCHAR *)GlobalAlloc(GPTR, sizeof(TCHAR));
buf = (TCHAR*) MemAlloc(sizeof(TCHAR));
buf[0] = _T('\0');
}
@ -987,9 +967,7 @@ void SaveCompressor()
bool FileExists(const TCHAR *fname)
{
WIN32_FIND_DATA wfd;
HANDLE h;
h = FindFirstFile(fname,&wfd);
HANDLE h = FindFirstFile(fname,&wfd);
if(INVALID_HANDLE_VALUE != h) {
FindClose(h);
return true;
@ -999,14 +977,15 @@ bool FileExists(const TCHAR *fname)
HMENU FindSubMenu(HMENU hMenu, UINT uId)
{
MENUITEMINFO mii = {
sizeof(MENUITEMINFO),
MIIM_SUBMENU,
};
mii.hSubMenu = NULL;
GetMenuItemInfo(hMenu, uId, FALSE, &mii);
return mii.hSubMenu;
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_SUBMENU;
return GetMenuItemInfo(hMenu, uId, FALSE, &mii) ? mii.hSubMenu : 0;
}
HFONT CreateFont(int Height, int Weight, DWORD PitchAndFamily, LPCTSTR Face)
{
return CreateFont(Height, 0, 0, 0, Weight, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
PitchAndFamily, Face);
}

View file

@ -27,15 +27,25 @@
#include "resource.h"
#include "toolbar.h"
#ifdef _countof
#define COUNTOF _countof
#else
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#endif
#define MRU_LIST_SIZE 5
#define MRU_DISPLAY_LENGTH 40
void* MemAllocZI(SIZE_T cb);
void MemSafeFree(void*mem);
#define MemAlloc MemAllocZI
#define MemFree MemSafeFree
void FreeSpawn(PROCESS_INFORMATION *pPI, HANDLE hRd, HANDLE hWr);
BOOL InitSpawn(STARTUPINFO &si, HANDLE &hRd, HANDLE &hWr);
int SetArgv(const TCHAR *cmdLine, TCHAR ***argv);
void SetTitle(HWND hwnd,const TCHAR *substr);
void SetBranding(HWND hwnd);
void CopyToClipboard(HWND hwnd);
void ClearLog(HWND hwnd);
void LogMessage(HWND hwnd,const TCHAR *str);
@ -68,4 +78,12 @@ void ClearMRUList();
bool FileExists(const TCHAR *fname);
HMENU FindSubMenu(HMENU hMenu, UINT uId);
HFONT CreateFont(int Height, int Weight, DWORD PitchAndFamily, LPCTSTR Face);
inline void GetGripperPos(HWND hwnd, RECT&r)
{
GetClientRect(hwnd, &r);
r.left = r.right - GetSystemMetrics(SM_CXVSCROLL);
r.top = r.bottom - GetSystemMetrics(SM_CYVSCROLL);
}
#endif