Autor Beitrag
jakob.scholbach
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 27.08.06 22:18 
Hallo Leute,

ich habe ein Formular X mit einer ImageList, dann ein Formular Y mit einem MainMenu, deren Icons aus X.ImageList kommen. Das klappt normalerweise ja ganz gut. Jetzt aber das Problem: ich verwende verschiedene Sprachdateien für die Oberfläche in verschiedenen Sprachen (habe dann eine .deu und .enu-Datei usw.). Ergebnis: das Menü zeigt die Icons nicht mehr an.

Woran könnte das liegen? Wenn ich dann zur Laufzeit Y.MainMenu.Images = X.ImageList setze, klappt es wieder.

Danke. Gruß aus Leipzig,

Jakob
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 27.08.06 22:46 
Moin!

Glaskugel hat folgendes geschrieben:
Out of Source Error: Bitte die Eingabe mit mehr Quelltext wiederholen!

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
jakob.scholbach Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 27.08.06 22:54 
Naja, der Quellcode ist nicht groß, eigentlich gibt es gar keinen

// zur Entwicklungszeit (im Objektinspektor gesetzt)
Y.MainMenu.Images = X.ImageList

Dann habe ich eine Projektdatei mit dem eigentlichen Projekt und zwei Sprachen. Wenn ich die Sprachdateien (z.B .enu) mitbenutze (dies mach ich wie folgt), dann gibt es das beschriebene Problem, daß zur Laufzeit die Icons einfach nicht angezeigt werden.

Danke, Jakob

ausblenden Delphi-Quelltext
1:
2:
  if LoadNewResourceModule(English) <> 0 then
    ReinitializeForms;


Hier noch die Funktion (funktioniert eigentlich bisher tadellos)
ausblenden volle Höhe 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:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
function LoadNewResourceModule(Locale: LCID): LongInt;
var
  FileName: array [0..260of char;
  P: PChar;
  LocaleName: array[0..4of Char;
  NewInst: LongInt;

begin
  GetModuleFileName(HInstance, FileName, SizeOf(FileName));
  GetLocaleInfo(Locale, LOCALE_SABBREVLANGNAME, LocaleName, SizeOf(LocaleName));
  P := PChar(@FileName) + lstrlen(FileName);
  while (P^ <> '.'and (P <> @FileName) do Dec(P);
  NewInst := 0;
  Result := 0;
  if P <> @FileName then
  begin
    Inc(P);
    if LocaleName[0] <> #0 then
    begin
      // Then look for a potential language/country translation
      lstrcpy(P, LocaleName);
      NewInst := LoadLibraryEx(FileName, 0, LOAD_LIBRARY_AS_DATAFILE);
      if NewInst = 0 then
      begin
        // Finally look for a language only translation
        LocaleName[2] := #0;
        lstrcpy(P, LocaleName);
        NewInst := LoadLibraryEx(FileName, 0, LOAD_LIBRARY_AS_DATAFILE);
      end;
    end;
  end;
  if NewInst <> 0 then
    Result := SetResourceHInstance(NewInst)
end;

procedure ReinitializeForms;
var
  Count: Integer;
  I: Integer;
  Form: TForm;

begin
  Count := Screen.FormCount;
  for I := 0 to Count-1 do
  begin
    Form := Screen.Forms[I];
    ReloadInheritedComponent(Form, TForm);
  end;
end;