Cancel button available on all pages after the instfiles page but the last page unless /ENABLECANCEL was used in its Page command

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2246 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-03-06 21:24:19 +00:00
parent 267e7ebfb6
commit b97418269b
6 changed files with 50 additions and 20 deletions

View file

@ -313,6 +313,8 @@ CEXEBuild::CEXEBuild()
build_last_page_define[0]=0;
ubuild_last_page_define[0]=0;
enable_last_page_cancel=0;
uenable_last_page_cancel=0;
notify_hwnd=0;
}
@ -1392,8 +1394,11 @@ int CEXEBuild::write_output(void)
page *p=(page *) build_pages.get();
for (int i=0; i<build_header.common.num_pages; i++, p++) {
if (i) p->back=SW_SHOWNA|2; // 2 - enabled, SW_SHOWNA - visible, 0 - invisible (or'ed)
else p->back=0;
// 2 - back enabled
// 4 - cancel enabled
// SW_SHOWNA (8) - back visible
if (i) p->button_states=SW_SHOWNA|2|4;
else p->button_states=4;
p->next=LANG_BTN_NEXT;
@ -1406,13 +1411,16 @@ int CEXEBuild::write_output(void)
p->next=LANG_BTN_LICENSE;
#endif
if (p->id==NSIS_PAGE_INSTFILES || p->id==NSIS_PAGE_COMPLETED)
p->back&=~2;
p->button_states&=~6;
if (i && (p-1)->id==NSIS_PAGE_COMPLETED)
p->back&=~2;
p->button_states&=~2;
if (p->next == LANG_BTN_NEXT) next_used = true;
}
(--p)->next=LANG_BTN_CLOSE;
if (!enable_last_page_cancel) {
p->button_states&=~4;
}
if (p->id==NSIS_PAGE_COMPLETED) (--p)->next=LANG_BTN_CLOSE;
}
#ifdef NSIS_CONFIG_SILENT_SUPPORT
@ -1473,8 +1481,11 @@ int CEXEBuild::write_output(void)
page *p=(page *) ubuild_pages.get();
int noinstlogback=0;
for (int i=0; i<build_uninst.common.num_pages; i++, p++) {
if (i) p->back=SW_SHOWNA|2; // 2 - enabled, SW_SHOWNA - visible, 0 - invisible (or'ed)
else p->back=0;
// 2 - back enabled
// 4 - cancel enabled
// SW_SHOWNA (8) - back visible
if (i) p->button_states=SW_SHOWNA|2|4;
else p->button_states=4;
p->next=LANG_BTN_NEXT;
@ -1484,11 +1495,16 @@ int CEXEBuild::write_output(void)
p->next=LANG_BTN_UNINST;
}
if (p->id==NSIS_PAGE_INSTFILES || p->id==NSIS_PAGE_COMPLETED)
p->back=noinstlogback?0:SW_SHOWNA;
p->button_states=noinstlogback?0:SW_SHOWNA;
if (i && (p-1)->id==NSIS_PAGE_COMPLETED)
p->button_states&=~2;
if (p->next == LANG_BTN_NEXT) next_used = true;
}
(--p)->next=LANG_BTN_CLOSE;
if (!uenable_last_page_cancel) {
p->button_states&=~4;
}
if (p->id==NSIS_PAGE_COMPLETED) (--p)->next=LANG_BTN_CLOSE;
}
#ifdef NSIS_CONFIG_SILENT_SUPPORT

View file

@ -220,8 +220,8 @@ class CEXEBuild {
GrowBuf build_pages, ubuild_pages;
char build_last_page_define[1024], ubuild_last_page_define[1024];
int build_custom_used, ubuild_custom_used;
int enable_last_page_cancel, uenable_last_page_cancel;
MMapBuf build_datablock, ubuild_datablock; // use GrowBuf here instead of MMapBuf if you want
IGrowBuf *cur_datablock;

View file

@ -545,9 +545,10 @@ nextPage:
hwndtmp=GetDlgItem(hwndDlg,IDC_BACK);
SendMessage(g_hwnd,DM_SETDEFID,IDOK,0);
SetWindowLong(hwndtmp,GWL_STYLE,GetWindowLong(hwndtmp,GWL_STYLE)&~BS_DEFPUSHBUTTON);
ShowWindow(hwndtmp,this_page->back&SW_SHOWNA);// SW_HIDE = 0
EnableWindow(hwndtmp,this_page->back&2);
ShowWindow(hwndtmp,this_page->button_states&SW_SHOWNA);// SW_HIDE = 0, SW_SHOWNA = 8
EnableWindow(hwndtmp,this_page->button_states&2);
EnableWindow(m_hwndOK,1);
EnableWindow(m_hwndCancel,this_page->button_states&4);
mystrcpy(g_tmp,g_caption);
process_string_fromtab(g_tmp+mystrlen(g_tmp),this_page->caption);
@ -1389,7 +1390,6 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
EnableWindow(m_hwndOK,0);
EnableWindow(m_hwndCancel,0);
}
if (uMsg == WM_NOTIFY_START) {
DWORD id;

View file

@ -470,7 +470,7 @@ typedef struct
#endif //NSIS_SUPPORT_CODECALLBACKS
int caption; // caption tab
int next;
int back;
int button_states;
} page;
// the following are only used/implemented in exehead, not makensis.

