2017年9月20日 星期三

Delphi 列出所有 Component / 元件

http://theprofessionalspoint.blogspot.tw/2012/11/how-to-find-all-components-and-controls.html

procedure MyForm.DisableAllButtons;
var
  i : integer;
begin
  try
    for i := 0 to ComponentCount - 1 do
    begin
      if Components[i] is TButton then //Check whether the component is button or anything else
      begin
        MyForm(Components[i]).Enabled := False;
      end;
    end;
   
  except
    on E : Exception do
    begin
      ShowMessage('Error occured in function DisableAllButtons: ' + E.Message);
      exit;
    end;
  end;
end;


    for i := 0 to frmMain.ComponentCount -1 do
    if ( frmMain.Components[i] is TAdvSmoothLabel ) then
    if TAdvSmoothLabel(frmMain.Components[i]).Name = 'projNameLabel' then

        TAdvSmoothLabel(frmMain.Components[i]).Caption.Text := appVar.appName;

2017年9月17日 星期日

Delphi 清空 Type 內所有內容 emptyBFT750Info: TBFT750Info = ();





https://stackoverflow.com/questions/5509394/how-can-i-quickly-clear-a-record-of-simple-types
var
  MyList : TListSignals;
begin
     ZeroMemory(@Mylist,SizeOf(MyList));
end;

Delphi 清空 Type 內所有內容 emptyBFT750Info: TBFT750Info = ();