Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Redondear esquinas de cualquier control (https://www.clubdelphi.com/foros/showthread.php?t=80778)

AzidRain 08-12-2006 03:39:09

Redondear esquinas de cualquier control
 
Código Delphi [-]

procedure DrawRounded(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, - 4, - 4) ;
     Perform(EM_SETRECTNP, 0, lParam(@r)) ;
     SetWindowRgn(Handle, rgn, True) ;
     Invalidate;
   end;
end;

{Ejemplo de uso}
procedure TForm1.FormCreate(Sender: TObject) ;
begin
   // rounding Panel1
   DrawRounded(Panel1) ;

   // rounding Memo1
   Memo1.BorderStyle := bsNone;
   DrawRounded(Memo1) ;

   // rounding Edit1
   Edit1.BorderStyle := bsNone;
   DrawRounded(Edit1) ;

end;

Neomanar 30-03-2007 18:47:37

Me tira los siguientes errores:
[Pascal Error] E2003 Undeclared identifier: 'EM_GETRECT'
[Pascal Error] E2003 Undeclared identifier: 'EM_SETRECTNP'
Qué me está faltando?

Neomanar 30-03-2007 18:54:03

Me tira los siguientes errores:
[Pascal Error] E2003 Undeclared identifier: 'EM_GETRECT'
[Pascal Error] E2003 Undeclared identifier: 'EM_SETRECTNP'
Qué me está faltando?

Black_Ocean 01-05-2007 01:54:08

Para Neomanar

Fácil, te está faltando declarar en tu USES la librería Messages

Cordiales saludos.

Lisandro 06-09-2007 13:55:19

Muy bueno, me anda con BDS 2006. Gracias

mario2000 15-03-2008 19:07:04

Hola lo hise con un boton y en verdad que es horrendo, el boton se ve peor de lo normal, quisiera saber si se puede hacer que los botones tengan esquinas suaves y redondas ademas que tengan un efecto gradiente gracias.


La franja horaria es GMT +2. Ahora son las 20:32:08.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi