How to make OnIncludeItem work for OpenDialog
Posted on 2004-04-11
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);
Include := False;
procedure TMainForm.RegisterNewModMenuItemClick(Sender: TObject);
var TheZipName: string;
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!