Added /checknoshortcuts

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1669 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-11-11 17:17:33 +00:00
parent e6ed3bdf82
commit 89ddb8a245
6 changed files with 71 additions and 57 deletions

View file

@ -19,7 +19,7 @@ FunctionEnd
Page custom StartMenuGroupSelect ": Start Menu Folder"
Function StartMenuGroupSelect
StartMenu::Select /autoadd /lastused $R0 "StartMenu.dll test"
StartMenu::Select /checknoshortcuts "Don't create a start menu folder" /autoadd /lastused $R0 "StartMenu.dll test"
Pop $R1
StrCpy $R2 $R1 5
@ -33,10 +33,16 @@ FunctionEnd
Page instfiles
Section
CreateDirectory $SMPROGRAMS\$R0
CreateShortCut $SMPROGRAMS\$R0\MakeNSIS.lnk $INSTDIR\makensis.exe
# this part is only necessary if you used /checknoshortcuts
StrCpy $R1 $R0 1
StrCmp $R1 ">" skip
SetShellVarContext All
CreateDirectory $SMPROGRAMS\$R0
CreateShortCut "$SMPROGRAMS\$R0\All users MakeNSIS.lnk" $INSTDIR\makensis.exe
CreateDirectory $SMPROGRAMS\$R0
CreateShortCut $SMPROGRAMS\$R0\MakeNSIS.lnk $INSTDIR\makensis.exe
SetShellVarContext All
CreateDirectory $SMPROGRAMS\$R0
CreateShortCut "$SMPROGRAMS\$R0\All users MakeNSIS.lnk" $INSTDIR\makensis.exe
skip:
SectionEnd

View file

@ -9,7 +9,11 @@ which is the program group default name, and some more optional parameters:
"Select the Start Menu folder in which..."
/lastused [folder] - sets the edit box to a specific value folder.
Use this to make this plug-in remember the last
folder selected by the user
folder selected by the user
/checknoshortcuts text - Shows a check box with the text "text". If
the user checks this box, the return value
will have ^ as its first character and you
should not create the program group.
The function pushes the folder selection back to the stack. It does not push the
full path but only the selected sub-folder. It's up to you to decide if to put

View file

@ -13,11 +13,13 @@ HWND hwIcon;
HWND hwText;
HWND hwLocation;
HWND hwDirList;
HWND hwCheckBox;
char buf[MAX_PATH];
char text[1024];
char progname[1024];
char lastused[1024];
char checkbox[1024];
int autoadd = 0;
int g_done = 0;
@ -25,17 +27,10 @@ int noicon = 0;
void *lpWndProcOld;
typedef struct {
char *pszName;
int nValue;
} TableEntry;
BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void AddFolderFromReg(char *name, HKEY rootKey);
void PopulateListWithDir(char *dir);
int LookupToken(TableEntry*, char*);
int LookupTokens(TableEntry*, char*);
void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
{
@ -74,6 +69,10 @@ void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variab
{
popstring(lastused);
}
else if (!lstrcmpi(buf+1, "checknoshortcuts"))
{
popstring(checkbox);
}
if (popstring(buf))
*buf = 0;
}
@ -143,7 +142,7 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
case WM_INITDIALOG:
{
RECT dialog_r, temp_r, icon_r;
RECT dialog_r, temp_r;
HFONT hFont = (HFONT)SendMessage(hwParent, WM_GETFONT, 0, 0);
@ -166,12 +165,14 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
hwText = GetDlgItem(hwndDlg, IDC_TEXT);
hwLocation = GetDlgItem(hwndDlg, IDC_LOCATION);
hwDirList = GetDlgItem(hwndDlg, IDC_DIRLIST);
hwCheckBox = GetDlgItem(hwndDlg, IDC_CHECK);
SendMessage(hwndDlg, WM_SETFONT, (WPARAM) hFont, TRUE);
SendMessage(hwIcon, WM_SETFONT, (WPARAM) hFont, TRUE);
SendMessage(hwText, WM_SETFONT, (WPARAM) hFont, TRUE);
SendMessage(hwLocation, WM_SETFONT, (WPARAM) hFont, TRUE);
SendMessage(hwDirList, WM_SETFONT, (WPARAM) hFont, TRUE);
SendMessage(hwCheckBox, WM_SETFONT, (WPARAM) hFont, TRUE);
if (!noicon)
{
@ -195,16 +196,16 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (!*text)
lstrcpy(text, "Select the Start Menu folder in which you would like to create the program's shortcuts:");
GetWindowRect(hwIcon, &icon_r);
icon_r.right += 5;
icon_r.bottom += 5;
ScreenToClient(hwndDlg, ((LPPOINT) &icon_r) + 1);
GetWindowRect(hwIcon, &temp_r);
temp_r.right += 5;
temp_r.bottom += 5;
ScreenToClient(hwndDlg, ((LPPOINT) &temp_r) + 1);
ProgressiveSetWindowPos(
hwText,
noicon ? 0 : icon_r.right,
dialog_r.right - dialog_r.left - (noicon ? 0 : icon_r.right),
icon_r.bottom + 2
noicon ? 0 : temp_r.right,
dialog_r.right - dialog_r.left - (noicon ? 0 : temp_r.right),
temp_r.bottom + 2
);
SendMessage(hwText, WM_SETTEXT, 0, (LPARAM) text);
@ -218,15 +219,39 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
temp_r.bottom - temp_r.top
);
if (*lastused == '>')
{
SendMessage(hwCheckBox, BM_SETCHECK, BST_CHECKED, 0);
lstrcpy(buf, lastused);
lstrcpy(lastused, buf + 1);
}
SendMessage(hwLocation, WM_SETTEXT, 0, (LPARAM) (*lastused ? lastused : progname));
GetWindowRect(hwCheckBox, &temp_r);
ScreenToClient(hwndDlg, ((LPPOINT) &temp_r));
ScreenToClient(hwndDlg, ((LPPOINT) &temp_r) + 1);
ProgressiveSetWindowPos(
hwDirList,
0,
dialog_r.right - dialog_r.left,
dialog_r.bottom - dialog_r.top - y_offset
dialog_r.bottom - dialog_r.top - y_offset - (*checkbox ? temp_r.bottom - temp_r.top + 5 : 0)
);
ProgressiveSetWindowPos(
hwCheckBox,
0,
dialog_r.right - dialog_r.left,
temp_r.bottom - temp_r.top
);
if (*checkbox)
{
ShowWindow(hwCheckBox, SW_SHOWNA);
SendMessage(hwCheckBox, WM_SETTEXT, 0, (LPARAM) checkbox);
}
AddFolderFromReg("Programs", HKEY_LOCAL_MACHINE);
AddFolderFromReg("Programs", HKEY_CURRENT_USER);
@ -252,7 +277,13 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
pushstring("cancel");
else
{
SendMessage(hwLocation, WM_GETTEXT, MAX_PATH, (LPARAM) buf);
if (SendMessage(hwCheckBox, BM_GETCHECK, 0, 0) == BST_CHECKED)
{
buf[0] = '>';
buf[1] = 0;
}
else *buf = 0;
SendMessage(hwLocation, WM_GETTEXT, MAX_PATH, (LPARAM) buf + lstrlen(buf));
pushstring(buf);
}
break;
@ -323,34 +354,4 @@ void PopulateListWithDir(char *dir)
}
}
} while (FindNextFile(hSearch, &FileData));
}
int LookupToken(TableEntry* psTable_, char* pszToken_)
{
int i;
for (i = 0; psTable_[i].pszName; i++)
if (!lstrcmpi(pszToken_, psTable_[i].pszName))
return psTable_[i].nValue;
return 0;
}
int LookupTokens(TableEntry* psTable_, char* pszTokens_)
{
int n = 0;
char *pszStart = pszTokens_;
char *pszEnd = pszTokens_;
for (;;) {
if (*pszEnd == '\0') {
n |= LookupToken(psTable_, pszStart);
break;
}
if (*pszEnd == '|') {
*pszEnd = '\0';
n |= LookupToken(psTable_, pszStart);
*pszEnd = '|';
pszStart = pszEnd + 1;
}
pszEnd++;
}
return n;
}
}

View file

@ -35,7 +35,9 @@ BEGIN
WS_CLIPSIBLINGS
LTEXT "",IDC_TEXT,17,65,55,11,WS_CLIPSIBLINGS
LISTBOX IDC_DIRLIST,76,42,48,40,LBS_SORT | LBS_NOINTEGRALHEIGHT |
WS_CLIPSIBLINGS | WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY
WS_CLIPSIBLINGS | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE |
WS_TABSTOP,21,44,16,8
END

View file

@ -7,6 +7,7 @@
#define IDC_LOCATION 1002
#define IDC_TEXT 1003
#define IDC_DIRLIST 1004
#define IDC_CHECK 1005
// Next default values for new objects
//
@ -14,7 +15,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1005
#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.