SHBrowseForFolder: Move the selected entry into the visible area

36 Views Asked by At

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
}
0

There are 0 best solutions below