http://bugs.winehq.org/show_bug.cgi?id=24756
Summary: Form do not have transparent region - SetLayeredWindowAttributes do not work Product: Wine Version: 1.3.2 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: shell32 AssignedTo: wine-bugs@winehq.org ReportedBy: alejandro.lavarello@gmail.com
Forms with transparent regions works OK in Windows XP but the transparency not work in Wine 1.3.2.
Transparency is obtained using the Windows API call to SetLayeredWindowAttributes. In more detail, this is the Lazarus code:
------begin of code ------------------------------------------------- unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms,
Controls, StdCtrls, Graphics, Dialogs, ExtCtrls, 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)
Button1: TButton;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ 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,LWA_COLORKEY);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
transparency:longint;
begin
{the color were going to make transparent the red that the form background is set to}
transparency:= clLime;
{call the function to do it}
SetTranslucent (form1.Handle, transparency, 0);
end;
------end of code -------------------------------------------------
Tested in Wine 1.3.2 under Puppy Linux 4.3.1 and in WineXO under Fedora Remix + Sugar in a XO-1.