陈
陈晨
Unregistered / Unconfirmed
GUEST, unregistred user!
type
TSetLayeredWindowAttributes = function (Hwnd: THandle; crKey: COLORREF; bAlpha: Byte; dwFlags: DWORD): Boolean; stdcall;
;
;
procedure TCustomForm.SetLayeredAttribs;
const
cUseAlpha: array [Boolean] of Integer = (0, LWA_ALPHA);
cUseColorKey: array [Boolean] of Integer = (0, LWA_COLORKEY);
var
AStyle: Integer;
begin
if not (csDesigning in ComponentState) and
(Assigned(SetLayeredWindowAttributes)) and HandleAllocated then
begin
AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if FAlphaBlend or FTransparentColor then
begin
if (AStyle and WS_EX_LAYERED) = 0 then
SetWindowLong(Handle, GWL_EXSTYLE, AStyle or WS_EX_LAYERED);
SetLayeredWindowAttributes(Handle, FTransparentColorValue, FAlphaBlendValue,
cUseAlpha[FAlphaBlend] or cUseColorKey[FTransparentColor]);
end
else
begin
SetWindowLong(Handle, GWL_EXSTYLE, AStyle and not WS_EX_LAYERED);
RedrawWindow(Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ALLCHILDREN);
end;
end;
end;
TSetLayeredWindowAttributes = function (Hwnd: THandle; crKey: COLORREF; bAlpha: Byte; dwFlags: DWORD): Boolean; stdcall;
;
;
procedure TCustomForm.SetLayeredAttribs;
const
cUseAlpha: array [Boolean] of Integer = (0, LWA_ALPHA);
cUseColorKey: array [Boolean] of Integer = (0, LWA_COLORKEY);
var
AStyle: Integer;
begin
if not (csDesigning in ComponentState) and
(Assigned(SetLayeredWindowAttributes)) and HandleAllocated then
begin
AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if FAlphaBlend or FTransparentColor then
begin
if (AStyle and WS_EX_LAYERED) = 0 then
SetWindowLong(Handle, GWL_EXSTYLE, AStyle or WS_EX_LAYERED);
SetLayeredWindowAttributes(Handle, FTransparentColorValue, FAlphaBlendValue,
cUseAlpha[FAlphaBlend] or cUseColorKey[FTransparentColor]);
end
else
begin
SetWindowLong(Handle, GWL_EXSTYLE, AStyle and not WS_EX_LAYERED);
RedrawWindow(Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ALLCHILDREN);
end;
end;
end;