⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sstoreutils.pas

📁 AlphaControls是一个Delphi标准控件的集合
💻 PAS
📖 第 1 页 / 共 2 页
字号:
                  'Item' + IntToStr(i),
                  IntToStr(Grid.Columns[i].Width),
                  IniFile);
    end;
  finally
    FreeAndNil(IniFile);
  end;
}
end;

procedure RestoreOurGrid(IniFileName: string; Grid:TDBGridEH);
//var
//  i, j : integer;
//  s : string;
//  f: TCustomForm;
//  r:TIniFile;
begin
  Grid.RestoreColumnsLayoutIni(IniFileName, 'T' + GetParentForm(Grid).Name, [crpColWidthsEh]);
{
  f := GetParentForm(Grid);
  r := TIniFile.Create(IniFileName);
  try
    for i := 0 to Grid.Columns.Count - 1 do begin
      j := ReadIniInteger('T' + f.Name + Grid.Name, 'Item' + IntToStr(i), -1, r);
      if j <> -1 then begin
        Grid.Columns[i].Width := j;
      end;
    end;
  finally
    FreeAndNil(r);
  end;
}  
end;
{$ENDIF}

procedure RestoreCaptions(Form: TForm; IniFileName: string);
var
  i : integer;
  s : string;
//  m : TMessage;
  r : TMemIniFile;
begin
  Exit;
  r := TMemIniFile.Create(IniFileName);

  s := ReadIniString('T' + Form.Name, Form.Name + '_Caption', r);
  Form.Caption := iff(s<>'', s, Form.Caption);

  for i := 0 to Form.ComponentCount-1 do begin
    s := UpperCase(Form.Components[i].ClassName);
    if Form.Components[i] is TLabel then begin // TLabel
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
      TLabel(Form.Components[i]).Caption := iff(s<>'', s, TLabel(Form.Components[i]).Caption);
    end else
    if Form.Components[i] is TAction then begin // TAction
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
      if s<>'' then TAction(Form.Components[i]).Caption := s;
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Hint', r);
      TAction(Form.Components[i]).Hint := iff(s<>'', s, TAction(Form.Components[i]).Hint);
    end else
    if Form.Components[i] is TsCheckedControl then begin // TCheckBox
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
      TsCheckedControl(Form.Components[i]).Caption := iff(s<>'', s, TsCheckedControl(Form.Components[i]).Caption);
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Hint', r);
      TsCheckedControl(Form.Components[i]).Hint := iff(s<>'', s, TsCheckedControl(Form.Components[i]).Hint);
    end else
    if Form.Components[i] is TMenuItem then begin // TMenuItem
      if not Assigned(TMenuItem(Form.Components[i]).Action) then begin
        s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
        TMenuItem(Form.Components[i]).Caption := iff(s<>'', s, TMenuItem(Form.Components[i]).Caption);
        s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Hint', r);
        TMenuItem(Form.Components[i]).Hint := iff(s<>'', s, TMenuItem(Form.Components[i]).Hint);
      end;
    end else
{$IFDEF USEDB}
    if Form.Components[i] is TField then begin // TField
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_DisplayLabel', r);
      TField(Form.Components[i]).DisplayLabel := iff(s<>'', s, TField(Form.Components[i]).DisplayLabel);
    end else
{$ENDIF}    
    if Form.Components[i] is TToolButton  then begin //TToolButton
      if not Assigned(TToolButton(Form.Components[i]).Action) then begin
        s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
        TToolButton(Form.Components[i]).Caption := iff(s<>'', s, TToolButton(Form.Components[i]).Caption);
        s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Hint', r);
        TToolButton(Form.Components[i]).Caption := iff(s<>'', s, TToolButton(Form.Components[i]).Hint);
      end;
    end else
    if Form.Components[i] is TTabSheet then begin // TTabSheet
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
      TTabSheet(Form.Components[i]).Caption := iff(s<>'', s, TTabSheet(Form.Components[i]).Caption);
    end else
    if Form.Components[i] is TSpeedButton then begin // TSpeedButton
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
      TSpeedButton(Form.Components[i]).Caption := iff(s<>'', s, TSpeedButton(Form.Components[i]).Caption);
    end else
    if Form.Components[i] is TsCheckedControl then begin // TsCheckedControl
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_Caption', r);
      TsCheckedControl(Form.Components[i]).Caption := iff(s<>'', s, TsCheckedControl(Form.Components[i]).Caption);
    end;

    try
    if (GetStyleInfo(Form.Components[i]) > tos_SCUSTOMSTYLE) and (TsCustomStyle(GetsStyle(TWinControl(Form.Components[i]))).Caption.Text <> '') then begin // TsStyle.Caption
      s := ReadIniString('T' + Form.Name, Form.Components[i].Name + '_sCaption', r);
      TsCustomStyle(GetsStyle(TWinControl(Form.Components[i]))).Caption.Text := iff(s<>'', s, TsCustomStyle(GetsStyle(TWinControl(Form.Components[i]))).Caption.Text);
    end;
    except
      ShowMessage(Form.Components[i].Name);
    end;
  end;
