I've attached a cropped screen grab to show what I've achieved.
I'm just curious: It looks like an antialiased border, so what API did you use ?
UpdateLayeredWindow or SetWindowRGN ?
Is that only one window ?
For the transparency coding I was directed by RVK and Fungus to use this :
(I've left in all the comments to explain far better than I can what is happening)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';
[...]
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 TInvClock.FormCreate(Sender: TObject);
var
transparency:longint;
begin
{the color were going to make transparent the White that the form background is set to}
transparency:= clWhite;
{call the function to do it}
SetTranslucent (InvClock.Handle, transparency, 0);
Read_Date;
end;
The final 'Read_Date' is a separate procedure to initialize the Date and Time at program start-up.
The background image is a .PNG file with a white background and the hands are transparent .PNG Images - I haven't yet coded the analogue hand movement, for that I'm investigating the BGRABitmap routines created by lainz (that's my job for today!).
I coded the digital Time and Date display yesterday so a new image is attached to better show that it can be dragged and the background is transparent.