Button with colored background and wordwrap lazarus / 31-LCL ---------------------------------------------------------------------- Roosters · 2012-01-01 09:02 This is for Windows. I've searched, modified delphi code, used other controls, but try as I might I'm unable to find a button that has a working color property AND wordwrap. I modified the standard TButton and gave it a wordwrap feature, this works great. I understand that if I wish to use TButton as a starting point I have to use a customdraw routine, I have no idea how to implement this. Can anyone point me in the right direction, better still some working code ? ---------------------------------------------------------------------- digeo · 2012-01-01 10:31 Have you taken a look at the BGRA Graphics and Controls Library. They have pretty cool button with gradient or just plain colour. I created an editor that you can download from my site to check possibilities. Because its lazarus, it should also run on al OS's. Check following threads: http://forum.lazarus.freepascal.org/index.php?topic=12411.0 http://forum.lazarus.freepascal.org/index.php?topic=15634.0 ---------------------------------------------------------------------- felipemdc · 2012-01-01 10:37 Quote from: Roosters on January 01, 2012, 10:02:33 amI understand that if I wish to use TButton as a starting point I have to use a customdraw routine, I have no idea how to implement this. Can anyone point me in the right direction, better still some working code ? Try TCDButton from the Lazarus Custom Drawn Controls, which is a part of Lazarus: http://wiki.lazarus.freepascal.org/Lazarus_Custom_Drawn_Controls It has the color property and it works in all platforms. Patches are welcome for adding wordwrap. ---------------------------------------------------------------------- Roosters · 2012-01-01 11:32 Thanks for the replies :-  digeo :- I tried BGRA but it didn't have wordwrap property, I couldn't  get wordwrap to work with this. felipemdc :- I also tried adding a wordwrap property to TCDButton, again it didn't work (like it does in TButton) . I even inherited a new button from TCDButton, added wordwrap and that crashed lazarus. Would you like to see the code I used to add wordwrap to TButton ? ---------------------------------------------------------------------- felipemdc · 2012-01-01 12:04 Quote from: Roosters on January 01, 2012, 12:32:02 pmfelipemdc :- I also tried adding a wordwrap property to TCDButton, again it didn't work (like it does in TButton) . I even inherited a new button from TCDButton, added wordwrap and that crashed lazarus. Would you like to see the code I used to add wordwrap to TButton ? Yes, please send a patch. And I will already tell you the correct way to do this: 1> Add a WordWrap property in TCDButton 2> Add a WordWrap field in TCDButtonStateEx 3> Add synchronizing both values in TCDButton.PrepareStateEx 4> Handle this value in customdrawn_common.pas in DrawButton, check where it draws the text with ExtTextOut and use LCLIntf.DrawText instead (only when WordWrap=True) with correct values. You also need to change the button AutoSize calculation in GetPreferredSize in the same file ---------------------------------------------------------------------- SONFEDAI · 2012-01-01 19:14 Where is the download package? I Can't find ---------------------------------------------------------------------- SONFEDAI · 2012-01-01 19:29 Sorry  I'm found now ---------------------------------------------------------------------- Roosters · 2012-01-05 08:02 Hi, sorry for the late reply, I was called away unexpectedly. In the private section of Tbutton.pas i place the following  FWordWrap : Boolean;  procedure SetWordWrap(AValue: Boolean);  In "published" I place this property WordWrap: Boolean read fWordWrap write SetWordWrap default FALSE; And finally after implementation I place the following procedure procedure TButton1.SetWordWrap(AValue: Boolean); begin    if fWordWrap <> AValue then   begin     fWordWrap := AValue;     recreateWnd(Self);   end; end;  This works great for the standard Tbutton. Thanks and once again apologies for not replying sooner after you were so helpfu