![]() |
FIX: Bug in der Typelib zum DWebBrowserEvents2 interface
Bug in der Typelib zum DWebBrowserEvents2 interface
Symptom: FileDownload() wird zwar aufgerufen, jedoch kann ein Download nicht verhindert werden, was durch Setzen des ersten Parameters auf TRUE möglich sein müßte. Problem: Die Signatur der FileDownload()-Methode in der Typelib von MS ist fehlerhaft! Achtung: wenn man aus der Typelib des ![]()
Code:
Korrekt wäre jedoch:
void FileDownload(VARIANT_BOOL *&Cancel);
Code:
Es handelt sich dabei um DISPID_FILEDOWNLOAD == 270 ("Fired to indicate the File Download dialog is opening") und exakter ausgedrückt, wie
void FileDownload(
VARIANT_BOOL *ActiveDocument, VARIANT_BOOL *Cancel ); ![]()
Delphi-Quellcode:
Hier aus der Invoke-Methode des Dispatchers die Behandlung dieser speziellen DISPID:
procedure DoFileDownload(var Cancel: WordBool); safecall;
Delphi-Quellcode:
270: begin
DoFileDownload (dps.rgvarg^ [pDispIds^ [0]].pbool^); Result := S_OK; end;
Delphi-Quellcode:
procedure TWebBrowserEvents.DoFileDownload(var Cancel: WordBool);
begin if not Assigned (FileDownload) then System.Exit; FileDownload (Self, Cancel); end;
Delphi-Quellcode:
Microsoft selbst
TFileDownloadEvent = procedure(Sender: TObject;
var Cancel: WordBool) of object; ![]() An obigen Quellen müssen folgende Änderungen vorgenommen werden:
Delphi-Quellcode:
procedure DoFileDownload(var ActiveDocument: WordBool; var Cancel: WordBool); safecall;
Delphi-Quellcode:
270: begin
DoFileDownload(dps.rgvarg^ [pDispIds^ [0]].pbool^, dps.rgvarg^ [pDispIds^ [1]].pbool^); Result := S_OK; end;
Delphi-Quellcode:
procedure TWebBrowserEvents.DoFileDownload(var ActiveDocument: WordBool; var Cancel: WordBool);
begin if not Assigned (FileDownload) then System.Exit; FileDownload (Self, ActiveDocument, Cancel); end;
Delphi-Quellcode:
So, das sollte es auch schon gewesen sein. Gefunden habe ich das Ganze durch Probleme in einer C++-Implementation dieses Interfaces. Durch einen
TFileDownloadEvent = procedure(Sender: TObject;
var ActiveDocument: WordBool; var Cancel: WordBool) of object; ![]() Da es mich viel Zeit gekostet hat, dachte ich die Codelib sei für diese Sache genau der richtige Platz! So müssen sich andere nicht auch wie ich mühsam auf die Suche nach dem Problem machen ;) Ich hoffe, daß ich nix übersehen habe, da ich wie gesagt, das Ganze nur in C++ benutze. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz