[PATCH v2 0/1] MR5013: msi: Properly select first feature
We need to select the first feature when all controls are created, otherwise they are not properly updated Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56290 -- v2: msi: Properly select first feature https://gitlab.winehq.org/wine/wine/-/merge_requests/5013
From: Fabian Maurer <dark.shadow4(a)web.de> We need to select the first feature when all controls are created, otherwise they are not properly updated Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56290 Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de> --- dlls/msi/dialog.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c index ba8ca526266..066dd6373b3 100644 --- a/dlls/msi/dialog.c +++ b/dlls/msi/dialog.c @@ -2415,10 +2415,9 @@ static LRESULT WINAPI MSISelectionTree_WndProc(HWND hWnd, UINT msg, WPARAM wPara static void seltree_add_child_features( MSIPACKAGE *package, HWND hwnd, const WCHAR *parent, HTREEITEM hParent ) { - struct msi_selection_tree_info *info = GetPropW( hwnd, L"MSIDATA" ); MSIFEATURE *feature; TVINSERTSTRUCTW tvis; - HTREEITEM hitem, hfirst = NULL; + HTREEITEM hitem; LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry ) { @@ -2446,9 +2445,6 @@ static void seltree_add_child_features( MSIPACKAGE *package, HWND hwnd, const WC if (!hitem) continue; - if (!hfirst) - hfirst = hitem; - seltree_sync_item_state( hwnd, feature, hitem ); seltree_add_child_features( package, hwnd, feature->Feature, hitem ); @@ -2457,10 +2453,6 @@ static void seltree_add_child_features( MSIPACKAGE *package, HWND hwnd, const WC if ( feature->Display % 2 != 0 ) SendMessageW( hwnd, TVM_EXPAND, TVE_EXPAND, (LPARAM) hitem ); } - - /* select the first item */ - SendMessageW( hwnd, TVM_SELECTITEM, TVGN_CARET | TVGN_DROPHILITE, (LPARAM) hfirst ); - info->selected = hfirst; } static void seltree_create_imagelist( HWND hwnd ) @@ -3498,6 +3490,20 @@ static UINT dialog_create_controls( MSIRECORD *rec, void *param ) return ERROR_SUCCESS; } +static void select_first_feature( msi_dialog *dialog ) +{ + struct control *control; + + LIST_FOR_EACH_ENTRY( control, &dialog->controls, struct control, entry ) + { + if (!wcscmp(control->type, L"SelectionTree")) + { + HTREEITEM first_feature = (HTREEITEM)SendMessageW( control->hwnd, TVM_GETNEXTITEM, (WPARAM)TVGN_ROOT, 0 ); + SendMessageW( control->hwnd, TVM_SELECTITEM, TVGN_CARET | TVGN_DROPHILITE, (LPARAM) first_feature ); + } + } +} + static UINT dialog_fill_controls( msi_dialog *dialog ) { UINT r; @@ -3516,6 +3522,8 @@ static UINT dialog_fill_controls( msi_dialog *dialog ) r = MSI_IterateRecords( view, 0, dialog_create_controls, dialog ); msiobj_release( &view->hdr ); + + select_first_feature(dialog); return r; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5013
Can you explain why the existing code doesn't work? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5013#note_60018
On Mon Feb 5 11:23:00 2024 +0000, Hans Leidekker wrote:
Can you explain why the existing code doesn't work? TortoiseGit creates the selection treeview first, so when the first element gets selected, the other controls can't update yet (since they don't exit).
I considered sending the control an event after they're created so they can update their contents, but that would need to duplicate the logic inside `dialog_seltree_handler`. The easiest way is to wait until all controls are created, then a selection change in the tree will be able to update all other controls properly. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5013#note_60026
Any news on this? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5013#note_74777
participants (3)
-
Fabian Maurer -
Fabian Maurer (@DarkShadow44) -
Hans Leidekker (@hans)