////
//  This file was generated by VCL Generator
//  Copyright 1998 - Morgan Martinet
//  06/07/1999 07:58:54
//  it subclasses all classes of the unit Forms
////

unit Delphi_Forms;

interface

uses
  Messages,
  Windows,
  SysUtils,
  Classes,
  Graphics,
  Menus,
  Controls,
  Imm,
  ActnList,
  MultiMon,
  Forms,
  PythonEngine,
  PyVarArg,
  PyRecords,
  PyDelphiAssoc;

type
  TPyControlScrollBar = class( TControlScrollBar )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyScrollingWinControl = class( TScrollingWinControl )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyScrollBox = class( TScrollBox )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
    procedure EventOnCanResize( Sender : TObject; var NewWidth, NewHeight : Integer; var Resize : Boolean );
    procedure EventOnClick( Sender : TObject );
    procedure EventOnConstrainedResize( Sender : TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight : Integer );
    procedure EventOnDblClick( Sender : TObject );
    procedure EventOnDockDrop( Sender : TObject; Source : TDragDockObject; X, Y : Integer );
    procedure EventOnDockOver( Sender : TObject; Source : TDragDockObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
    procedure EventOnDragDrop( Sender, Source : TObject; X, Y : Integer );
    procedure EventOnDragOver( Sender, Source : TObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
    procedure EventOnEndDock( Sender, Target : TObject; X, Y : Integer );
    procedure EventOnEndDrag( Sender, Target : TObject; X, Y : Integer );
    procedure EventOnEnter( Sender : TObject );
    procedure EventOnExit( Sender : TObject );
    procedure EventOnGetSiteInfo( Sender : TObject; DockClient : TControl; var InfluenceRect : TRect; MousePos : TPoint; var CanDock : Boolean );
    procedure EventOnMouseDown( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseMove( Sender : TObject; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseUp( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseWheel( Sender : TObject; Shift : TShiftState; WheelDelta : Integer; MousePos : TPoint; var Handled : Boolean );
    procedure EventOnMouseWheelDown( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
    procedure EventOnMouseWheelUp( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
    procedure EventOnResize( Sender : TObject );
    procedure EventOnStartDock( Sender : TObject; var DragObject : TDragDockObject );
    procedure EventOnStartDrag( Sender : TObject; var DragObject : TDragObject );
    procedure EventOnUnDock( Sender : TObject; Client : TControl; NewTarget : TWinControl; var Allow : Boolean );
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyCustomForm = class( TCustomForm )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyCustomActiveForm = class( TCustomActiveForm )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
    procedure EventOnActivate( Sender : TObject );
    procedure EventOnClick( Sender : TObject );
    procedure EventOnCreate( Sender : TObject );
    procedure EventOnDblClick( Sender : TObject );
    procedure EventOnDestroy( Sender : TObject );
    procedure EventOnDeactivate( Sender : TObject );
    procedure EventOnDragDrop( Sender, Source : TObject; X, Y : Integer );
    procedure EventOnDragOver( Sender, Source : TObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
    procedure EventOnKeyDown( Sender : TObject; var Key : Word; Shift : TShiftState );
    procedure EventOnKeyPress( Sender : TObject; var Key : Char );
    procedure EventOnKeyUp( Sender : TObject; var Key : Word; Shift : TShiftState );
    procedure EventOnMouseDown( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseMove( Sender : TObject; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseUp( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
    procedure EventOnPaint( Sender : TObject );
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyForm = class( TForm )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
    procedure EventOnActivate( Sender : TObject );
    procedure EventOnCanResize( Sender : TObject; var NewWidth, NewHeight : Integer; var Resize : Boolean );
    procedure EventOnClick( Sender : TObject );
    procedure EventOnClose( Sender : TObject; var Action : TCloseAction );
    procedure EventOnCloseQuery( Sender : TObject; var CanClose : Boolean );
    procedure EventOnConstrainedResize( Sender : TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight : Integer );
    procedure EventOnCreate( Sender : TObject );
    procedure EventOnDblClick( Sender : TObject );
    procedure EventOnDestroy( Sender : TObject );
    procedure EventOnDeactivate( Sender : TObject );
    procedure EventOnDockDrop( Sender : TObject; Source : TDragDockObject; X, Y : Integer );
    procedure EventOnDockOver( Sender : TObject; Source : TDragDockObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
    procedure EventOnDragDrop( Sender, Source : TObject; X, Y : Integer );
    procedure EventOnDragOver( Sender, Source : TObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
    procedure EventOnEndDock( Sender, Target : TObject; X, Y : Integer );
    procedure EventOnGetSiteInfo( Sender : TObject; DockClient : TControl; var InfluenceRect : TRect; MousePos : TPoint; var CanDock : Boolean );
    procedure EventOnHide( Sender : TObject );
    function  EventOnHelp( Command : Word; Data : Longint; var CallHelp : Boolean ) : Boolean;
    procedure EventOnKeyDown( Sender : TObject; var Key : Word; Shift : TShiftState );
    procedure EventOnKeyPress( Sender : TObject; var Key : Char );
    procedure EventOnKeyUp( Sender : TObject; var Key : Word; Shift : TShiftState );
    procedure EventOnMouseDown( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseMove( Sender : TObject; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseUp( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
    procedure EventOnMouseWheel( Sender : TObject; Shift : TShiftState; WheelDelta : Integer; MousePos : TPoint; var Handled : Boolean );
    procedure EventOnMouseWheelDown( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
    procedure EventOnMouseWheelUp( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
    procedure EventOnPaint( Sender : TObject );
    procedure EventOnResize( Sender : TObject );
    procedure EventOnShortCut( var Msg : TWMKey; var Handled : Boolean );
    procedure EventOnShow( Sender : TObject );
    procedure EventOnStartDock( Sender : TObject; var DragObject : TDragDockObject );
    procedure EventOnUnDock( Sender : TObject; Client : TControl; NewTarget : TWinControl; var Allow : Boolean );
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyCustomDockForm = class( TCustomDockForm )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyDataModule = class( TDataModule )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
    procedure EventOnCreate( Sender : TObject );
    procedure EventOnDestroy( Sender : TObject );
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyMonitor = class( TMonitor )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyScreen = class( TScreen )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
    procedure EventOnActiveControlChange( Sender : TObject );
    procedure EventOnActiveFormChange( Sender : TObject );
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;

  TPyApplication = class( TApplication )
  protected
    FAssoc : Integer;
  public
    destructor Destroy; override;
    procedure EventOnActionExecute( Action : TBasicAction; var Handled : Boolean );
    procedure EventOnActionUpdate( Action : TBasicAction; var Handled : Boolean );
    procedure EventOnActivate( Sender : TObject );
    procedure EventOnDeactivate( Sender : TObject );
    procedure EventOnException( Sender : TObject; E : Exception );
    procedure EventOnIdle( Sender : TObject; var Done : Boolean );
    function  EventOnHelp( Command : Word; Data : Longint; var CallHelp : Boolean ) : Boolean;
    procedure EventOnHint( Sender : TObject );
    procedure EventOnMessage( var Msg : TMsg; var Handled : Boolean );
    procedure EventOnMinimize( Sender : TObject );
    procedure EventOnRestore( Sender : TObject );
    procedure EventOnShowHint( var HintStr : string; var CanShow : Boolean; var HintInfo : THintInfo );
    procedure EventOnShortCut( var Msg : TWMKey; var Handled : Boolean );
  published
    property __assoc__ : Integer read FAssoc write FAssoc;
  end;


implementation

Uses Py_Misc;

/////////// class TPyControlScrollBar /////////////////////

destructor TPyControlScrollBar.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

/////////// class TPyScrollingWinControl /////////////////////

destructor TPyScrollingWinControl.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

/////////// class TPyScrollBox /////////////////////

destructor TPyScrollBox.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

procedure TPyScrollBox.EventOnCanResize( Sender : TObject; var NewWidth, NewHeight : Integer; var Resize : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( NewWidth ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( NewHeight ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Resize ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnCanResize', TDelphiAssoc(__assoc__), L, args );
    NewWidth := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    NewHeight := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    Resize := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnClick( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    rslt := ExecuteEvent( 'OnClick', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnConstrainedResize( Sender : TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MinWidth ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MinHeight ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MaxWidth ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MaxHeight ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnConstrainedResize', TDelphiAssoc(__assoc__), L, args );
    MinWidth := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    MinHeight := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    MaxWidth := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    MaxHeight := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[4]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnDblClick( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    rslt := ExecuteEvent( 'OnDblClick', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnDockDrop( Sender : TObject; Source : TDragDockObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnDockDrop', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnDockOver( Sender : TObject; Source : TDragDockObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(State) ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Accept ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnDockOver', TDelphiAssoc(__assoc__), L, args );
    Accept := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[5]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnDragDrop( Sender, Source : TObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnDragDrop', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnDragOver( Sender, Source : TObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(State) ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Accept ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnDragOver', TDelphiAssoc(__assoc__), L, args );
    Accept := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[5]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnEndDock( Sender, Target : TObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Target, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnEndDock', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnEndDrag( Sender, Target : TObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Target, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnEndDrag', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnEnter( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    rslt := ExecuteEvent( 'OnEnter', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnExit( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    rslt := ExecuteEvent( 'OnExit', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnGetSiteInfo( Sender : TObject; DockClient : TControl; var InfluenceRect : TRect; MousePos : TPoint; var CanDock : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( DockClient, 'Forms', 'TScrollBox' ) ); 
    L.Add( CreateVarArg( CreateRect( InfluenceRect ).GetSelf ).GetSelf ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( CanDock ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnGetSiteInfo', TDelphiAssoc(__assoc__), L, args );
    InfluenceRect := PyObjectAsRect( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    CanDock := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[4]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnMouseDown( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(Button) ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseDown', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnMouseMove( Sender : TObject; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseMove', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnMouseUp( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(Button) ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseUp', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnMouseWheel( Sender : TObject; Shift : TShiftState; WheelDelta : Integer; MousePos : TPoint; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( WheelDelta ) ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMouseWheel', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[4]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnMouseWheelDown( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMouseWheelDown', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnMouseWheelUp( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMouseWheelUp', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnResize( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    rslt := ExecuteEvent( 'OnResize', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnStartDock( Sender : TObject; var DragObject : TDragDockObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( CreateVarArg( GetPythonObject( DragObject, 'Forms', 'TScrollBox' ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnStartDock', TDelphiAssoc(__assoc__), L, args );
    DragObject := GetObjectOf( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) ) as TDragDockObject;
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnStartDrag( Sender : TObject; var DragObject : TDragObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( CreateVarArg( GetPythonObject( DragObject, 'Forms', 'TScrollBox' ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnStartDrag', TDelphiAssoc(__assoc__), L, args );
    DragObject := GetObjectOf( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) ) as TDragObject;
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScrollBox.EventOnUnDock( Sender : TObject; Client : TControl; NewTarget : TWinControl; var Allow : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( Client, 'Forms', 'TScrollBox' ) ); 
    L.Add( GetPythonObject( NewTarget, 'Forms', 'TScrollBox' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Allow ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnUnDock', TDelphiAssoc(__assoc__), L, args );
    Allow := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

/////////// class TPyCustomForm /////////////////////

destructor TPyCustomForm.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

/////////// class TPyCustomActiveForm /////////////////////

destructor TPyCustomActiveForm.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

procedure TPyCustomActiveForm.EventOnActivate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnActivate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnClick( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnClick', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnCreate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnCreate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnDblClick( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnDblClick', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnDestroy( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnDestroy', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnDeactivate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnDeactivate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnDragDrop( Sender, Source : TObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnDragDrop', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnDragOver( Sender, Source : TObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(State) ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Accept ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnDragOver', TDelphiAssoc(__assoc__), L, args );
    Accept := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[5]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnKeyDown( Sender : TObject; var Key : Word; Shift : TShiftState );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Key ) ).GetSelf ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    rslt := ExecuteEvent( 'OnKeyDown', TDelphiAssoc(__assoc__), L, args );
    Key := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnKeyPress( Sender : TObject; var Key : Char );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Key ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnKeyPress', TDelphiAssoc(__assoc__), L, args );
    Key := PyObjectAsChar( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnKeyUp( Sender : TObject; var Key : Word; Shift : TShiftState );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Key ) ).GetSelf ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    rslt := ExecuteEvent( 'OnKeyUp', TDelphiAssoc(__assoc__), L, args );
    Key := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnMouseDown( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(Button) ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseDown', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnMouseMove( Sender : TObject; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseMove', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnMouseUp( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(Button) ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseUp', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyCustomActiveForm.EventOnPaint( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TCustomActiveForm' ) ); 
    rslt := ExecuteEvent( 'OnPaint', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

/////////// class TPyForm /////////////////////

destructor TPyForm.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

procedure TPyForm.EventOnActivate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnActivate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnCanResize( Sender : TObject; var NewWidth, NewHeight : Integer; var Resize : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( NewWidth ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( NewHeight ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Resize ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnCanResize', TDelphiAssoc(__assoc__), L, args );
    NewWidth := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    NewHeight := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    Resize := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnClick( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnClick', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnClose( Sender : TObject; var Action : TCloseAction );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.PyInt_FromLong( Integer(Action) ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnClose', TDelphiAssoc(__assoc__), L, args );
    Action := TCloseAction( GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnCloseQuery( Sender : TObject; var CanClose : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( CanClose ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnCloseQuery', TDelphiAssoc(__assoc__), L, args );
    CanClose := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnConstrainedResize( Sender : TObject; var MinWidth, MinHeight, MaxWidth, MaxHeight : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MinWidth ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MinHeight ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MaxWidth ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( MaxHeight ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnConstrainedResize', TDelphiAssoc(__assoc__), L, args );
    MinWidth := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    MinHeight := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    MaxWidth := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    MaxHeight := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[4]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnCreate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnCreate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDblClick( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnDblClick', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDestroy( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnDestroy', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDeactivate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnDeactivate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDockDrop( Sender : TObject; Source : TDragDockObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnDockDrop', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDockOver( Sender : TObject; Source : TDragDockObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(State) ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Accept ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnDockOver', TDelphiAssoc(__assoc__), L, args );
    Accept := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[5]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDragDrop( Sender, Source : TObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnDragDrop', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnDragOver( Sender, Source : TObject; X, Y : Integer; State : TDragState; var Accept : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( Source, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(State) ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Accept ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnDragOver', TDelphiAssoc(__assoc__), L, args );
    Accept := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[5]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnEndDock( Sender, Target : TObject; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( Target, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnEndDock', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnGetSiteInfo( Sender : TObject; DockClient : TControl; var InfluenceRect : TRect; MousePos : TPoint; var CanDock : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( DockClient, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( CreateRect( InfluenceRect ).GetSelf ).GetSelf ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( CanDock ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnGetSiteInfo', TDelphiAssoc(__assoc__), L, args );
    InfluenceRect := PyObjectAsRect( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    CanDock := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[4]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnHide( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnHide', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

function TPyForm.EventOnHelp( Command : Word; Data : Longint; var CallHelp : Boolean ) : Boolean;
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonEngine.VariantAsPyObject( Command ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Data ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( CallHelp ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnHelp', TDelphiAssoc(__assoc__), L, args );
    CallHelp := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    Result := GetPythonEngine.PyObjectAsVariant( rslt );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnKeyDown( Sender : TObject; var Key : Word; Shift : TShiftState );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Key ) ).GetSelf ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    rslt := ExecuteEvent( 'OnKeyDown', TDelphiAssoc(__assoc__), L, args );
    Key := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnKeyPress( Sender : TObject; var Key : Char );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Key ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnKeyPress', TDelphiAssoc(__assoc__), L, args );
    Key := PyObjectAsChar( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnKeyUp( Sender : TObject; var Key : Word; Shift : TShiftState );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Key ) ).GetSelf ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    rslt := ExecuteEvent( 'OnKeyUp', TDelphiAssoc(__assoc__), L, args );
    Key := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnMouseDown( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(Button) ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseDown', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnMouseMove( Sender : TObject; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseMove', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnMouseUp( Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonEngine.PyInt_FromLong( Integer(Button) ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( X ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Y ) ); 
    rslt := ExecuteEvent( 'OnMouseUp', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnMouseWheel( Sender : TObject; Shift : TShiftState; WheelDelta : Integer; MousePos : TPoint; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( WheelDelta ) ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMouseWheel', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[4]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnMouseWheelDown( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMouseWheelDown', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnMouseWheelUp( Sender : TObject; Shift : TShiftState; MousePos : TPoint; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( SetToList( @Shift, sizeof(Shift) ) ); 
    L.Add( CreatePoint( MousePos ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMouseWheelUp', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnPaint( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnPaint', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnResize( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnResize', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnShortCut( var Msg : TWMKey; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( CreateVarArg( GetPythonEngine.Py_None ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnShortCut', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnShow( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    rslt := ExecuteEvent( 'OnShow', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnStartDock( Sender : TObject; var DragObject : TDragDockObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonObject( DragObject, 'Forms', 'TForm' ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnStartDock', TDelphiAssoc(__assoc__), L, args );
    DragObject := GetObjectOf( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) ) as TDragDockObject;
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyForm.EventOnUnDock( Sender : TObject; Client : TControl; NewTarget : TWinControl; var Allow : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( Client, 'Forms', 'TForm' ) ); 
    L.Add( GetPythonObject( NewTarget, 'Forms', 'TForm' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Allow ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnUnDock', TDelphiAssoc(__assoc__), L, args );
    Allow := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[3]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

/////////// class TPyCustomDockForm /////////////////////

destructor TPyCustomDockForm.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

/////////// class TPyDataModule /////////////////////

destructor TPyDataModule.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

procedure TPyDataModule.EventOnCreate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TDataModule' ) ); 
    rslt := ExecuteEvent( 'OnCreate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyDataModule.EventOnDestroy( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TDataModule' ) ); 
    rslt := ExecuteEvent( 'OnDestroy', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

/////////// class TPyMonitor /////////////////////

destructor TPyMonitor.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

/////////// class TPyScreen /////////////////////

destructor TPyScreen.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

procedure TPyScreen.EventOnActiveControlChange( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScreen' ) ); 
    rslt := ExecuteEvent( 'OnActiveControlChange', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyScreen.EventOnActiveFormChange( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TScreen' ) ); 
    rslt := ExecuteEvent( 'OnActiveFormChange', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

/////////// class TPyApplication /////////////////////

destructor TPyApplication.Destroy;
begin
  ClearInterface( TDelphiAssoc(FAssoc) );
  FAssoc := 0;
  inherited;
end;

procedure TPyApplication.EventOnActionExecute( Action : TBasicAction; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Action, 'Forms', 'TApplication' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnActionExecute', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnActionUpdate( Action : TBasicAction; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Action, 'Forms', 'TApplication' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnActionUpdate', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnActivate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    rslt := ExecuteEvent( 'OnActivate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnDeactivate( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    rslt := ExecuteEvent( 'OnDeactivate', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnException( Sender : TObject; E : Exception );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    L.Add( GetPythonEngine.Py_None ); 
    rslt := ExecuteEvent( 'OnException', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnIdle( Sender : TObject; var Done : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Done ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnIdle', TDelphiAssoc(__assoc__), L, args );
    Done := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

function TPyApplication.EventOnHelp( Command : Word; Data : Longint; var CallHelp : Boolean ) : Boolean;
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonEngine.VariantAsPyObject( Command ) ); 
    L.Add( GetPythonEngine.VariantAsPyObject( Data ) ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( CallHelp ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnHelp', TDelphiAssoc(__assoc__), L, args );
    CallHelp := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[2]) ) );
    Result := GetPythonEngine.PyObjectAsVariant( rslt );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnHint( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    rslt := ExecuteEvent( 'OnHint', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnMessage( var Msg : TMsg; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( CreateVarArg( GetPythonEngine.Py_None ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnMessage', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnMinimize( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    rslt := ExecuteEvent( 'OnMinimize', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnRestore( Sender : TObject );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( GetPythonObject( Sender, 'Forms', 'TApplication' ) ); 
    rslt := ExecuteEvent( 'OnRestore', TDelphiAssoc(__assoc__), L, args );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnShowHint( var HintStr : string; var CanShow : Boolean; var HintInfo : THintInfo );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( HintStr ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( CanShow ) ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.Py_None ).GetSelf ); 
    rslt := ExecuteEvent( 'OnShowHint', TDelphiAssoc(__assoc__), L, args );
    HintStr := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[0]) ) );
    CanShow := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;

procedure TPyApplication.EventOnShortCut( var Msg : TWMKey; var Handled : Boolean );
var
  args, rslt : PPyObject;
  L : TList;
begin
  L := TList.Create;
  try
    L.Add( CreateVarArg( GetPythonEngine.Py_None ).GetSelf ); 
    L.Add( CreateVarArg( GetPythonEngine.VariantAsPyObject( Handled ) ).GetSelf ); 
    rslt := ExecuteEvent( 'OnShortCut', TDelphiAssoc(__assoc__), L, args );
    Handled := GetPythonEngine.PyObjectAsVariant( ExtractValueOfVarArg( PPyObject(L.Items[1]) ) );
    GetPythonEngine.Py_XDecRef( rslt );
    GetPythonEngine.Py_XDecRef( args );
  finally
    L.Free;
  end;
end;


end.
