how do I make the form transparent lazarus / 31-LCL ---------------------------------------------------------------------- jw · 2010-01-26 22:53 how do I make the form transparent? I've got experience with vb6/vb.net and programmed in turbo pascal 7 a long time ago. To get a transparent form in vb6 I had to make an api call vb.net was even easier.  But free pascal which is not supposed to be platfom specific wouldn't want me to use a windows specific api call besides I don't know how to setup an API call in free pascal yet anyway.  So how do I make the form transparent? ---------------------------------------------------------------------- Marc · 2010-01-26 23:25 This is not (yet) cross platform supported. On windows you can make the same api call as you did in vb6. Add uses windows to your  uses clause ---------------------------------------------------------------------- skalogryz · 2010-01-27 08:24 Quote from: jw on January 26, 2010, 11:53:01 pmSo how do I make the form transparent? if you use svn version of Lazarus or tomorrows daily snapshot (after 27-jan-2001). You can adjust form's transparency by changing AlphaBlendValue property. ---------------------------------------------------------------------- LazaruX · 2010-01-27 11:00 Regarding the windows way, search in the forum there are already example on how to do that on windows. ---------------------------------------------------------------------- jw · 2010-01-27 18:22 here's workining code for setting the forms background transparent in windows thank to all for the help unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls, windows;   const   LWA_COLORKEY = 1;   LWA_ALPHA = 2;   LWA_BOTH = 3;   WS_EX_LAYERED = $80000;   GWL_EXSTYLE = -20;  {Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal Color As Long, ByVal X As Byte, ByVal alpha As Long) As Boolean }  function SetLayeredWindowAttributes (hWnd:Longint; Color:Longint; X:Byte; alpha:Longint):bool stdcall; external 'USER32';  {not sure how to alias these functions here ????   alias setwindowlonga!!}  {Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long }  Function SetWindowLongA (hWnd:Longint; nIndex:longint; dwNewLong:longint):longint stdcall; external 'USER32';  {Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long }  Function GetWindowLongA ( hWnd:Longint; nIndex:longint):longint stdcall; external 'user32'; type   { TForm1 }   TForm1 = class(TForm)     procedure FormCreate(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation { TForm1 } procedure SetTranslucent(ThehWnd: Longint; Color: Longint; nTrans: Integer); var attrib:longint;  begin     {SetWindowLong and SetLayeredWindowAttributes are API functions, see MSDN for details }     attrib := GetWindowLongA(ThehWnd, GWL_EXSTYLE);     SetWindowLongA (ThehWnd, GWL_EXSTYLE, attrib Or WS_EX_LAYERED);     {anything with color value color will completely disappear if flag = 1 or flag = 3  }     SetLayeredWindowAttributes (ThehWnd, Color, nTrans,1); end; procedure TForm1.FormCreate(Sender: TObject); var    transparency:longint; begin      {the color were going to make transparent the red that the form backgroud is set to}      transparency:=  $000002EE;      {call the function to do it}      SetTranslucent (form1.Handle, transparency, 0); end; initialization   {$I unit1.lrs} end. all newbs this hung me up be sure and goto the form events tab oncreate click it and make the drop down menu say formcreate.  Also set the form color to $000002EE that's the only color the form will go transparent to unless you change the transparency = bpsoftware I did find your webpage in the forums thank you however setting windows regions and blending the colors to create transparency is very different. I admire your work to create a transparent bunny etc by scanning for and makeing the region for controls however I didn't think that would be easy or work for me as I want the control to animate.  this is the starting point for me to animate pictures across my desktop.  Like makeing an active desktop. all the rest of you guys I'll be sure and look at the new svn version however I think it's going to make the form fade in and out and the controls along with it and there was already code to do that in the forums however please correct me if I'm wrong.  I guess I poorly worded my original question,  It should have been how do I set the tforms backgroud color to transparent? ---------------------------------------------------------------------- cdbc · 2010-01-28 01:25 Hi Jw Code: [Select]SetTranslucent (form1.hWnd, transparency, g_nTransparency, flag); SetTranslucent (form1.Handle transparency, g_nTransparency, flag); HTH Regards Benny ---------------------------------------------------------------------- Paul Ishenin · 2010-01-28 01:31 Since yesterday you can use Form1.AlphaBlendValue := 100; // 0..255 Form1.AlphaBlend := True; ---------------------------------------------------------------------- jw · 2010-03-19 15:54 here's the easiest way to set the a color on the form transperent much easier then my code above credit to xpete http://bugs.freepascal.org/view.php?id=1804 just include windows in uses and these 2 commands SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED); SetLayeredWindowAttributes(Handle,clWhite,255,LWA_COLORKEY); ---------------------------------------------------------------------- Leledumbo · 2010-03-25 12:03 Quotehere's the easiest way to set the a color on the form transperent much easier then my code aboveWindows only code. Paul's solution is cross platform and even MUCH easier. ---------------------------------------------------------------------- jw · 2010-04-13 22:19 leledumbo Pauls code fades the form in and out, controls and all. Yes my code is windows only. Don't confuse form transparency with setting a single color on the form as a transparent color which is what my code does.  This api call will also do what Pauls code does with the right parameters passed to it. My api call is setting form regions according to a particular color clwhite! I've exparmented with setting form regions useing only the LCL from code in the lazarus examples directory shapedcontrols. unfortunatly it requires a tbitmap and will not use a tcustiombitmap which means you cant easily draw complex regions useing the color that just happens to be clwhite, our mask color. The idea was to draw all the sprites to the form.canvas and then draw the masked regions on my mask.canvas and have what I needed but as I said it no worky it was slower then useing the API call and unable to use tcustombitmaps. ---------------------------------------------------------------------- krzynio · 2014-02-27 20:47 Quote from: Paul Ishenin on January 28, 2010, 02:31:48 amSince yesterday you can use Form1.AlphaBlendValue := 100; // 0..255 Form1.AlphaBlend := True; It is nice option but it doesn't work as expected. Childs of the form ale also blended i.e. images. I am looking for solution on Linux. Regards, Krzysztof ---------------------------------------------------------------------- Conn · 2015-09-13 17:02 Krzysztof, Did you find a solution to this?.. Cheers, Conn ---------------------------------------------------------------------- taazz · 2015-09-13 17:59 for windows there is the alpha blended technique that can be used for a per pixel transparency on other systems I guess there is something similar but I have no  experince outside windows.