Apr
29
Полупрозрачный MessageBox
11:50unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
WM_MSGBOX = WM_USER + 1;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure msgBoxShow(var msg: TMessage); message WM_MSGBOX;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure make50transp(winHWND: HWND);
var
exStyle: Longint;
begin
exStyle := GetWindowLong(winHWND, GWL_EXSTYLE);
if (exStyle and WS_EX_LAYERED = 0) then begin
exStyle := exStyle or WS_EX_LAYERED;
SetwindowLong(winHWND, GWL_EXSTYLE, exStyle);
end;
SetLayeredWindowAttributes(winHWND, 0, 128, LWA_ALPHA);
end;
procedure TForm1.msgBoxShow(var msg: TMessage);
var
msgbHandle: HWND;
begin
msgbHandle := GetActiveWindow;
if msgbHandle <> 0 then
make50transp(msgbHandle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(handle, WM_USER + 1, 0, 0);
MessageBox(handle, 'This Is A Transparent Message Box', '50% MessageBox.', MB_OK or MB_ICONWARNING);
end;
end.
http://www.delphimaster.ru/cgi-bin/forum.pl?id=1143463865&n=5