private
  // используется для заполнения всего экрана
  procedure WMSettingChange(var Msg: TMessage); message WM_SETTINGCHANGE;
public
  ActiveDetailForm: TForm; // Форма, которая активна в данный момент
  procedure SetActiveDetailForm(F: TForm; ParentControl: TWinControl);
end;
var
  frmIMMain: TfrmIMMain;
implementation
uses
  imdata, imSoftL, imSuppl, imEqDet, imDesk, imSpareP, imCateg,
  imLocL, imUserL, imEqList, imEqByUsr, imImpBlb, imSftLic, imSupL,
  imEqDetR, imRptPrm, imdmRep, imSftLicRepPrm, imSparePR, imSparePPrm,
  imSftDetR, imSoftDetRPrmDlg;
{$R *.DFM}
function GetWindowsWorkArea: TRect;
begin
  SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0);
end;
procedure TfrmIMMain.WMSettingChange( var Msg: TMessage);
var
  R: TRect;
begin
  if (Msg.WParam=SPI_SETWORKAREA) then
  begin
    R:=GetWindowsWorkArea;
    SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top);
  end;
  Msg.Result:=0;
end;
procedure TfrmIMMain.FormCreate(Sender: TObject);
var
  R: TRect;
begin
  // заполняем весь экран...
  R:=GetWindowsWorkArea;
  SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top);
end;
// показываем форму списка Software
procedure TfrmIMMain.acSoftwareListExecute(Sender: TObject);
begin
  if (Sender is TAction) then
  begin
    (Sender as TAction).Checked:=True;
    fcbSoftList.Down:=True;
  end;
  //paWorkArea это панель, которая использется, как управляющая для форм
  SetActiveDetailForm(frmIMSoftList, paWorkArea);
end;
// показываем форму "Оборудование"...
procedure TfrmIMMain.acEquipmentDetailsExecute(Sender: TObject);
begin
  if (Sender is TAction) then
  begin
    (Sender as TAction).Checked:=True;
    fcbEqDet.Down:=True;
  end;
  SetActiveDetailForm(frmIMEqDet, paWorkArea);
end;
// устанавливаем активную форму, чтобы выглядело как в MS outlook.......
// ParentControl это TPanel, но это может быть любой оконный элемент
// управления (который имеет оконное свойство Handle)
procedure TfrmIMMain.SetActiveDetailForm(F: TForm; ParentControl:
TWinControl);
begin
  if ActiveDetailForm<>F then
  begin
    if Assigned(ActiveDetailForm) then
      ActiveDetailForm.Hide;
    //следующие две линии делают то, что нам нужно...
    F.Parent:=ParentControl;
    F.Align:=alClient;
    ActiveDetailForm:=F;
    F.Show;
  end;
end;
procedure TfrmIMMain.FormActivate(Sender: TObject);
begin
  //устанавливаем форму по умолчанию при запуске.
  if not Assigned(ActiveDetailForm) then
    acEquipmentDetailsExecute(acEquipmentDetails);
end;
 |