I have inherited from TGroupBox of the Delphi native control and overriden its Paint method to draw rounded rectangle.
procedure TclTransparentGroupBox.CreateParams(var params : TCreateParams);
begin
inherited;
Params.ExStyle := params.ExStyle or WS_EX_TRANSPARENT;
end;
After overriding the Create params, the Paint method is as below.
procedure TclTransparentGroupBox.Paint;
begin
// Draw the rounded rect to show the group box bounds
Canvas.Pen.Color := clWindowFrame;
Canvas.RoundRect(5, 15, ClientRect.Right - 5, ClientRect.Bottom - 5, 10, 10);
if Caption <> EmptyStr then
begin
Canvas.Brush.Style := bsClear;
Canvas.TextOut(10, 0, Caption);
end;
end;
The major problem i m facing is that, i have few labels on top of the transparent group box. When i open the form the labels look fine, but when the text changes, some bounding rectangles of the labels will be visible. This is looking weird on top of transparent box.
Even when i resize the form, the group box itself disappears, when i change the focus to another application and bring back my application, the group box draws itself.
Am i missing anything with respect to drawing? Any windows messages that i need to take care of???
Thanks in advance Rahul