Leave function for custom pages too

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2335 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-03-18 15:45:25 +00:00
parent 156648c9d5
commit 070d1f136a
10 changed files with 81 additions and 56 deletions

View file

@ -605,17 +605,27 @@ LRESULT WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
static void *lpWndProcOld;
static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_NOTIFY_OUTER_NEXT)
{
PostMessage(hConfigWindow,WM_USER+666,wParam,0);
}
return CallWindowProc((long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long))lpWndProcOld,hwnd,message,wParam,lParam);
}
int g_is_cancel,g_is_back;
BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
BOOL bRes;
if (message == WM_NOTIFY_OUTER_NEXT && wParam == 1)
// Get the settings ready for the leave function verification
SaveSettings();
bRes = CallWindowProc((long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long))lpWndProcOld,hwnd,message,wParam,lParam);
if (message == WM_NOTIFY_OUTER_NEXT && !bRes)
{
// if leave function didn't abort (lRes != 0 in that case)
if (wParam == NOTIFY_BYE_BYE || wParam == -1 || ValidateFields()) {
if (wParam == -1) g_is_back++;
if (wParam == NOTIFY_BYE_BYE) g_is_cancel++;
g_done++;
PostMessage(hConfigWindow,WM_CLOSE,0,0);
}
}
return bRes;
}
BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
UINT uMsg,
@ -625,15 +635,6 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
switch (uMsg)
{
HANDLE_MSG(hwndDlg, WM_COMMAND, WMCommandProc);
return 0;
case WM_USER+666:
if (wParam == NOTIFY_BYE_BYE || wParam == -1 || ValidateFields()) {
if (wParam == -1) g_is_back++;
if (wParam == NOTIFY_BYE_BYE) g_is_cancel++;
g_done++;
PostMessage(hwndDlg,WM_CLOSE,0,0);
}
break;
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORDLG:
SetBkMode((HDC)wParam, TRANSPARENT);
@ -962,7 +963,7 @@ int createCfgDlg()
void showCfgDlg()
{
lpWndProcOld = (void *) SetWindowLong(hMainWindow,GWL_WNDPROC,(long)ParentWndProc);
lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc);
SendMessage(hMainWindow, WM_NOTIFY_CUSTOM_READY, 0, 0);
ShowWindow(hConfigWindow, SW_SHOWNA);
@ -982,7 +983,7 @@ void showCfgDlg()
if (!g_is_cancel) SaveSettings();
if (lpWndProcOld)
SetWindowLong(hMainWindow,GWL_WNDPROC,(long)lpWndProcOld);
SetWindowLong(hMainWindow,DWL_DLGPROC,(long)lpWndProcOld);
DestroyWindow(hConfigWindow);
if (was_ok_enabled) EnableWindow(hNextButton,0);
SetWindowText(hCancelButton,old_cancel);

View file

@ -10,6 +10,9 @@ Name "InstallOptions Test"
;The file to write
OutFile "Test.exe"
; Show install details
ShowInstDetails show
;Things that need to be extracted on startup (keep these lines before any File command!)
;Only useful for BZIP2 compression
;Use ReserveFile for your own InstallOptions INI files too!
@ -18,7 +21,7 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "test.ini"
;Order of pages
Page custom SetCustom ": Testing InstallOptions" ;Custom page. InstallOptions gets called in SetCustom.
Page custom SetCustom VerifyCustom ": Testing InstallOptions" ;Custom page. InstallOptions gets called in SetCustom.
Page instfiles
Section "Components"
@ -26,15 +29,15 @@ Section "Components"
;Get Install Options dialog user input
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 2" "State"
MessageBox MB_OK "Install X=${TEMP1}"
DetailPrint "Install X=${TEMP1}"
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 3" "State"
MessageBox MB_OK "Install Y=${TEMP1}"
DetailPrint "Install Y=${TEMP1}"
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 4" "State"
MessageBox MB_OK "Install Z=${TEMP1}"
DetailPrint "Install Z=${TEMP1}"
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 5" "State"
MessageBox MB_OK "File=${TEMP1}"
DetailPrint "File=${TEMP1}"
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 6" "State"
MessageBox MB_OK "Dir=${TEMP1}"
DetailPrint "Dir=${TEMP1}"
SectionEnd
@ -59,4 +62,16 @@ Function SetCustom
Pop ${TEMP1}
FunctionEnd
Function VerifyCustom
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 2" "State"
StrCmp ${TEMP1} 1 done
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 3" "State"
StrCmp ${TEMP1} 1 done
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 4" "State"
StrCmp ${TEMP1} 1 done
MessageBox MB_ICONSTOP|MB_OK "You must select at least one install option!"
Abort
done:
FunctionEnd