delphi - TEventObject & IE tabs gives fatal error -
After
I try the document using this code
: = (IWebbrowser2 PDisp). Document like IHTMLDocument2; Body: = Document Link: = Document.links; I: Start (Links.length-1) from = tmp: = (Links.item (i, 0) as iHTMLElement); Tmp.onclick: = TEventObject.Create (MyProcedure) as IDispatch; // this line end; Apart from E: Exception Show Message (E. ClassName + 'has been raised with error message:' + E. Message); End;
In the documentComplete event of an IE web browser, it works fine, but when I open a new tab, I have to face a Microsoft Internet Explorer and "error "Has to be shut down.
In the code given above // the line marked with this line is the one which is creating it (I commented it and did not show this error).
Code:
TEventObject = class (TInterfacedObject, IDispatch) Private FOnEvent: TProcedure; Protected function GetTypeInfoCount (Calculate Out: Integer): HRESULT; Stdcall; Function GetTypeInfo (Index, LocaleID: Integer; Out TypeInfo): HRESULT; Stdcall; Function GetIDsOfNames (constant id: TGUID; name: indicator; NameCount, LocaleID: integer; DispIDs: indicator): HRESULT; Stdcall; Function implemented (DispID: Integer; Constants ID: TGUID; LocaleID: Integer; Flags: Word, Parameter; VarResult, ExcepInfo, ArgErr: Indicator): HRESULT; Stdcall public creator (Constant OnEvent Build: TProcedure); Property On Event: TPCCD FOnEvent writes FOnEvent; End; ........... Constructor TEventObject.Create (Constant Event: TPCCDure); Start the heritage; Create; FOnEvent: = OnEvent; End; Function TEventObject.GetIDsOfNames (static ID: TGUID; name: indicator; NameCount, LocaleID: integer; DispIDs: indicator): HRESULT; Start the result: = E_NOTIMPL; End; The function TEventObject.GetTypeInfo (index, locale: integer; out type interface): HRSLT; Start the result: = E_NOTIMPL; End; Function TEventObject.GetTypeInfoCount (Out Count: Integer): HRSult; Start the result: = E_NOTIMPL; End; Work in a TriviaBuild.Invoke (DispID: Integer; Integer; IID: TGUID; LocaleID: Integer; Flags: Word, Parameter; VarResult, ExcepInfo, ArgErr: Indicator): HRESULT; Start (Dispid = DISPID_VALUE) then if assigned (FOnEvent) then FOnEvent; Results: = S_OK; End and result: = E_NOTIMPL; End;
How do I work for this tab?
I found a workaround:
url: = annilever case (Url); If (URL = '') or (URL = 'about: blank') or (URL = 'about: tabs') then exit;
Click events that work well on those other pages are not about: tabs.
Comments
Post a Comment