View file

@ -562,6 +562,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
{
SCRIPT_MSG("Page: %s", line.gettoken_str(1));
enable_last_page_cancel = 0;
if (!stricmp(line.gettoken_str(line.getnumtokens()-1),"/ENABLECANCEL"))
enable_last_page_cancel = 1;
int k = line.gettoken_enum(1,"custom\0license\0components\0directory\0instfiles");
page p = {
0,
@ -587,7 +591,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
if (k) {
// not custom
#ifdef NSIS_SUPPORT_CODECALLBACKS
switch (line.getnumtokens()) {
switch (line.getnumtokens() - enable_last_page_cancel) {
case 7:
PRINTHELP();
case 6:
if (k != 4) {
lstrcpy(build_last_page_define, line.gettoken_str(5));
@ -603,14 +609,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
p.prefunc = ns_func.add(line.gettoken_str(2),0);
}
#else
if (line.getnumtokens() == 3)
if (line.getnumtokens() - enable_last_page_cancel == 3)
lstrcpy(build_last_page_define, line.gettoken_str(2));
#endif//NSIS_SUPPORT_CODECALLBACKS
}
#ifdef NSIS_SUPPORT_CODECALLBACKS
else {
// a custom page
switch (line.getnumtokens()) {
switch (line.getnumtokens() - enable_last_page_cancel) {
case 7:
case 6:
ERROR_MSG("Error: custom page can not have more than the creator function.\n");
return PS_ERROR;
@ -698,6 +705,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
{
SCRIPT_MSG("UninstPage: %s", line.gettoken_str(1));
uenable_last_page_cancel = 0;
if (!stricmp(line.gettoken_str(line.getnumtokens()-1),"/ENABLECANCEL"))
uenable_last_page_cancel = 1;
int k = line.gettoken_enum(1,"custom\0uninstConfirm\0instfiles");
page p = {
0,
@ -723,7 +734,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
if (k) {
// not custom
#ifdef NSIS_SUPPORT_CODECALLBACKS
switch (line.getnumtokens()) {
switch (line.getnumtokens() - uenable_last_page_cancel) {
case 7:
PRINTHELP();
case 6:
if (k != 2) {
lstrcpy(ubuild_last_page_define, line.gettoken_str(5));
@ -754,14 +767,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
}
}
#else
if (line.getnumtokens() == 3)
if (line.getnumtokens() - uenable_last_page_cancel == 3)
lstrcpy(ubuild_last_page_define, line.gettoken_str(2));
#endif//NSIS_SUPPORT_CODECALLBACKS
}
#ifdef NSIS_SUPPORT_CODECALLBACKS
else {
// a custom page
switch (line.getnumtokens()) {
switch (line.getnumtokens() - uenable_last_page_cancel) {
case 7:
case 6:
ERROR_MSG("Error: custom page can not have more than the creator function.\n");
return PS_ERROR;

View file

@ -107,7 +107,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_NAME,"Name",1,1,"[/LANG=lang_id] installer_name"},
{TOK_OUTFILE,"OutFile",1,0,"install_output.exe"},
#ifdef NSIS_SUPPORT_CODECALLBACKS
{TOK_PAGE,"Page",1,4,"(custom function [caption]) | ((license|components|directory|instfiles) [pre_function] [show_function] [leave_function])"},
{TOK_PAGE,"Page",1,5,"(custom function [caption]) | ((license|components|directory|instfiles) [pre_function] [show_function] [leave_function])"},
#else
{TOK_PAGE,"Page",1,1,"license|components|directory|instfiles"},
#endif
@ -165,7 +165,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_UNINSTCAPTION,"UninstallCaption",1,1,"[/LANG=lang_id] uninstaller_caption"},
{TOK_UNINSTICON,"UninstallIcon",1,0,"icon_on_local_system.ico"},
#ifdef NSIS_SUPPORT_CODECALLBACKS
{TOK_UNINSTPAGE,"UninstPage",1,4,"(custom function [caption]) | ((uninstConfirm|instfiles) [pre_function] [show_function] [leave_function])"},
{TOK_UNINSTPAGE,"UninstPage",1,5,"(custom function [caption]) | ((uninstConfirm|instfiles) [pre_function] [show_function] [leave_function])"},
#else
{TOK_UNINSTPAGE,"UninstPage",1,1,"uninstConfirm|instfiles"},
#endif