Hello! First of all — a short introduction.
For self-education purposes, I am writing a small game: Mine Sweeper with RPG influence. Since I am completely unfamiliar with LCL, my development cycle looks like writing code → google → RTFM and repeat. But from time to time I really get stuck.
Now I am trying to figure out how Constraints work. I am using Lazarus 3.6 on Windows 10 if it matters.
As it is said in the documentation, Constraints have the highest priority above Aligning, Anchoring and so on, but maybe I understand something wrong. As
I see, it works at design stage, but not at runtime.
Below is my test code.
Most of controls have MinHeight and/or MinWidth set.
When I set TForm1.AutoSize things go wrong. And when I resizing the main window manually things go even worse.
No doubt I'm missing something or misunderstand how Constraints work. But what?
In attach — published project,
screenshot 1 is what I expect (approximately),
screenshot 2 is what I get.
implementation
{$R *.lfm}
procedure TForm1.Panel1Resize(Sender: TObject);
begin
Label3.Top := ( Panel1.Height - (Label3.Height + Image2.Height) ) div 2;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Self.AutoSize := True;
end;
procedure TForm1.Button_FormHeight_minus_10Click(Sender: TObject);
begin
self.Height := self.Height - 10;
end;
procedure TForm1.Button_FormHeight_plus_10Click(Sender: TObject);
begin
self.Height := self.Height + 10;
end;
procedure TForm1.Button_FormWidth_minus_10Click(Sender: TObject);
begin
self.Width := self.Width - 10;
end;
procedure TForm1.Button_FormWidth_plus_10Click(Sender: TObject);
begin
self.Width := self.Width + 10;
end;
end.