0

Hello!

It's about SHBrowseForFolder again. Thanks to I've made a lot of progress on Charlieface, but there's still something missing for the final touch.

In the BFFCALLBACK BrowseCallbackProc I select the select item. Can I still send a TVM_ENSUREVISIBLE message at this point so that I can move the selected entry to the visible area of the tree view? (I couldn't do that because I'm missing the pointer to the selected entry [the result of BFFM_SETSELECTIONW].)

In my post: I described that I used a launcher to get the dialog window and then the tree view. At this point I can move the selected item into the visible area.

SendMessage(hwndTV, TVM_SELECTITEM, new IntPtr(TVGN_CARET), SelectItem); // Select directory
SendMessage(hwndTV, TVM_ENSUREVISIBLE, IntPtr.Zero, SelectItem); // bring the select directory into view

Is this only possible via the launcher?

This not work:

if (msg == API32.BFFM_INITIALIZED)              // Wenn die Initalisierung des Dialog-Fensters abgeschlossen wurde ...
{
    _ = API32.SendMessage(hwnd, API32.BFFM_SETSELECTIONW, 1, _selectedPath); // Das TreeView-Item mit der Bezeichnung des Select-Verzeichnisses selektieren
    IntPtr SelectItem = IntPtr.Zero;
    _ = API32.SendMessage(hwnd, API32.TVM_SELECTITEM, new IntPtr(API32.TVGN_CARET), SelectItem);   // Select-Verzeichnis selektieren
    _ = API32.SendMessage(hwnd, API32.TVM_ENSUREVISIBLE, IntPtr.Zero, SelectItem);                 // Select-Verzeichnis in den sichtbaren Bereich bringen
}
perlfred
  • 1
  • 3
  • You can't send `TVM_` messages directly to the parent dialog window, you'd need to send them to the TreeView itself. But does `BFFM_SETSELECTIONW` not scroll it into view automatically? – Charlieface Jul 09 '23 at 01:28
  • @Charlieface No, only if the selected entry is at most one level lower. From 2 or more levels, the selected entry is no longer moved into the visible area. – perlfred Jul 10 '23 at 13:27

0 Answers0