unit uDendriteClone;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, Vcl.ComCtrls,
  Vcl.Menus, Vcl.StdCtrls, uNeuronTypes,
  AdvShape, Vcl.ExtCtrls,
  PropSaveMain, Vcl.Buttons, uDendriteFrame, uBodyPlan, uInOutFrame, uDimsFrame;

type
  TfrmDendrite_1 = class(TForm)
    PropSaveMain: TPropSaveMain;
    pnlControl: TPanel;
    cbOn: TCheckBox;
    btnDisconnect: TButton;
    btnDock: TButton;
    DendriteFrame: TDendriteFrame;

    procedure FormCreate(Sender: TObject);
    procedure btnDockClick(Sender: TObject);
    procedure cbOnClick(Sender: TObject);
    procedure btnDisconnectClick(Sender: TObject);

  private
    { Private declarations }
    procedure WMsetFunction(var Msg: TMessage); message WM_setFunction;
    procedure WMresetFunction(var Msg: TMessage); message WM_resetFunction;

  public
    { Public declarations }
    recMessage: TSetMessage;
    TagRec: TTagRec;
  end;

var
  frmDendrite_1: TfrmDendrite_1;
  Input: Single;

implementation

{$R *.dfm}

uses INIFiles;

procedure TfrmDendrite_1.btnDisconnectClick(Sender: TObject);
begin
  frmBodyPlan.RemoveEntry('Dendrite_1');
end;

procedure TfrmDendrite_1.btnDockClick(Sender: TObject);
begin
  with frmBodyPlan do
    begin
      RemoveEntry('Dendrite_1');
      RenumberGrid;
      Dendrite_1.Parent := pnlDendrites;
      Dendrite_1.Left := 15;
      Dendrite_1.Top := 40;
      SetSmallestIconToFront(pnlDendrites);
    end;
  close;
end;

procedure TfrmDendrite_1.cbOnClick(Sender: TObject);
begin
  with frmBodyPlan.Dendrite_1 do
    begin
      if NOT cbOn.Checked then
        begin
          Appearance.Color := clSkyBlue;
          Font.Color := clBlack;
          close;
        end
      else
        begin
          Appearance.Color := clBlue;
          Font.Color := clWhite;

        end;
    end;

  DendriteFrame.FOn := cbOn.Checked;
  frmBodyPlan.DrawWires;
end;

procedure TfrmDendrite_1.FormCreate(Sender: TObject);
begin
  Tag := NativeInt(@TagRec);
  TagRec := PTagRec(Tag)^; // Pick up the local tag
  DendriteFrame.ThisBodyPart := 'Dendrite_1';
  DendriteFrame.FOn := cbOn.Checked;
  DendriteFrame.Init;

end;

procedure TfrmDendrite_1.WMsetFunction(var Msg: TMessage);
begin
  DendriteFrame.ProcesssetFunctionMessage(Msg);
end;

procedure TfrmDendrite_1.WMresetFunction(var Msg: TMessage);
begin
  DendriteFrame.ProcesssetResetFunctionMessage(Msg);
end;

end.
