Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mi 18.03.09 17:06 
Hallo,

ich möchte, dass man meine Form zwar verkleinern kann, dies jedoch nur zu einer bestimmten Größe. Beispielsweise soll die minimale Weite 50 Pixel sein.

Wie ist das möglich ? Ich habe schon einiges im OnResize-Event ausprobiert, aber leider hat das nicht zum Erfolg geführt.

Danke !!

Ciao LHUser


Moderiert von user profile iconGausi: Topic aus Windows API verschoben am Mi 18.03.2009 um 16:23
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 18.03.09 17:11 
Guck dir mal die Eigenschaft Constraints von Formular an. :wink:

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mi 18.03.09 17:41 
Naja, das hilft mir aber doch nicht weiter, oder ? Es gibt ja den Unterschied zwischen ClientWidth und Width bzw. MinWidth.

Wenn ich nun bei MinWidth einen Wert einstelle, kann ich ja nie sichergehen, dass der Wert exakt der ist, den ich als ClientWidth minimal haben will. Es wird immer der Rahmen mitgerechnet, der aber unterschiedlich sein kann.

Gibt es keine Eigenschaft MaxClientWidth o.ä. ?
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 18.03.09 18:30 
user profile iconLonghornUser hat folgendes geschrieben Zum zitierten Posting springen:
Naja, das hilft mir aber doch nicht weiter, oder ? Es gibt ja den Unterschied zwischen ClientWidth und Width bzw. MinWidth.

Wenn du ca. 30 px für die Mehr-Höhe und ca. 20px für die Mehr-Breite einplanst, dann kannst du ungefähr einen Bereich abtasten.

user profile iconLonghornUser hat folgendes geschrieben Zum zitierten Posting springen:
Wenn ich nun bei MinWidth einen Wert einstelle, kann ich ja nie sichergehen, dass der Wert exakt der ist, den ich als ClientWidth minimal haben will. Es wird immer der Rahmen mitgerechnet, der aber unterschiedlich sein kann.

Zwei Möglichkeiten:
1. Entwickle eine Anwendung, die einen gewissen Rahmen einfach zulässt oder
2. Lies die aktuelle Rahmeneinstellung von Windows aus (wie, weiß ich nicht)

user profile iconLonghornUser hat folgendes geschrieben Zum zitierten Posting springen:
Gibt es keine Eigenschaft MaxClientWidth o.ä. ?

Nein.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 18.03.09 20:24 
Wie wäre es ganz einfach mit GetSystemMetrics? ;-)
ausblenden Delphi-Quelltext
1:
2:
3:
GetSystemMetrics(SM_CXBORDER)
GetSystemMetrics(SM_CYBORDER)
GetSystemMetrics(SM_CYCAPTION)
Dann kannst du damit die richtigen Constraints beim Start ausrechnen.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mi 18.03.09 22:54 
Ah, das ist super. Vielen Dank dafür. Ich werde s gleich ausprobieren, obwohl ich es schwach finde, dass ein so grundlegendes Feature bei Delphi fehlt, währenddessen ClientHeight und ClientWidth an Bord sind.

Naja, ich versuchs mal.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 19.03.09 00:49 
Naja, im Allgemeinen ist es bei den Constraints nicht so wichtig, ob es ein paar Pixel mehr oder weniger sind. Denn wenn das Fenster in der Größe überhaupt veränderbar ist, dann muss es ja auch entsprechende Anpassungen drin haben.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 22.03.09 18:03 
OK, ich habe GetSystemMetrics mal ausprobiert, aber der Wert kann irgendwie nicht stimmen. Er gibt mir sowohl bei der Border X als auch bei Y als Wert "1" zurück. Die Kante ist aber viel breiter.

Und wenn ich ins OnCreate der Form schreibe
ausblenden Delphi-Quelltext
1:
2:
  Form1.Constraints.MinWidth := GetSystemMetrics(SM_CXBORDER)+780;
  Form1.Constraints.MinHeight := GetSystemMetrics(SM_CYBORDER)+545;

geht es demnach auch nicht zufriedenstellend :(
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 22.03.09 18:48 
Die Verhältnisse sollten eigentlich so sein:
ausblenden Delphi-Quelltext
1:
2:
FormX.Width = FormX.ClientWidth + 2*GetSystemMetrics(SM_CXBORDER)
FormX.Height = FormX.ClientHeight + GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYCAPTION)
Ich habe damit bei einer Skinkomponente für Rahmen und Titelleiste herumgespielt, das hat bei mir eigentlich gepasst.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 22.03.09 18:57 
Mhm, also ich habe mein Problem, wie ich es oben geschrieben habe, versucht zu lösen aber leider gibt er mir unter Vista (vielleicht hat das auch was zu sagen ??) für die Borders diese kleinen Werte aus. Width ist übrigens 796 wenn ClientWidth 780 ist. Das kann mit einer Border von 1 px nicht wirklich hinkommen :(
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 22.03.09 19:31 
Ja, bei in der Größe veränderbaren Fenstern ist der Rahmen SM_CXFRAME usw., das hatte ich falsch geschrieben. In der Dokumentation findest du diese Information aber auch:
msdn.microsoft.com/e...ibrary/ms724385.aspx

Bei mir sieht das unter Vista dann so aus, damit passt das:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Width: 1142
ClientWidth: 1126
SM_CXFRAME * 2: 16

Height: 656
ClientHeight: 620
SM_CYFRAME * 2: 16
SM_CYCAPTION: 20
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 22.03.09 20:05 
Ah, super. Vielen Dank.
Mr_Emre_D
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 114
Erhaltene Danke: 14



BeitragVerfasst: Mo 23.03.09 03:54 
Falls dir noch nicht geholfen werden konnte:

Fange die Message WM_GetMinMaxInfo ab und handle dementsprechend:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
TForm1 = class( TForm )
  ..
public
  ..
  procedure TForm1.GetMinMaxInfo(var Message: TWMGetMinMaxInfo);
  ..
end;

procedure TForm1.GetMinMaxInfo(var Message: TWMGetMinMaxInfo);
begin
  with Message.MinMaxInfo^ do
  begin
    ptMinTrackSize := Point( 320240 );
    ptMaxTrackSize := Point( 640480 );
  end;
end;


So mach ichs immer :)

MfG
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mo 23.03.09 08:20 
Intern macht Constraints auch nix anderes ;)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."