Autor Beitrag
Elite
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 10.12.04 18:25 
Hab mal kurz nen Code geschrieben, durch den auch gleich alle Komponenten an die neue Größe angepasst werden. Funktioniert allerdings nicht mehr, sobald die Größenänderung allzu klein wird (bei 1-2pixels), weil dann der Vergrößerungsfaktor gegen 1 geht und damit nichts mehr bewirkt.
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:
procedure TForm1.FormCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
var
  XFaktor, YFaktor: extended;
  XRand, YRand: integer;
  a: integer;
begin
  XRand := width - clientwidth;
  YRand := height - clientheight;
  XFaktor := (NewWidth-XRand) / (Width-XRand);
  YFaktor := (NewHeight-YRand) / (Height-YRand);

  if (XFaktor > 1) and (YFaktor > 1) then
    Label1.Caption := (floattostr(XFaktor) + ' | ' + floattostr(YFaktor));

  for a := 0 to ComponentCount -1  do
    if (Components[a] is TControl) then
      with TControl(Components[a]) do
      begin
        Width := round(width*XFaktor);
        Left := round(left*XFaktor);
        Height := round(height*YFaktor);
        Top := round(top*YFaktor);
      end;
  resize := true;
end;

Vielleicht ist der Code ja für jemanden von Nutzen, müsste allerdings noch ausgebessert werden, indem man zu Programmstart das Originalgrößenverhältnis der Steuerelemente speichert und sich später nach diesem Verhältnis richtet. Damit sollte es dann keine Probleme mehr geben.
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 10.12.04 18:31 
Greg genau das ist mein Problem... Nur wie kriegt man das gelösst? :)
greg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 119

Windows2000, WindowsXP
D5 Prof
BeitragVerfasst: Fr 10.12.04 18:45 
Ich hab jetzt das da, erstmal als Minimallösung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.WndProc(var Message : TMessage);
begin
  if Message.WParam = SIZE_RESTORED then
  begin
    if Form1.Height <> TWMSIZE(Message).Height then
    begin
      Form1.Width := Round(4/3 * TWMSIZE(Message).Height);
    end else
    begin
      Form1.Height := Round(3/4 * TWMSIZE(Message).Width);
    end;
  end;
  inherited WndProc(Message);
end;


... aber es tut nicht :x Beim starten verschwindet das Formular :cry: naja vielleicht kann ich das ja irgendwann nochmal brauchen :wink:

Mein Kollege sagte noch etwas davon, dass ich irgendwie mitteilen müsste das SIZE_RESTORED 'Handled' ist :?:
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 13.12.04 12:32 
Weiss keiner wie das geht??? :(