必须是在Windows2000以下的系统才支持SetLayeredWindowAttributes这个API,原理就是先找到窗口句柄,然后设置窗口属性
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)program opacity;
{$APPTYPE CONSOLE}
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/) uses
SysUtils,
Windows;
var
handle,AStyle:integer;
begin
try
if ParamCount2 then
begin
Writeln('parameter must');
exit;
end;
handle:=findwindow(nil,pchar(ParamStr(1)));//目前是找窗口的Text,也可以是找ClassName
AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
SetWindowLong(Handle, GWL_EXSTYLE, AStyle or WS_EX_LAYERED);
if SetLayeredWindowAttributes(Handle, 0, strtoint(ParamStr(2)),LWA_ALPHA) then
Writeln(ParamStr(1)+' update successed to '+ParamStr(2))
else
Writeln('Opacity update failed');
except
Writeln('parameter error');
end;
end.
http://blog.csdn.net/redbirdli/archive/2007/02/15/1510602.aspx