Forum > LCL

[How to?] Call "EventOnMessage" inside "onClickEvent"

(1/1)

codeman:
Hello, how to call eventOnMessage inside onClick Event??



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.EventOnMessage(var Msg: tagMSG; var Handled: Boolean);var  NrFiles, i : Integer;  Buffer : Array[0..255] of Char;begintry   Handled:=Msg.Message=WM_DROPFILES;   if not Handled then     exit;   attachedSelected:=true;  NrFiles:=DragQueryFile(Msg.Wparam,$FFFFFFFF,Buffer,256); .......... finally    DragFinish(Msg.WParam);end; 


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.button1Click(Sender: TObject);begin       ???? EventOnMessage( ?? );       Everything i tried, I get that compiling error (Types of actual and formal var parameters must be identical)end; 

Thanks for considering my request!

Mr.Madguy:
Have you tried to do it standard way?

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure WMDropFiles(var Message : TMessage); message WM_DROPFILES; I haven't checked, but may be there is existing handler for this message?

jamie:
Although you can do as you wish it would be meaningless because the values in the message record would need to contain something valid for that to work manually.

 What you should do is make method of the code body you are executing within that message handler and simply call that method instead. What this does is allows you to also call that same body of code elsewhere without the confusion of message handling which in this case would be a lost, just provide a function body (method) with the actual code you are trying to execute so that both this existing event handler can all it along with your manual click..

 Btw, the TFORM has a handler already for a file drop event...

codeman:
Thank you both! Solved! :)

Navigation

[0] Message Index

Go to full version