[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 819
  • Last Modified:

How to make OnIncludeItem work for OpenDialog

The basic question is "if I want to make OnIncludeItem exclude some files, how do I do it"?

I know the name of the files I want to exclude.

There are two parts to my question, based on where I am up to:

1) What is wrong with this:

procedure TMainForm.DontShowAlreadyLoadedMods(const OFN: TOFNotifyEx; var Include: Boolean);
begin
    Debug('OnIncludeItem...');
    Include := False;
end;

procedure TMainForm.RegisterNewModMenuItemClick(Sender: TObject);
    var TheZipName: string;
        ModOpenDialog: TOpenDialog;
        i: integer;
begin
    TellUser('Initiate mod file open...');

    ModOpenDialog := TOpenDialog.Create(self);

    ModOpenDialog.InitialDir := CurrentGame^.GameModDir;
    ModOpenDialog.Options := [ofEnableIncludeNotify, ofAllowMultiSelect, ofPathMustExist, ofFileMustExist, ofHideReadOnly, ofEnableSizing];
    ModOpenDialog.Filter := 'Mod Zip Files|*.zip';
    ModOpenDialog.OnIncludeItem := DontShowAlreadyLoadedMods;

    TellUser('looking in ' + CurrentGame^.GameModDir);

    if not(ModOpenDialog.Execute) then
...


I would have thought that this would result in no files being displayed in the OpenDialog, since I return False always from OnIncludeItem.  I have confirmed that OnIncludeItem is being called, but it makes no difference to the outcome: all the .zip files in the directory are displayed.

What am I missing?

2) Suppose that worked, then how do I determine the file name of the file under consideration: it must be hidden inside OFN, but darned if I can see where!

Thanks!
0
GreenAsJade
Asked:
GreenAsJade
1 Solution
 
mokuleCommented:
Hi

OnIncludeItem won't work.

Read 3rd question there:
http://msdn.microsoft.com/msdnmag/issues/03/10/CQA/default.aspx
0
 
GreenAsJadeAuthor Commented:
Well, knowning that can save some heartache.

So do I have to write my open file open dialog, or is there some less extreme option?

Thanks,
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now