有谁知道如何在window2000下创建象flashget那个小盒那样的透明窗口?急用!

kingofwang 2000-12-23 07:31:00
...全文
110 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingofwang 2000-12-23
  • 打赏
  • 举报
回复
谢谢二位了!


我。。。。。。
peacock 2000-12-23
  • 打赏
  • 举报
回复
哇!一模一样!
GoodHope 2000-12-23
  • 打赏
  • 举报
回复
相关函数UpdateLayeredWindow资料,也是抄的:

UpdateLayeredWindow
The UpdateLayeredWindow function updates the position, size, shape, content, and translucency of a layered window.

BOOL UpdateLayeredWindow(
HWND hwnd, // handle to layered window
HDC hdcDst, // handle to screen DC
POINT *pptDst, // new screen position
SIZE *psize, // new size of the layered window
HDC hdcSrc, // handle to surface DC
POINT *pptSrc, // layer position
COLORREF crKey, // color key
BLENDFUNCTION *pblend, // blend function
DWORD dwFlags // options
);
Parameters
hwnd
[in] Handle to a layered window. A layered window is created by specifying WS_EX_LAYERED when creating the window with the CreateWindowEx function.
hdcDst
[in] Handle to a device context (DC) for the screen. This handle is obtained by specifying NULL when calling the GetDC function. It is used for palette color matching when the window contents are updated. If hdcDst is NULL, the default palette will be used.
If hdcSrc is NULL, hdcDst must be NULL.

pptDst
[in] Pointer to a POINT structure that specifies the new screen position of the layered window. If the current position is not changing, pptDst can be NULL.
psize
[in] Pointer to a SIZE structure that specifies the new size of the layered window. If the size of the window is not changing, psize can be NULL.
If hdcSrc is NULL, psize must be NULL.

hdcSrc
[in] Handle to a DC for the surface that defines the layered window. This handle can be obtained by calling the CreateCompatibleDC function or the IDirectDrawSurface7::GetDC method. If the shape and visual context of the window are not changing, hdcSrc can be NULL.
pptSrc
[in] Pointer to a POINT structure that specifies the location of the layer in the device context.
If hdcSrc is NULL, pptSrc should be NULL.

crKey
[in] Pointer to a COLORREF value that specifies the color key to be used when composing the layered window. To generate a COLORREF, use the RGB macro.
pblend
[in] Pointer to a BLENDFUNCTION structure that specifies the transparency value to be used when composing the layered window.
dwFlags
[in] This parameter can be one of the following values. Value Meaning
ULW_ALPHA Use pblend as the blend function. If the display mode is 256 colors or less, the effect of this value is the same as the effect of ULW_OPAQUE.
ULW_COLORKEY Use crKey as the transparency color.
ULW_OPAQUE Draw an opaque layered window.


If hdcSrc is NULL, dwFlags should be zero.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The source DC should contain the surface that defines the visible contents of the layered window. For example, you can select a bitmap into a device context obtained by calling the CreateCompatibleDC function.

The UpdateLayeredWindow function maintains the window's appearance on the screen. The windows underneath a layered window do not need to be repainted when they are uncovered due to a call to UpdateLayeredWindow, because the system will automatically repaint them. This permits seamless animation of the layered window.

UpdateLayeredWindow always updates the entire window. To update part of a window, use the traditional WM_PAINT and set the blend value using SetLayeredWindowAttributes.

For best drawing performance by the layered window and any underlying windows, the layered window should be as small as possible. An application should also process the WM_DISPLAYCHANGE message and recreate its layered windows when the display's color depth changes.

For more information, see Layered Windows.

Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
GoodHope 2000-12-23
  • 打赏
  • 举报
回复
呵呵,天下文章一大抄.
peacock 2000-12-23
  • 打赏
  • 举报
回复
这有帖子。


-------------------------------------------
<窗体特效〉半透明窗体 像Foxmail3.1beta的一样(soj 原作)


出处:

正文:

在windows2000下增加了一些API,可以轻易的实现半透明的窗体,源程序如下,必要的地方我加上了注释
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
//新增加的常量定义
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

function SetLayeredWindowAttributes(hwnd:HWND; crKey:Longint; bAlpha:byte; dwFlags:longint ):longint; stdcall; external user32;//函数声明

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_LAYERED;
SetWindowLong (handle, GWL_EXSTYLE, l);
SetLayeredWindowAttributes (handle, 0, 180, LWA_ALPHA);
//第二个参数是指定透明颜色
//第二个参数为0则使用第四个参数设置alpha值,从0到255,其他的我不太清楚,因为没有api帮助
end;



end.



现得分:36
给贴子评分(最高100分,最低1分): 我要加 分



作者 评论
StarRainBow 不对吧,我曾在95-98平台下见过一个老外的程序,它就支持半透明的窗体。
据我考虑,如果要实现此功能,只需要取得Desktop的画面,经过透明混合后
再回写到Desktop,不就搞定?WaitMe,在下打算做个VCL,如果完成了就会
公开的。
wwwsheng 这确实是Windows2000的新功能。
他需要操作系统的支持,所以在98nt中就不用试了。并且,我认为:98nt中不可能作出这种“动态”的Alpha混合(至少用同样的系统资源下不可能)。
还有,有关Windows2000的新功能的Help在msdn.microsoft.com都有,那些新的常量在BCB50和VC++(ServicePack3)的windows.h中都有声明了。
wwwsheng StartRainBow:

你说的这个算法也就是金山词霸的做法。但你想过没有:如果这时背景是运动的话,它的效果会非常糟糕的。
bitter Delphi5+win98se有控件可实现半透明窗体透明度0-100可调。
要的话emailbitter@990.net
ghj1976 呵呵呵,不错。
tibetty 其实很简单,Windows本身在关机时的半透明效果实际上是让带很多黑点的位图透明叠加在背景位图上实现的,如果有人不知道如何透明叠加,请与我联系:
email:tibetty99@etang.com
pino 在win9x里又该怎样写呢
有没有高手能把这个函数解出来
GoodHope 2000-12-23
  • 打赏
  • 举报
回复
在windows2000下增加了一些API,可以轻易的实现半透明的窗体,源程序如下:
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
//新增加的常量定义
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

function SetLayeredWindowAttributes(hwnd:HWND; crKey:Longint; bAlpha:byte; dwFlags:longint ):longint; stdcall; external user32;//函数声明

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_LAYERED;
SetWindowLong (handle, GWL_EXSTYLE, l);
SetLayeredWindowAttributes (handle, 0, 180, LWA_ALPHA);
// 参数是窗口句柄(必须具有WS_EX_LAYERED风格)
// 参数是指定透明颜色
// 参数为Alpha值
// 第四个参数为透明方式:LWA_COLORKEY使用crKey作为透明色;LWA_ALPHA使用Alpha作为混合比例。
end;



end.

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