Form SetShape(Bitmap) doesn't work on GTK2/Carbon
Original Reporter info from Mantis: SpongeBob
-
Reporter name: SpongeBob
Original Reporter info from Mantis: SpongeBob
- Reporter name: SpongeBob
Description:
I've tried to make a rounded form using form.SetShape(bitmap). It works fine on Windows only. It does nothing on GTK2 and Carbon. The form was set to be borderless, however it makes no difference if it has a border.
Additional information:
This code works OK on Windows only:
procedure CreateRoundedShape(AWid,AHei:integer; AControl:TWinControl);
const R = 9;
var bmp:TBitmap;
begin
bmp:=TBitmap.Create;
try
bmp.PixelFormat:=pf1bit;
bmp.SetSize(AControl.Width, AControl.Height);
bmp.Canvas.Pen.Style:=psSolid;
bmp.Canvas.Brush.Style:=bsSolid;
bmp.Canvas.Brush.Color:=clBlack;
bmp.Canvas.FillRect(0,0,bmp.Width,bmp.Height);
bmp.Canvas.Brush.Color:=clWhite;
bmp.Canvas.Pen.Color:=clWhite;
bmp.Canvas.RoundRect(0,0,bmp.Width,bmp.Height,R,R);
AControl.SetShape(bmp);
finally
bmp.Free;
end;
end;
Use as:
CreateRoundedShape(Width, Height, self);
from Form OnCreate.
I haven't tested if this works with TPanel or anything else, but with TForm it doesn't.
It would be cool if we can create rounded forms on all platforms. On Windows I used regions and on Mac I used some custom form drawing with alpha-transparency. But to make it crossplatform it would be nice if SetShape() works correctly.
Mantis conversion info:
- Mantis ID: 16517
- Version: 0.9.29 (SVN)
- Monitored by: » @zeljan1 (Zeljan Rikalo)