⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delfaq.txt

📁 一个Delphi解释器的例子
💻 TXT
字号:
>I'm interested in creating a handler event for QuickReport events, It will
>be great to add Delphin capabilities to write macro in this event.

There are two different ways of linking an interpreter to the event. 

1) Old way: 
   You can drop THalComp on form and asign ControlLink,EventLink properties.
   When form with such component is loaded at runtime, interpreter will
   assign an event handler to the property with name EventLink of the 
   component ControlLink. Each time when event will be fired, interpreter's 
   script will be executed. This way has a limitation : only TNotifyEvents are 
   supported. 

2) Interpreter can load and execute forms with code. (You can use procedures
   RunFormModal, RunForm, etc.). When you call this procedure, interpreter 
   loads form and corresponding pas file with events and methods. When loaded
   all events are assigned and script is executed each time an event is fired.

   Currently we registered such event types:

   Dream Controls V2.11B:

   TQRAfterPrintEvent      TQRAfterPreviewEvent   TQRNotifyEvent
   TNotifyEvent            TCloseEvent            TDragDropEvent
   TDragOverEvent          TEndDragEvent          TStartDragEvent
   TKeyPressEvent          TQROnNeedDataEvent     TQRNotifyOperationEvent
   TQRBandBeforePrintEvent TQRBandAfterPrintEvent TQRReportBeforePrintEvent
   TQRFilterEvent          THelpEvent             TCloseQueryEvent
   TQRLabelOnPrintEvent    TQRProgressUpdateEvent TQRPageAvailableEvent
   TMouseEvent             TMouseMoveEvent        TKeyEvent

   It's very easy to register new event types in the interpreter. Here is an 
   example:
 
   --------------------------------------------------------------------
   uses Delphin;

   type
     // you need to create a new class and derive it from THalEvent
     THEvent = Class(THalEvent)
     public
       // you need to declare method which will be fired when event is fired
       // list of parameters must be the same as in event type 	
       Procedure MCloseEvent(Sender: TObject; Var Action: TCloseAction);        
     end;

   Procedure THEvent.MCloseEvent(Sender: TObject; Var Action: TCloseAction);
   Var
     V: Array[0..0] of Variant;
   Begin
     V[0] := Action;
     ExecProc(Sender,1,@V);// 1 - is number of parameters
     Action := V[0];
   End;
   
   initialization
     RegisterEvent('TCloseEvent', @THEvent.MCloseEvent, THalEvent);
   --------------------------------------------------------------------

   Other examples of registering events can be found in delphin.pas.

   An alternative way is to ask us to add new event into the Delphi. And we 
   will add it into the next release.
  

>Then, I need to understand how a Delphin script can be filled up with a
>form objects (as Quick report components), how I can read within the script 
>the value those components properties (and how to affect them).

THalComp fills list of component automatically. If you drop THalComp on form 
you can use any form's components in scripts. Just write 
Button1.Caption:='HHH' for example. 

There are some limitations:

* only one point allowed in identifiers (A.B.C will not work)

* if you use form's property you need to write Self.<propname> 
  (Self.Caption for example).

* property or method must be registered in the interpreter (You can open Browser 
  and look on what's registered and what's not). 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -