Subject [IBO] IB_BrowseDialog FIX (was: Two Questions)
Author Paul Vinkenoog
Hello Rainer,

About the EInvalidCast in IB_BrowseDialog:

>> It's a known, er... phenomenon ;-)
>> Not your fault.
>
> Do you think there will be a update for the IB_BrowsDialog? It is
> such a nice component, but I can't use it in application done for
> customers, since they would come right at me with this "phenomenon"
> :-(

I've found the troublemaker. If you have the source code, here's how
to fix it:


Open IBF_Browse.pas and go to:

procedure TfrmBrowse.pmShowMainPopup(Sender: TObject);
(line 1385 in the latest versions)


In the var section, add:

enable_del: Boolean;


Now, locate this code (starting 6 lines after "begin")
and comment it out completely or delete it:

with PopupTarget as TIB_CustomGrid do
begin
if b then
b := Assigned( DataSource ) and
Assigned( DataSource.Dataset ) and
DataSource.Dataset.BufferActive;
// CopyItemsToClipboard1.Enabled := b;
CpNamesClipb.Enabled := b;
CpRowClipb.Enabled := b;
CpTableClipb.Enabled := b;
miDeleteselectedrecords.Enabled := b and DataSource.Dataset.CanDelete;
end;


Insert this code as replacement:

if b then
begin
with PopupTarget as TIB_CustomGrid do
begin
b := Assigned( DataSource ) and
Assigned( DataSource.Dataset ) and
DataSource.Dataset.BufferActive;
enable_del := b and DataSource.Dataset.CanDelete;
end
end
else
begin
enable_del := false;
end;

// CopyItemsToClipboard1.Enabled := b;
CpNamesClipb.Enabled := b;
CpRowClipb.Enabled := b;
CpTableClipb.Enabled := b;
miDeleteselectedrecords.Enabled := enable_del;


This fixes the typecast error. But while you're hacking away, you
might as well go to immediately after these lines:

while Dialogs1.Count > 0 do
Dialogs1.Items[0].Free;

and insert:

Dialogs1.Enabled := not ( fsModal in FormState );

The rest of the procedure consists of a for-loop that is useless if
Dialogs1 is disabled so you sandwich that loop between

if Dialogs1.Enabled then // no use building submenu if disabled
begin
// these two lines go BEFORE the line {$IFNDEF VER90}

and

end;


After saving the changed code, rebuild projects IBO40FRT, IBO40VDT,
IBO40FDT and IBO40EDT (in that order). If you also use "X" packages,
some of these may need to be rebuilt too. Don't forget to also
INSTALL the packages ending in *DT.

Remake or rebuild your application, and the problem is gone. If
you also changed the "Dialogs1" stuff, this submenu will be disabled
if your browser is modal. (If it ain't disabled while the dialog is modal,
users are led to believe they can switch between dialogs but they really
can't.)

You can also remake IB_SQL (included in the IBO source) to fix the
problem there too.



I'll send the fixes to Jason for inclusion in a next version.



Greetings,
Paul Vinkenoog