Recent

Author Topic: TGraphicControl and child controls  (Read 13127 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
TGraphicControl and child controls
« on: April 24, 2011, 01:12:33 pm »
Hi,

I', writting component which using BGRABitmap for drawing theme. I inherit from TGraphicControl. Drawing works fine but I can't drop child controls (like TPanel do). So I switch parent class from TGraphicControl to TCustomControl with ControlStyle := ControlStyle + [csAcceptsControls, csOpaque]. Now I can drop childs but transparency has stopped working. It seems that TCustomControl draw first some standard background with parent color. I am lock now.

Regards

lainz

  • Guest
Re: TGraphicControl and child controls
« Reply #1 on: April 24, 2011, 05:03:35 pm »
Hi,

I', writting component which using BGRABitmap for drawing theme. I inherit from TGraphicControl. Drawing works fine but I can't drop child controls (like TPanel do). So I switch parent class from TGraphicControl to TCustomControl with ControlStyle := ControlStyle + [csAcceptsControls, csOpaque]. Now I can drop childs but transparency has stopped working. It seems that TCustomControl draw first some standard background with parent color. I am lock now.

Regards

Go to the bugtracker.

See this, they fixed my report: added transparency in controls with controls inside:
http://bugs.freepascal.org/view.php?id=18172

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: TGraphicControl and child controls
« Reply #2 on: April 25, 2011, 12:11:14 pm »
I updated lazarus svn version but still this same problem. TToolbar have no transparency too. I have linux GTK2

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TGraphicControl and child controls
« Reply #3 on: May 04, 2011, 12:23:53 pm »
I updated lazarus svn version but still this same problem. TToolbar have no transparency too. I have linux GTK2

The solved bug that lainz points to is for win widgetset only.

For Gtk2, there is separate entry in bugtracker: http://bugs.freepascal.org/view.php?id=18168
This one is not solved yet. :(

camauri

  • Newbie
  • Posts: 2
Re: TGraphicControl and child controls
« Reply #4 on: May 13, 2011, 12:22:52 am »
Now I can drop childs but transparency has stopped working. It seems that TCustomControl draw first some standard background with parent color. I am lock now.

Hi Dibo,
on Windows systems TCustomControl descendant aren't transparent by default.
This is a correct behaviour in the LCL as in the VCL.
In Mac OS X controls are native fully transparent (tested on my Mac with Lazarus ver. 0.9.28). See also here http://www.lazarus.freepascal.org/index.php?topic=9963.0.
Same for GTK and QT.

For transparent controls on Windows can be used the old Delphi trick.

  • Declare TBGRAButton = class(TCustomControl)
  • Add Messages unit
  • Add the following protected declarations:

Code: [Select]
{$IFDEF LCLwin32}
procedure CreateParams(var params: TCreateParams); override;
procedure WMEraseBkGnd(var msg: TWMEraseBkGnd); message WM_ERASEBKGND;
{$ENDIF}

Code: [Select]
{$IFDEF LCLwin32}
procedure TBGRAButton.CreateParams(var params: TCreateParams);
begin
  inherited CreateParams(params);
  params.ExStyle := params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TBGRAButton.WMEraseBkGnd(var msg: TWMEraseBkGnd);
begin
  SetBkMode (msg.DC, TRANSPARENT);
  msg.result := 1;
end;
{$ENDIF}


That's all, the component is now working on Windows as transparent TCustomControl descendant.
For the other platform I will try asap.

Bye.
Camauri

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: TGraphicControl and child controls
« Reply #5 on: May 14, 2011, 12:37:28 pm »
Hm, this trick doesn't work on GTK :/

camauri

  • Newbie
  • Posts: 2
Re: TGraphicControl and child controls
« Reply #6 on: May 14, 2011, 06:38:32 pm »
Hm, this trick doesn't work on GTK :/

I know, this trick is for Windows only.
But now BRGAControls on Windows can have the same behavior as in GTK, QT and Carbon/Cocoa.
Now I'm installing Lazarus on latest Ubuntu distro to try some solutions for GTK.
Next I will try on Snow Leopard.
Bye.
Camauri

 

TinyPortal © 2005-2018