Even easier paging system, no more Abort and Quit from custom pages creator functions, NSIS does it all!

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1636 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-11-09 12:50:00 +00:00
parent 35b45db225
commit 297e981d32
17 changed files with 123 additions and 335 deletions

View file

@ -282,10 +282,8 @@ Here is a little example:
InstallOptions::show
Pop $0
StrCmp $0 "success" done
StrCmp $0 "back" 0 +2
Abort
StrCmp $0 "cancel" 0 error
Quit
StrCmp $0 "back" done
StrCmp $0 "cancel" done
error:
MessageBox MB_OK|MB_ICONSTOP "IO error: $0"
Quit
@ -404,8 +402,8 @@ Here is a little example:
<UL>
<LI>Barely qualifies as a distribution. </LI></UL></LI></UL>
<HR>
<A name=license><PRE> Copyright © 2001 Michael Bishop
Portions Copyright © 2001 Nullsoft, Inc.
<A name=license><PRE> Copyright &copy; 2001 Michael Bishop
Portions Copyright &copy; 2001 Nullsoft, Inc.
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

@ -165,12 +165,9 @@ HINSTANCE m_hInstance = NULL;
char *pszFilename = NULL;
char *pszTitle = NULL;
char *pszCancelQuestion = NULL;
char *pszCancelQuestionCaption = NULL;
char *pszCancelButtonText = NULL;
char *pszNextButtonText = NULL;
char *pszBackButtonText = NULL;
unsigned int nCancelConfirmFlags=0;
BOOL bBackDisabled=FALSE;
BOOL bCancelEnabled=TRUE; // by ORTIM: 13-August-2002
@ -455,36 +452,12 @@ char * WINAPI myGetProfileStringDup(LPCTSTR lpAppName, LPCTSTR lpKeyName)
bool ReadSettings(void) {
static char szField[25];
int nIdx;
// Messagebox flags
static TableEntry MBFlagTable[] = {
{ "MB_ICONEXCLAMATION", MB_ICONEXCLAMATION },
// { "MB_ICONWARNING", MB_ICONWARNING }, // same as above
{ "MB_ICONINFORMATION", MB_ICONINFORMATION },
// { "MB_ICONASTERISK", MB_ICONASTERISK }, // same as above
{ "MB_ICONQUESTION", MB_ICONQUESTION },
{ "MB_ICONSTOP", MB_ICONSTOP },
// { "MB_ICONERROR", MB_ICONERROR }, // same as above
// { "MB_ICONHAND", MB_ICONHAND }, // same as above
{ "MB_TOPMOST", MB_TOPMOST },
{ "MB_SETFOREGROUND", MB_SETFOREGROUND },
{ "MB_RIGHT", MB_RIGHT },
{ "MB_DEFBUTTON1", MB_DEFBUTTON1 },
{ "MB_DEFBUTTON2", MB_DEFBUTTON2 },
// { "MB_DEFBUTTON3", MB_DEFBUTTON3 }, // useless, as there are only two buttons
// { "MB_DEFBUTTON4", MB_DEFBUTTON4 }, // useless, as there are only two buttons
{ NULL, 0 }
};
pszTitle = myGetProfileStringDup("Settings", "Title");
pszCancelQuestion = myGetProfileStringDup("Settings", "CancelConfirm");
pszCancelQuestionCaption = myGetProfileStringDup("Settings", "CancelConfirmCaption");
pszCancelButtonText = myGetProfileStringDup("Settings", "CancelButtonText");
pszNextButtonText = myGetProfileStringDup("Settings", "NextButtonText");
pszBackButtonText = myGetProfileStringDup("Settings", "BackButtonText");
myGetProfileString("Settings", "CancelConfirmFlags");
nCancelConfirmFlags = LookupTokens(MBFlagTable, szResult);
nNumFields = GetPrivateProfileInt("Settings", "NumFields", 0, pszFilename);
bBackDisabled = GetPrivateProfileInt("Settings", "BackDisabled", 0, pszFilename);
@ -671,15 +644,9 @@ static void *lpWndProcOld;
static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CLOSE)
if (message == WM_NOTIFY_OUTER_NEXT)
{
message = WM_COMMAND;
wParam = IDCANCEL;
}
if (message == WM_COMMAND && (LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDOK || LOWORD(wParam) == 3))
{
PostMessage(hConfigWindow,WM_USER+666,0,LOWORD(wParam));
return 0;
PostMessage(hConfigWindow,WM_USER+666,wParam,0);
}
return CallWindowProc((long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long))lpWndProcOld,hwnd,message,wParam,lParam);
}
@ -697,14 +664,11 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
HANDLE_MSG(hwndDlg, WM_COMMAND, WMCommandProc);
return 0;
case WM_USER+666:
if (lParam != IDCANCEL || !pszCancelQuestion || MessageBox(hwndDlg,pszCancelQuestion,pszCancelQuestionCaption?pszCancelQuestionCaption:"Question",MB_YESNO|nCancelConfirmFlags)==IDYES)
{
if (lParam == IDCANCEL || lParam == 3 || ValidateFields()) {
if (lParam == 3) g_is_back++;
if (lParam == IDCANCEL) g_is_cancel++;
g_done++;
PostMessage(hwndDlg,WM_CLOSE,0,0);
}
if (wParam == 0xD1E || wParam == -1 || ValidateFields()) {
if (wParam == -1) g_is_back++;
if (wParam == 0xD1E) g_is_cancel++;
g_done++;
PostMessage(hwndDlg,WM_CLOSE,0,0);
}
break;
case WM_CTLCOLORSTATIC:
@ -1036,8 +1000,6 @@ void showCfgDlg()
if (cw_vis) ShowWindow(childwnd,SW_SHOWNA);
FREE(pszTitle);
FREE(pszCancelQuestion);
FREE(pszCancelQuestionCaption);
FREE(pszCancelButtonText);
FREE(pszNextButtonText);
FREE(pszBackButtonText);

View file

@ -61,21 +61,22 @@ FunctionEnd
Function SetCustom
;Display the Install Options dialog
;Display the Install Options dialog
Push ${TEMP1}
Push ${TEMP1}
InstallOptions::dialog "$PLUGINSDIR\test.ini"
Pop ${TEMP1}
StrCmp ${TEMP1} "cancel" "" +3
Pop ${TEMP1}
Quit
StrCmp ${TEMP1} "cancel" done
StrCmp ${TEMP1} "back" done
StrCmp ${TEMP1} "success" 0 error
# User clicked Next, all fields validated, read stuff from the INI here or later
Goto done
error:
MessageBox MB_OK|MB_ICONSTOP "InstallOptions error:$\r$\n${TEMP1}"
done: Pop ${TEMP1}
StrCmp ${TEMP1} "back" "" +3
Pop ${TEMP1}
Abort
Pop ${TEMP1}
FunctionEnd