<Form Special Effects> Translucent Forms like Foxmail3.1Beta

zhaozj2021-02-08  203

Add some APIs under Windows 2000, you can easily implement translucent forms, the source program is as follows, and if necessary, I added a comment.

Unit unit1;

Interface

Uses

Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs

Const

WS_EX_LAYERED = $ 80000;

AC_SRC_OVER = $ 0;

AC_SRC_ALPHA = $ 1;

AC_SRC_NO_PREMULT_ALPHA = $ 1;

AC_SRC_NO_ALPHA = $ 2;

AC_DST_NO_PREMULT_ALPHA = $ 10;

AC_DST_NO_ALPHA = $ 20;

LWA_COLORKEY = $ 1;

LWA_ALPHA = $ 2;

ULW_COLORKEY = $ 1

ULW_ALPHA = $ 2

ULW_OPAQUE = $ 4

// Newly added constant definition

Type

TFORM1 = Class (TFORM)

Procedure formcreate (Sender: TOBJECT);

Private

{Private Declarations}

public

{Public declarations}

END;

Function sets (hWnd: hwnd; crkey: longint; balpha: byte; dwflags: longint): longint; stdcall; external user32; // function declaration

VAR

FORM1: TFORM1;

IMPLEMENTATION

{$ R * .dfm}

Procedure TFORM1.FormCreate (Sender: TOBJECT);

Var L: longint;

Begin

L: = getWindowlong (Handle, GWL_EXSTYLE);

l: = L or ws_ex_layred;

Setwindowlong (Handle, GWL_EXSTYLE, L);

SetlayeredWindowAttributes (Handle, 0, 180, LWA_ALPHA);

// Second parameter is specified transparent color

// The second parameter is 0 Use the fourth parameter to set the alpha value, from 0 to 255, other I don't know, because there is no API help

END;

End.

转载请注明原文地址:https://www.9cbs.com/read-2248.html

New Post(0)