1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| procedure TForm1.Button2Click(Sender: TObject);
var
X, Y, CYFrame, CXFrame, CXSize, CYSize: Integer;
begin
CYFrame := GetSystemMetrics(SM_CYFRAME); // Hauteur bordure
CXFrame := GetSystemMetrics(SM_CXFRAME);
CXSize := GetSystemMetrics(SM_CXSIZE); // Largeur bouton barre de titre
CYSize := GetSystemMetrics(SM_CYSIZE);
Canvas.Handle := GetWindowDC(Self.Handle);
try
Y := (CYSize + (2 * CYFrame) - Canvas.TextHeight('W')) div 2 ;
//ShowMessage(IntToStr(Y)); // = 11
X := (CXSize + (2 * CXFrame) - Canvas.TextHeight('Z')) div 2 ;
//ShowMessage(IntToStr(X)); // = 17
Canvas.TextOut(X, Y, 'Test2');
finally
ReleaseDC(Self.Handle, Canvas.Handle);
Canvas.Handle := 0;
end;
end; |
Partager