https://www.swissdelphicenter.ch/en/showcode.php?id=921
www.teamb.com
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]
Tip Rating (38):
procedure MakeRounded(Control: TWinControl);
var
R: TRect;
Rgn: HRGN;
begin
with Control do
begin
R := ClientRect;
rgn := CreateRoundRectRgn(R.Left, R.Top, R.Right, R.Bottom, 20, 20);
Perform(EM_GETRECT, 0, lParam(@r));
InflateRect(r, - 5, - 5);
Perform(EM_SETRECTNP, 0, lParam(@r));
SetWindowRgn(Handle, rgn, True);
Invalidate;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// TMemo:
Memo1.BorderStyle := bsNone;
MakeRounded(Memo1);
// TEdit:
Edit2.BorderStyle := bsNone;
MakeRounded(Edit2);
// TPanel:
MakeRounded(Panel1);
// TStaticText:
MakeRounded(StaticText1);
// TForm
Form1.BorderStyle := bsNone;
MakeRounded(Form1);
end;
Vcl.ExtCtrls.TShape corner size of RoundRect
FMX.StdCtrls.TCornerButton
https://stackoverflow.com/questions/11675374/how-to-make-tframe-with-rounded-corners
TCustomRoundShape = class(TGraphicControl)
procedure TForm1.FormPaint(Sender: TObject);
const
n = 50;
var
Rgn: HRGN;
x1,y1,x2,y2: Integer;
begin
x1 := n;
y1 := n div 2;
x2 := ClientWidth - n;
y2 := ClientHeight - n;
Rgn := CreateRoundRectRgn(x1, y1, x2, y2, n, n);
Canvas.Brush.Color := clSilver;
Canvas.Brush.Style := bsCross;
FillRgn(Canvas.Handle, Rgn, Canvas.Brush.Handle);
Canvas.Brush.Color := clRed;
Canvas.Brush.Style := bsSolid;
FrameRgn(Canvas.Handle, Rgn, Canvas.Brush.Handle, 2, 2);
DeleteObject(Rgn);
end;
https://stackoverflow.com/questions/11675374/how-to-make-tframe-with-rounded-corners
https://stackoverflow.com/questions/5755719/rounded-and-titled-tpanel-in-delphi-7
https://stackoverflow.com/questions/32987649/how-to-create-a-user-control-with-rounded-corners
...create a form with rounded corners?
Autor: Horst Kniebusch
Homepage: http://members.tripod.de/Kniebusch
[ Print tip ]
Tip Rating (38):
{
Die CreateRoundRectRgn lässt eine Form mit abgerundeten Ecken erscheinen.
The CreateRoundRectRgn function creates a rectangular
region with rounded corners
}
procedure TForm1.FormCreate(Sender: TObject);
var
rgn: HRGN;
begin
Form1.Borderstyle := bsNone;
rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
0, // y-coordinate of the region's upper-left corner
ClientWidth, // x-coordinate of the region's lower-right corner
ClientHeight, // y-coordinate of the region's lower-right corner
40, // height of ellipse for rounded corners
40); // width of ellipse for rounded corners
SetWindowRgn(Handle, rgn, True);
end
{ The CreatePolygonRgn function creates a polygonal region. }
procedure TForm1.FormCreate(Sender: TObject);
const
C = 20;
var
Points: array [0..7] of TPoint;
h, w: Integer;
begin
h := Form1.Height;
w := Form1.Width;
Points[0].X := C; Points[0].Y := 0;
Points[1].X := 0; Points[1].Y := C;
Points[2].X := 0; Points[2].Y := h - c;
Points[3].X := C; Points[3].Y := h;
Points[4].X := w - c; Points[4].Y := h;
Points[5].X := w; Points[5].Y := h - c;
Points[6].X := w; Points[6].Y := C;
Points[7].X := w - C; Points[7].Y := 0;
SetWindowRgn(Form1.Handle, CreatePolygonRgn(Points, 8, WINDING), True);
end;
沒有留言:
張貼留言