end;

procedure SaveCaptions(Form: TForm; IniFileName: string);
//var
//  i : integer;
//  s : string;
//  r : TIniFile;
begin
(*
  r := TIniFile.Create(IniFileName);

  WriteIniStr('T' + Form.Name, Form.Name + '_Caption', Form.Caption, r);
  for i := 0 to Form.ComponentCount-1 do begin
//    s := UpperCase(Form.Components[i].ClassName);
    if Form.Components[i] is TLabel then begin // TLabel
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TLabel(Form.Components[i]).Caption, r);
    end else
    if Form.Components[i] is TAction then begin // TAction
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TAction(Form.Components[i]).Caption, r);
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Hint', TAction(Form.Components[i]).Hint, r);
    end else
    if Form.Components[i] is TsCheckedControl then begin // TCheckBox
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TsCheckedControl(Form.Components[i]).Caption, r);
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Hint', TsCheckedControl(Form.Components[i]).Hint, r);
    end else
    if Form.Components[i] is TMenuItem then begin // TMenuItem
      if not Assigned(TMenuItem(Form.Components[i]).Action) then begin
        WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TMenuItem(Form.Components[i]).Caption, r);
        WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Hint', TMenuItem(Form.Components[i]).Hint, r);
      end;
    end else
{$IFDEF USEDB}
    if Form.Components[i] is TField then begin // TField
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_DisplayLabel', TField(Form.Components[i]).DisplayLabel, r);
    end else
{$ENDIF}    
    if Form.Components[i] is TToolButton  then begin //TToolButton
      if not Assigned(TToolButton(Form.Components[i]).Action) then begin
        WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TToolButton(Form.Components[i]).Caption, r);
        WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Hint', TToolButton(Form.Components[i]).Hint, r);
      end;
    end else
    if Form.Components[i] is TTabSheet then begin // TTabSheet
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TTabSheet(Form.Components[i]).Caption, r);
    end else
    if Form.Components[i] is TSpeedButton then begin // TSpeedButton
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TSpeedButton(Form.Components[i]).Caption, r);
    end else
    if Form.Components[i] is TsCheckedControl then begin // TsCheckedControl
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_Caption', TsCheckedControl(Form.Components[i]).Caption, r);
    end;
    if (GetStyleInfo(Form.Components[i]) > tos_SCUSTOMSTYLE) and (TsCustomStyle(GetsStyle(TWinControl(Form.Components[i]))).Caption.Text <> '') then begin // TsStyle.Caption
      WriteIniStr('T' + Form.Name, Form.Components[i].Name + '_sCaption', TsCustomStyle(GetsStyle(TWinControl(Form.Components[i]))).Caption.Text, r);
    end;
  end;
  FreeAndNil(r);
*)  
end;

procedure SaveFormPlacement(Form: TForm; IniFileName: string);
begin
{$IFNDEF DEMO}
  if Form.WindowState = wsNormal then begin
    WriteIniStr(Form.Name, 'Left', IntToStr(Form.Left), IniFileName);
    WriteIniStr(Form.Name, 'Top', IntToStr(Form.Top), IniFileName);
    WriteIniStr(Form.Name, 'Width', IntToStr(Form.Width), IniFileName);
    WriteIniStr(Form.Name, 'Height', IntToStr(Form.Height), IniFileName);
  end;
  WriteIniStr(Form.Name, 'State', IntToStr(ord(Form.WindowState)), IniFileName);
{$ENDIF}
end;

procedure RestoreFormPlacement(Form: TForm; IniFileName: string);
{$IFNDEF DEMO}
var
//  r : TRect;
  i : integer;
  ws : TWindowState;
{$ENDIF}
begin
{$IFNDEF DEMO}
  i := ReadIniInteger(Form.Name, 'State', -1, IniFileName);
  if i = -1 then Exit;
  ws := aWindowStates[i];

  Form.WindowState := ws;
  if ws = wsNormal then begin
    i := ReadIniInteger(Form.Name, 'Left', -1, IniFileName);
    if i <> -1 then begin
      Form.Left := i;
    end;
    i := ReadIniInteger(Form.Name, 'Top', -1, IniFileName);
    if i <> -1 then begin
      Form.Top := i;
    end;
    i := ReadIniInteger(Form.Name, 'Width', -1, IniFileName);
    if i <> -1 then begin
      Form.Width := i;
    end;
    i := ReadIniInteger(Form.Name, 'Height', -1, IniFileName);
    if i <> -1 then begin
      Form.Height := i;
    end;
  end;
{$ENDIF}
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -