//設定語系 Function TForm1.M_SetLanguage(M_Form:String):String; var M_Component:TComponent; K,i,j:Integer; begin IF M_Language <>'TW' then begin With Form1.AdoQueryLang do begin Close; Sql.Clear; Sql.Add('Select * from M_Language Where M_Form =:kk and M_Software =:kk2'); Parameters.ParamValues['kk'] := M_Form; Parameters.ParamValues['kk2'] := 'BItem'; Open; end; while not Form1.AdoQueryLang.eof do begin for i:=0 to Application.ComponentCount-1 do begin if (Application.Components[i].Name = M_Form) and (Application.Components[i] is TForm) then begin M_Component := Application.Components[i].FindComponent( Form1.ADOQueryLang.FieldByName('M_CNName').AsString ); if Assigned(M_Component) then begin //如果 a 是 TLabel類的物件 if (M_Component is TLabel) then TLabel(M_Component).Caption := Form1.ADOQueryLang.FieldByName('M_Caption').AsString; IF (M_Component is TMenuItem) then TMenuItem(M_Component).Caption := Form1.ADOQueryLang.FieldByName('M_Caption').AsString; if (M_Component is TButton) then TButton(M_Component).Caption := Form1.ADOQueryLang.FieldByName('M_Caption').AsString; if (M_Component is TTabSheet) then TTabsheet(M_Component).Caption := Form1.ADOQueryLang.FieldByName('M_Caption').AsString; if (M_Component is TCheckBox) then TCheckBox(M_Component).Caption := Form1.ADOQueryLang.FieldByName('M_Caption').AsString; //DBGrid 說明 if (M_Component is TDBGrid) then Begin With Form1.AdoQueryLangD do begin Close; Sql.Clear; Sql.Add('Select * from M_LanguageD Where M_Form =:kk and M_Key =:kk3 order by M_ColumnNo'); Parameters.ParamValues['kk'] := M_Form; Parameters.ParamValues['kk3'] := Form1.ADOQueryLang.FieldByName('M_Key').AsInteger; Open; end; // IF Form1.ADOQueryLang.FieldByName('M_Key').AsInteger =1000 then begin // Showmessage(IntTostr(Form1.ADOQueryLangD.RecordCount)); // end; For k:=1 to Form1.ADoQueryLangD.RecordCount do begin // IF Form1.ADOQueryLang.FieldByName('M_Key').AsInteger =1000 then begin // Showmessage( IntTostr(TDBGrid(M_Component).FieldCount) ); // end; for j := 0 to -1 + TDBGrid(M_Component).FieldCount do begin Try if TDBGrid(M_Component).Fields[j].FieldName= Form1.ADOQueryLangD.FieldByName('M_FieldName').AsString then begin TDBGrid(M_Component).Columns[j].Title.Caption := Form1.ADOQueryLangD.FieldByName('M_Caption').AsString; Break; end;// if TDBGrid(M_Component).Fields[j].FieldName= Form1.ADOQueryLangD.FieldByName('M_FieldName').AsString then begin Except Showmessage('欄位錯誤!'); end; end;// for j := 0 to -1 + DBGrid1.FieldCount do AdoQueryLangD.Next; end;// For k:=0 to Form1.ADoQueryLangD.RecordCount do begin end; // if (M_Component is TDBGrid) then Begin end; // if Assigned(M_Component) then begin end; // if (Application.Components[i].Name = M_From) then begin end; // for i:=0 to Application.ComponentCount-1 dobegin Form1.AdoQueryLang.Next; end;// while not Form1.AdoQueryLang.eof do end;// IF M_Language <>'TW' then end;