var
RHS:Tform;
procedure TMainForm.ShowRHS(FormName:Tform); // Embed named form into RHS Panel and show it. Allows us to split program into different forms
begin
if RHS<>nil then RHS.Close;
RHS:=formname;
RHS.Align := alClient;
RHS.BorderStyle := bsNone;
RHS.parent := RHSPanel;
RHS.show;
RHSPanel.caption:='';
cfg.activeform:=string(formname.Name);
RHS.BorderWidth:=2;
end;
procedure TMainForm.b1Click(Sender: TObject); // all buttons on left hand side have there onclick event go here and we embed the correct form..
begin
if sender=b1 then ShowRHS(HomeForm) else b1.Font.color:=cldefault;
if sender=b2 then ShowRHS(SalesOrdersForm) else b2.Font.color:=cldefault;
if sender=b3 then ShowRHS(DryStockForm) else b3.Font.color:=cldefault;
if sender=b5 then ShowRHS(SemiFinishedStockForm) else b5.Font.color:=cldefault;
if sender=b6 then ShowRHS(DemandForm) else b6.Font.color:=cldefault;
if sender=b7 then ShowRHS(ReportsForm) else b7.Font.color:=cldefault;
if sender=b8 then ShowRHS(DispatchForm) else b8.Font.color:=cldefault;
if sender=b9 then ShowRHS(PurchaseOrderForm) else b9.Font.color:=cldefault;
if sender=b10 then ShowRHS(StockControlForm) else b10.Font.Color:=cldefault;
if sender=b11 then ShowRHS(AccountingForm) else b11.Font.color:=cldefault;
if sender=b12 then ShowRHS(WetStockForm) else b12.Font.color:=cldefault;
TBitBtn(sender).Font.color:=clblue;
cfg.user.LastForm:=TBitBtn(sender).tag; // so I can save which form the user was looking at and restore it on open
end;