diff --git a/Docs/src/callback.but b/Docs/src/callback.but index b58e1b0f..6411145f 100644 --- a/Docs/src/callback.but +++ b/Docs/src/callback.but @@ -100,7 +100,7 @@ Example: Called when the selection changes on the \R{pages}{component page}. Useful for using with \R{sectionsetflags}{SectionSetFlags} and \R{sectiongetflags}{SectionGetFlags}. -Selection changes include both section selection and installation type change. +Selection changes include both section selection and installation type changes. The section id of the changed section is stored in $0. $0 is -1 if the installation type changed. You only get notifications for changes initiated by the user and only one notification per action even if the action also affected child sections and/or parent groups. \S3{onuserabort} .onUserAbort @@ -193,7 +193,7 @@ Example: Called when the selection changes on the \R{pages}{component page}. Useful for using with \R{sectionsetflags}{SectionSetFlags} and \R{sectiongetflags}{SectionGetFlags}. -Selection changes include both section selection and installation type change. +Selection changes include both section selection and installation type changes. The section id of the changed section is stored in $0. $0 is -1 if the installation type changed. You only get notifications for changes initiated by the user and only one notification per action even if the action also affected child sections and/or parent groups. \S3{unonuserabort} un.onUserAbort diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 55295a17..1db33d7f 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -1232,6 +1232,14 @@ int NSISCALL TreeGetSelectedSection(HWND tree, BOOL mouse) return (int) item.lParam; } +void NSISCALL ExecuteCallbackFunctionWithr0Int(int num,int r0) +{ + mystrcpy(g_tmp, g_usrvars[0]); + myitoa(g_usrvars[0], r0); + ExecuteCallbackFunction(num); + mystrcpy(g_usrvars[0], g_tmp); +} + static WNDPROC oldTreeWndProc; static LPARAM last_selected_tree_item; static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -1253,14 +1261,7 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l if (last_selected_tree_item != lParam) { last_selected_tree_item = lParam; - - mystrcpy(g_tmp, g_usrvars[0]); - - myitoa(g_usrvars[0], lParam); - - ExecuteCallbackFunction(CB_ONMOUSEOVERSECTION); - - mystrcpy(g_usrvars[0], g_tmp); + ExecuteCallbackFunctionWithr0Int(CB_ONMOUSEOVERSECTION,lParam); } } #endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT @@ -1269,11 +1270,12 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + const int wParamSelChangeNotifyInstTypeChanged = -1; static HTREEITEM *hTreeItems; static HIMAGELIST hImageList; HWND hwndCombo1 = GetUIItem(IDC_COMBO1); HWND hwndTree1 = GetUIItem(IDC_TREE1); - extern HWND g_SectionHack; + extern HWND g_SectionHack;// TODO: Can we remove this? section *sections=g_sections; int *install_types=g_header->install_types; if (uMsg == WM_INITDIALOG) @@ -1414,7 +1416,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar SectionFlagsChanged(secid); - wParam = 1; + wParam = secid + 1; lParam = !(g_flags & CH_FLAGS_COMP_ONLY_ON_CUSTOM); uMsg = WM_IN_UPDATEMSG; } @@ -1454,7 +1456,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar SendMessage(hwndDlg, WM_NOTIFY_INSTTYPE_CHANGED, 0, whichcfg); - wParam = 1; + wParam = wParamSelChangeNotifyInstTypeChanged; lParam = 0; uMsg = WM_IN_UPDATEMSG; } @@ -1479,9 +1481,11 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar RefreshSectionGroups(); #if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_COMPONENTPAGE) - if (wParam) + if (wParam != 0) { - ExecuteCallbackFunction(CB_ONSELCHANGE); + int secid = wParam; + if (wParamSelChangeNotifyInstTypeChanged != secid) --secid; + ExecuteCallbackFunctionWithr0Int(CB_ONSELCHANGE,secid); } #endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_COMPONENTPAGE