Autor Beitrag
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 09:55 
Nur mal so nebenbei.
Ich gehe einen Ordner (languages) im Pfad des Programmes durch und lese alle Sprachedateien (.lang) in ein Menü.
Dies soll der Anwender auswählen können und bei Programmende wird diese .lang Datei in die Programm Ini gespeichert, damit beim nächsten öffnen diese wieder geladen wird.

@jaenicke
im Moment stehe ich noch etwas auf dem Schlauch wie ich deinen Vorschlag umsetzen muss.
Könntest dur mir noch einen weiteren Tip geben?

Vielen Dank
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.12.08 09:59 
:roll: Ich habs doch schon fast exakt geschrieben wie die Abfrage sein muss.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
    if AForm.Name = ComponentName then
        AForm.Caption := ACaption
    else if AForm.FindComponent(ComponentName) is TRadioGroup then
    ...
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 10:09 
Danke für deine Antwort.

Und in der .lang Datei würde dann

Form1:Testform

als Caption für "Form1" abgerufen werden oder?
Bei mir funktioniert es nämlich nicht.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.12.08 10:11 
Ich habs nicht ausprobiert, du kannst ja nen Haltepunkt da setzen und schauen was passiert. Ich hätte vermutet, dass es so richtig ist.
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 10:15 
ich habe mal einen Haltepunkt auf
ausblenden Delphi-Quelltext
1:
  AForm.Caption := ACaption					

gesetzt und da läuft er munter drüber.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.12.08 10:17 
Ich meinte eher auf die if-Abfrage, denn wenn du in der Sprachdatei die Zeile als erstes schreibst kommt das Programm ja als erstes dort an. ;-)
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 10:17 
Habe ich auch.
Dort wurde gestoppt.
Es geht auch erst weiter wenn der Haltepunkt entfernt wurde.
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 13:13 
ich denke es hat etwas mit folgender funktion zu tun.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function ParseFileEntry(FileEntry: Stringvar Components: TFileEntryComponent): Boolean;
//Example:
//  MyTestLabel1:Hello world
//  Name:Caption
begin
    try
  Components.ComponentName := Copy(FileEntry, 1, Pos(':', FileEntry) - 1);
  Delete(FileEntry, 1, Pos(':', FileEntry));
  Components.Caption := FileEntry;
  Result := true;
    except
  Result := false;
    end;
end;

da hier auch nur die Komponenten angesprochen werden (wenn ich das richtig verstehe)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.12.08 13:27 
Das dient nur zum Parsen soweit ich das sehe.

Ok ok, ich werde es mal wirklich ansehen und testen statt den Quelltext nur zu überfliegen. (Ich hatte gedacht das würde genügen.) ;-)
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Di 16.12.08 14:03 
Nette Idee, aber Spaltenübersichriften bei Grids sowie Support für TreeViews, Listviews usw. und Drittkomponenten fehlt, oder hab ich was übersehen?

_________________
Na denn, dann. Bis dann, denn.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.12.08 14:07 
Das kann man ja anpassen, user profile iconAXMD hat die Unit ja für sein Projekt entwickelt und nicht als allumfassende Lösung...
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 14:10 
1000 Dank
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.12.08 14:51 
user profile iconbayou hat folgendes geschrieben Zum zitierten Posting springen:
Und in der .lang Datei würde dann

Form1:Testform

als Caption für "Form1" abgerufen werden oder?
Bei mir funktioniert es nämlich nicht.
Ich hab nochmal überlegt woran das liegen könnte. Kann es sein, dass du die Überprüfung ob die Komponente existiert noch davor hattest? Das ist natürlich nicht der Fall. Richtig wäre es deshalb so komplett eingebaut: (ungetestet)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
Function AssignCaption(AForm: TForm; ComponentName, ACaption: String): Boolean;
Var
    p: PPropInfo;
    i: Integer;
    RadioGroup: TRadioGroup;
Begin
    Result := false;
    if AForm.Name = ComponentName then
    begin
        AForm.Caption := ACaption;
        Result := True;
        Exit;
    end
    else if AForm.FindComponent(ComponentName) = Nil Then //Does component exist?
        exit
    else if AForm.FindComponent(ComponentName) is TRadioGroup then
    begin
        RadioGroup := TRadioGroup(AForm.FindComponent(ComponentName));
        for i := 0 to RadioGroup.Items.Count - 1 do
        begin
            if Pos(';', ACaption) = 0 then
              RadioGroup.Items[i] := ACaption
            else
              RadioGroup.Items[i] := Copy(ACaption, 1, Pos(';', ACaption) - 1);
            Delete(ACaption, 1, Pos(';', ACaption));
        end;
        Result := True;
        Exit;
    end;
    Try
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 16.12.08 16:41 
Spitze, es geht.
Vielen vielen Dank
Da wäre ich nie drauf gekommen.
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Mi 17.12.08 10:38 
Ich habe es noch etwas ergänzt damit man auch den Titel der RadioGroup bekommt.
Sollte kein Titel genutzt werden bleibt der erste Eintrag frei
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
    else if AForm.FindComponent(ComponentName) is TRadioGroup then
    begin
  RadioGroup := TRadioGroup(AForm.FindComponent(ComponentName));
     RadioGroup.Caption := Copy(ACaption, 1, Pos(';', ACaption) - 1);
     Delete(ACaption, 1, Pos(';', ACaption));
  for i := 0 to RadioGroup.Items.Count - 1 do
        begin  
      if Pos(';', ACaption) = 0 then
        RadioGroup.Items[i] := ACaption
      else
        RadioGroup.Items[i] := Copy(ACaption, 1, Pos(';', ACaption) - 1);
      Delete(ACaption, 1, Pos(';', ACaption));
        end;  
        Result := True;  
        Exit;  
    end;

für StringGrid konnte ich diese Lösung anpassen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
    else if AForm.FindComponent(ComponentName) is TStringGrid then
    begin
  StringGrid := TStringGrid(AForm.FindComponent(ComponentName));
  for i := 0 to StringGrid.ColCount - 1 do
  begin
      if Pos(';', ACaption) = 0 then
        StringGrid.Cells[i, 0] := ACaption
      else
        StringGrid.Cells[i, 0] := Copy(ACaption, 1, Pos(';', ACaption) - 1);
      Delete(ACaption, 1, Pos(';', ACaption));
  end;
  Result := True;
  Exit;
    end

auch hier wird der erste Eintrag einfach frei gelassen wenn in der 1. Spalte nichts stehen soll.
StringGrid1:;Spalte2;Spalte3

Bitte sagte mir wenn ich Fehler darin haben sollte.

Nochmals vielen Dankfür die Hilfe
MDX
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 595
Erhaltene Danke: 4

Windows 8.1, Linux Debian 8, Android Lollipop
Delphi, PHP, Java (Android)
BeitragVerfasst: Sa 28.03.09 21:25 
Wie kann man das für ne Combobox nutzen???
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 28.03.09 21:50 
Ich sag mal so: Ob es sinnvoll ist, ist die Frage, aber generell kannst du natürlich auch die Werte einer ComboBox reinschreiben. Du musst das ja nur entsprechend anpassen.

Je umfangreicher das wird, desto besser wäre eine professionellere Lösung, da gibts ja einige Möglichkeiten. Von den delphiinternen bis zu String Ressource Managern und externen Multilanguage-Tools.