Help:- How To Use TEVSWebBrowser.OnFileDownload lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Laurence · 2015-10-25 12:42 Hi All, I program as a hobby and I am a bit lost at the moment. I am using Lazarus - details on signature strip. I have written a program that parses web pages using an activeX component. It work fine and scrapes the info I need. Everything drops into the tables etc... The problem I have  is that a Dialog box keeps popping up with a "Do I want to ---" Save" Open, Cancel. I want to stop that Dialog from downloading in the first place. So........ This is where I seem to be 'not too bright'. In fact I am lost. I have tried to resolve this for nearly 3 weeks with no success The event Handler for TEVSWebBrowser.onfiledownload seems to expect a procedure with the arguments (Sender as TObject, ActiveDocument : Wordbool; Cancel : Boolean). I have never written a procedure that carried variables and I have no idea how to. I have always just used Global variables. This is my call:- webbrowser2.OnFileDownload:= Stop_Download(webBrowser2 as TEVSWebBrowser,false,Cancel); As I understand things, when the browser begins to download a file, it looks to see whether or not to allow it by calling the OnFileDownLoad event procedure. On compiling the above, the error shows:-   Error: Incompatible types: got "untyped" expected "" My Procedure looks like this:- Procedure Stop_Download(Sender : TEVSWebBrowser; ActiveDocument: WordBool; Var cancel : Boolean); Begin Cancel := True; ShowMessage('File is Stopped'); end;  I had to make the variable "Cancel" Global because if I did it locally it showed an error of "Duplicate Identifier" and without the Global declaration it didn't find it. More confusing. The Global Variable Declaration is: Var Cancel : Boolean; My Declaration for the procedure looks like this:- Procedure Stop_DownLoad(Sender : TEVSWebBrowser; ActiveDocument: WordBool; Var Cancel:Boolean); I have tried all kinds of variations,  each with a resounding error of some sort. I have also seen the ending "of Object" on my many travels in Googling this problem. This seems to be referred to in the error. I have no idea what it means........sorry. Just to confuse things further, This event used to have 1 argument in the form of 'Cancel'. Now it has two. This version of Lazarus seems to like two, so that is good. This is probably very simple and is a syntax thing. I don't quit easy guys. Believe me I HAVE tried. Thanks in anticipation BR Laurence. ---------------------------------------------------------------------- howardpc · 2015-10-25 13:06 Is your procedure Stop_Download a stand-alone procedure? If so, change it to be a method of some class. Perhaps a public method of the containing form class. It is also best to keep type declarations identical, thus: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure Stop_Download(  ...; var aCancel: wordbool);  You can make the names of arguments in procedure/function/method calls whatever you want. There is no need to have name clash with Cancel. Such names for common identifiers are best avoided. ---------------------------------------------------------------------- Laurence · 2015-10-26 17:44 Hi Howardpc Yes it is a "Stand-alone" so what I have done is: I have declared it just under the uses clause like so- Type         TStopDownLoads = Class(TEVSWebBrowser)      Public       Procedure Stop_DownLoad(Sender : TEVSWebBrowser; ActiveDocument: WordBool; Var CancelDownload:WordBool);        End; The compiler seems to pass that OK (Learning curve again) My calling procedure now looks like this:- webbrowser2.OnFileDownload:= TStopDownLoads.Stop_Download(webBrowser2 as TEVSWebBrowser,false,CancelDownload); With the variable "Cancel" changed to 'CancelDownload'. This generates a compiler error:- Error: Only class class methods, class properties and class variables can be accessed in class methods Now this bit has confused me, as I have declared this as an existing class, (TEVSWebBrowser) which the compiler must recognise ??? So I thought if there are three parameters,  Sender : TObject;   ActiveDocument : WordBool;   Var Cancel : Boolean; (This is according to a lot of Googling, mind you) then I should re-try 'Cancel'......Same result, same error message. Hence it is back to the variable 'CancelDownload'. I think, (NOTE the word "think") that I have declared the declaration correctly. Do I have to declare the variable CancelDownload in the type statement as well? I am reading from www.docwiki.appmethod web page to try and understand this as well as Delphi_basics.co.uk. The 'penny' just hasn't dropped as to what I am doing wrong! I am so pleased I earn a living from Hydraulic Engineering and not programming............I'd be very poor (Ha-Ha). Any pointers gratefully received from a 61 year old nitwit ! BR Laurence ---------------------------------------------------------------------- Laurence · 2015-10-27 07:29 Currently at work doing the day job!! But the class for TEVSWebBrowser is TSinkEvent. I will try using that when I get home tonight. Back to the day job. BR Laurence