unit uDendrite_3;

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, uBodyPlan, uInOutFrame, uSynapseFrame, uDendriteFrame, AbNumEdit;

type
  TfrmDendrite_3 = class(TForm)
    pnlControl: TPanel;
    cbOn: TCheckBox;
    btnDisconnect: TButton;
    btnDock: TButton;
    TDendriteFrame1: TDendriteFrame;
    PropSaveMain1: TPropSaveMain;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure btnDockClick(Sender: TObject);
    procedure cbOnClick(Sender: TObject);
    procedure btnDisconnectClick(Sender: TObject);
    procedure DendriteFramebtnResetDimensionsClick(Sender: TObject);
    procedure TDendriteFrame1btnTestClick(Sender: TObject);

  private
    { Private declarations }
    TagRec: TTagRec;
    procedure WMsetFunction(var Msg: TMessage); message WM_setFunction;
    procedure WMresetFunction(var Msg: TMessage); message WM_resetFunction;
    procedure WMExitSizeMove(var Msg: TMessage); message WM_EXITSIZEMOVE;
    procedure WMClose(var Msg: TMessage); message WM_CLOSE;
    procedure WMbAPFunction(var Msg: TMessage); message WM_bAPFunction;
  public
    { Public declarations }

  end;

var
  frmDendrite_3: TfrmDendrite_3;
  Input: Single;

implementation

{$R *.dfm}

uses INIFiles;

procedure TfrmDendrite_3.WMClose(var Msg: TMessage);
begin
  inherited;
  frmBodyPlan.DrawWires;
end;

procedure TfrmDendrite_3.WMExitSizeMove(var Msg: TMessage);
begin
  inherited;
  frmBodyPlan.DrawWires;
end;

procedure TfrmDendrite_3.btnDisconnectClick(Sender: TObject);
begin
  frmBodyPlan.RemoveEntry('Dendrite_3');
  Close;
end;

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

procedure TfrmDendrite_3.cbOnClick(Sender: TObject);
begin
  with frmBodyPlan.Dendrite_3 do
    begin
      if NOT cbOn.Checked then
        begin
          Appearance.Color := clSkyBlue;
          Font.Color := clWhite;
        end
      else
        begin
          Appearance.Color := clTeal;
          Font.Color := clWhite;
        end;
    end;

  TDendriteFrame1.On := cbOn.Checked;

end;

procedure TfrmDendrite_3.DendriteFramebtnResetDimensionsClick(Sender: TObject);
begin
  TDendriteFrame1.btnResetDimensionsClick(Sender);

end;

procedure TfrmDendrite_3.FormCreate(Sender: TObject);
begin
  Tag := NativeInt(@TagRec); // Needed Jim - Trust me.
  TDendriteFrame1.ThisBodyPart := 'Dendrite_3';
  TDendriteFrame1.Init;
  cbOnClick(Self);
end;

procedure TfrmDendrite_3.TDendriteFrame1btnTestClick(Sender: TObject);
begin
  TDendriteFrame1.btnTestClick(Sender);

end;

procedure TfrmDendrite_3.WMsetFunction(var Msg: TMessage);
begin
  TDendriteFrame1.ProcesssetFunctionMessage(Msg);
end;

procedure TfrmDendrite_3.WMresetFunction(var Msg: TMessage);
begin
  TDendriteFrame1.ProcesssetResetFunctionMessage(Msg);
end;

procedure TfrmDendrite_3.WMbAPFunction(var Msg: TMessage);
begin
  TDendriteFrame1.Manage_bAP_Message(Msg);
end;

end.
