Recent

Author Topic: Programmatic filtering in OpenDialog possible?  (Read 9193 times)

Bart

  • Hero Member
  • *****
  • Posts: 5666
    • Bart en Mariska's Webstek
Re: Programmatic filtering in OpenDialog possible?
« Reply #15 on: November 15, 2025, 05:57:46 pm »
Sure, but the request suggested killing off older support in favor of this.
I only saw a requast to add a feature not to kill off a feature we already have.

Bart

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Programmatic filtering in OpenDialog possible?
« Reply #16 on: November 15, 2025, 06:22:15 pm »
Quote
It might be worth discussing whether legacy support is still important nowadays, but I think it should be supported at least for Vista+.

That is what I am talking about from the report.

Jamie
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: Programmatic filtering in OpenDialog possible?
« Reply #17 on: November 15, 2025, 06:28:21 pm »
If Delphi has it, and we can implement it, there really isn't a good reason not to.
You're not obliged to use it.
Delphi XE12 has it. Here is the skeleton of the event handler for it:
Code: Pascal  [Select][+][-]
  1. procedure TForm2.OpenDialog1IncludeItem(const OFN: TOFNotifyEx;
  2.   var Include: Boolean);
  3. begin
  4.  
  5. end;

According to https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Dialogs.TOpenDialog.OnIncludeItem:
Quote
Description

Occurs before the dialog adds a file to the file list box.

Write an OnIncludeItem event handler to programmatically filter the items that appear in the shell folder's item list.

This event does not occur unless the Options property includes ofEnableIncludeNotify.

OFNotifyEx is declared in (fpc)/packages/winunits-base/src/commdlg.pp as
Code: Pascal  [Select][+][-]
  1.      OFNOTIFYEXA = record
  2.           hdr : NMHDR;
  3.           lpOFN : LPOPENFILENAMEA;
  4.           pszFile : pointer;
  5.           pidl  : pointer;
  6.        end;
  7.      LPOFNOTIFYEXA = ^OFNOTIFYEXA;
  8.      _OFNOTIFYEXA = OFNOTIFYEXA;
  9.      TOFNOTIFYEXA = OFNOTIFYEXA;
  10.      POFNOTIFYEXA = ^OFNOTIFYEXA;  
Being Windows-only makes it hard to implement this in a Delphi-compatible way...

Bart

  • Hero Member
  • *****
  • Posts: 5666
    • Bart en Mariska's Webstek
Re: Programmatic filtering in OpenDialog possible?
« Reply #18 on: November 15, 2025, 06:46:53 pm »
See my remarks in the related bugreport. 
(I wrote them at the same time wp was writing reply #17)

This feature is a only available for XP-style dialogs, not for Vista+ dialogs AFAICS. 

I concluded that we should not add this to LCL.

Bart

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: Programmatic filtering in OpenDialog possible?
« Reply #19 on: November 15, 2025, 08:05:46 pm »
Thank you for that.
 :)
Jamie
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018