Autor Beitrag
Andidreas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114

Windows XP Pro
BDS 2006
BeitragVerfasst: So 17.09.06 12:50 
Wie kann ich ein Fenster auf Titelleistengröße zusammen rollen und bei klick auf die Titelleiste wieder auf seine ursprüngliche Größe bringen?

Dank im voraus
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Mo 18.09.06 11:47 
user profile iconAndidreas hat folgendes geschrieben:
Wie kann ich ein Fenster auf Titelleistengröße zusammen rollen und bei klick auf die Titelleiste wieder auf seine ursprüngliche Größe bringen?

Dank im voraus


Hallo,

die Fensterhöhe wird einfach mit Form1.Height := (Höhe in Pixel) geändert, du solltest allerdings vorher mit GetSystemMetrics feststellen, wie hoch die Menüleiste ist, damit es immer und überall gut aussieht. Es darf natürlich unter "Constraints" keine minimale Höhe eingetragen sein.

Wann? Am besten baust du einen Button dafür ein, z.B. mit einem Pfeil nach oben.

Zurück? Am besten mit OnActivate: sobald das Formular den Focus erhält, kehrt es zur vorherigen Grösse zurück.

Gruss Reinhard
Carl Johnson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D3
BeitragVerfasst: Mo 18.09.06 12:57 
Es kann sein, dass das OnActivate-Event des Formulars nicht funktioniert.

Dann probier mal, Application.OnActivate das OnActivate deiner Form zuzuweisen.

Das klappt, hab es ausprobiert.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 18.09.06 13:45 
user profile iconReinhard Kern hat folgendes geschrieben:
du solltest allerdings vorher mit GetSystemMetrics feststellen, wie hoch die Menüleiste ist, damit es immer und überall gut aussieht.

Wieso nicht einfach ClientHeight auf 0?

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Mo 18.09.06 14:59 
user profile iconjakobwenzel hat folgendes geschrieben:
user profile iconReinhard Kern hat folgendes geschrieben:
du solltest allerdings vorher mit GetSystemMetrics feststellen, wie hoch die Menüleiste ist, damit es immer und überall gut aussieht.

Wieso nicht einfach ClientHeight auf 0?


Hallo,
das ist nicht genau dasselbe, die Hilfe zu TForm.ClientHeight hört sich so an, als ob bei Clientheight eine Statusbar berücksichtigt wird, ich bin mir aber nicht sicher, ob das stimmt. Die Höhe der Menüleiste ist jedenfalls genau das, was er will. Den unteren Rahmen sollte man ja auch nicht sehen.

Gruss Reinhard
Andidreas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114

Windows XP Pro
BDS 2006
BeitragVerfasst: Mo 18.09.06 16:11 
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:
50:
51:
52:
53:
54:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
     Form1.ClientHeight := 0;
     Form1.ClientWidth :=426;
end;

procedure TForm1.FormDblClick(Sender: TObject);
begin
    if Form1.ClientHeight > 0 then
     begin
       Form1.ClientHeight := 0;
       Form1.ClientWidth := 426;
     end
     else
     begin
       Form1.ClientHeight :=  256;
       Form1.ClientWidth := 426;
     end;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
     Form1.Top := 233;
     Form1.Left := 750;
end;

end.


Dann probierts mal aus. Schön ist es nicht beim Aufklappen.

Moderiert von user profile iconUGrohne: Delphi-Tags hinzugefügt.
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Mi 20.09.06 14:39 
Hallo,

das Problem mit OnActivate ist nur, dass das Formular den Focus behält und daher OnActivate nicht eintritt - Ein Focus auf ein aufgerolltes Formular ist aber eh sinnlos, also nehm ich ihm den Focus weg und setze ihn auf das Hauptfenster. Dann funktioniert das Wiederaufrollen des Fensters wie gewünscht, der Aufwand ist gering:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TFrm_Test.Bt_RollupClick(Sender: TObject);
begin
self.ClientHeight := 0;
RKMainForm.SetFocus;
end;

 { note : Form should have FormStyle = fsStayOnTop! }
procedure TFrm_Test.FormActivate(Sender: TObject);
begin
self.ClientHeight := 200;
end;


Anmerkung: wenn das Formular nicht Stay-On-Top ist, geht es schnell verloren, v.a. als nackte Titelleiste.

Gruss Reinhard
Andidreas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114

Windows XP Pro
BDS 2006
BeitragVerfasst: Mi 20.09.06 16:41 
Klasse. Funktioniert bestens. Herzlichen Dank nochmal