Fórum Centralizar um panel no form #615840
25/05/2021
0
Códigos tentados:
1 ------------Panel1.Left := (Self.Width - Panel1.Width) div 2;
------------Panel1.Top := (Self.Height - Panel1.Height) div 2;
2 ------------APanel.Left := (AForm.ClientWidth div 2) - (APanel.Width div 2);
------------ APanel.Top := (AForm.ClientHeight div 2) - (APanel.Height div 2);
3------------panel1.top := (self.Height div 2) - (panel1.height div 2);
------------panel1.left := (self.Width div 2) - (panel1.width div 2);
Wanderson Cardoso
Curtir tópico
+ 0Post mais votado
25/05/2021
Procedure CentralizarPanel(AForm: TForm; APanel: TPanel); begin APanel.Left := (AForm.ClientWidth div 2) - (APanel.Width div 2); APanel.Top := (AForm.ClientHeight div 2) - (APanel.Height div 2); APanel.Update; AForm.Update; end;
Exemplo de uso, no evento OnResize do form:
CentralizarPanel(Self, Panel1);
Natanael Ferreira
Gostei + 2
Mais Posts
25/05/2021
Wanderson Cardoso
Procedure CentralizarPanel(AForm: TForm; APanel: TPanel); begin APanel.Left := (AForm.ClientWidth div 2) - (APanel.Width div 2); APanel.Top := (AForm.ClientHeight div 2) - (APanel.Height div 2); APanel.Update; AForm.Update; end;
Exemplo de uso, no evento OnResize do form:
CentralizarPanel(Self, Panel1);
Debugando ele centralizou e depois quando chega na sengunda linha dessa procedure ele da 'access violation'
Mas valeu pela dica!
Todo conhecimento e bom!
Gostei + 0
25/05/2021
Wanderson Cardoso
Tava chamando de um form que não foi estanciado!
Agora funcionou valeu
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)