diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index 02d5085c4d5..2a213fcd473 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -4388,10 +4388,18 @@ static INT TREEVIEW_ProcessLetterKeys( idx=infoPtr->root->firstChild; } do { + /* At the end point, sort out wrapping */ if (idx == NULL) { + + /* If endidx is null, stop at the last item (ie top to bottom) */ if (endidx == NULL) break; + + /* Otherwise, start again at the very beginning */ idx=infoPtr->root->firstChild; + + /* But if we are stopping on the first child, end now! */ + if (idx == endidx) break; } /* get item */