首页 > 其他分享 >delphi 底部panel实现打开窗体显示当前标签

delphi 底部panel实现打开窗体显示当前标签

时间:2023-03-11 18:34:23浏览次数:34  
标签:Name aSpeedButton Self aMDIChild TSpeedButton 窗体 delphi MDIChildren panel

  • delphi 底部panel实现打开窗体显示当前标签
  • procedure TForm_Main.Open_MDI_Child_Form(const aMDIFormClass: TFormClass;
      var aMDIForm; aMDIOwner: TComponent);
    var i, j: Integer;
      aMDIChild: TForm;
      aSpeedButton: TSpeedButton;
    begin
      j := -1;
      for i := 0 to Self.MDIChildCount - 1 do
      begin
        if Self.MDIChildren[i].ClassType = aMDIFormClass then
        begin
          j := i;
          //TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Enabled := True;
          TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Color := clMaroon;
          TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Style := [fsBold];
        end
        else
        begin
          //TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Enabled := False;
          TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Color := clBlack;
          TSpeedButton(FindComponent('btn_' + Self.MDIChildren[i].Name)).Font.Style := [];
        end;
      end;
      {
      if j <> -1 then
      begin
        aMDIChild := Self.MDIChildren[j];
        ShowWindow(aMDIChild.Handle, SW_SHOWMAXIMIZED);
        if (not aMDIChild.Visible) then aMDIChild.Visible := True;
        aMDIChild.BringToFront;
        aMDIChild.Setfocus;
        aMDIChild.Show;
        TForm(aMDIForm) := aMDIChild;
        Exit;
      end;
      }
      if j <> -1 then
      begin
        SpeedButtonClick(TSpeedButton(FindComponent('btn_' + Self.MDIChildren[j].Name)));
        Exit;
      end;
    
    
      aMDIChild := TForm(aMDIFormClass.NewInstance);
      TForm(aMDIForm) := aMDIChild;
      aMDIChild.Create(aMDIOwner);
    
      aSpeedButton := TSpeedButton.Create(Self);
      aSpeedButton.Parent := pnl_Bottom_Client;
      aSpeedButton.Name := 'btn_' + aMDIChild.Name;
      aSpeedButton.Caption := aMDIChild.Caption;
      aSpeedButton.Align := alLeft;
      aSpeedButton.Width := Length(aSpeedButton.Caption) * 9;
      aSpeedButton.Font.Size := 11;
      aSpeedButton.OnClick := SpeedButtonClick;
      aSpeedButton.Visible := True;
      SpeedButtonClick(aSpeedButton);
    end;

     

标签:Name,aSpeedButton,Self,aMDIChild,TSpeedButton,窗体,delphi,MDIChildren,panel
From: https://www.cnblogs.com/springcloud/p/17206669.html

相关文章