哪里有透明的ScrollBox? 我动态生成了一些对象放在一个容器里面,由于比较多,所以需要滚动条,就选择了ScrollBox,但是这个东东不透明,现在需要让它透明因为要露出ScrollBox下面Form上的一些图片。应该怎么处理?哪里有透明的ScrollBox?或者可以用其它的什么方法来达到这个效果?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以使用scrollbar控件和panel控件配合 修改一下Delphi VCL的源代码就行了。,建立一个 ScrollBox1: TScrollBox; 按下Ctrl 单击TScrollBox 定位到以下单元的你在 Froms单元 中找一下{ TScrollBox = class(TScrollingWinControl) private FBorderStyle: TBorderStyle; procedure SetBorderStyle(Value: TBorderStyle); procedure WMNCHitTest(var Message: TMessage); message WM_NCHITTEST; procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED; protected procedure CreateParams(var Params: TCreateParams); override;//找到这里}//在这里添加 找到这里procedure TScrollBox.CreateParams(var Params: TCreateParams);const BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);begin inherited CreateParams(Params); with Params do begin Style := Style or BorderStyles[FBorderStyle]; if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then begin Style := Style and not WS_BORDER; ExStyle := ExStyle or WS_EX_CLIENTEDGE;// { 增加透明 }//加上这句 就行了 ////////!!!!!!!! ExStyle := ExStyle or WS_EX_TRANSPARENT; end; end;end; 樓上你的代碼測試通過了嘛?我這裡沒效果.自己寫個組件:unit TranScrollBox;interfaceuses SysUtils, Classes, Controls, Forms, Messages, Windows;type TTranScrollBox = class(TScrollBox) private { Private declarations } FTransparent: Boolean; procedure SetTransparent(value: Boolean); procedure WMEraseBkgnd(var Msg: TMessage); message WM_ERASEBKGND; protected procedure CreateParams(var Params: TCreateParams); override; procedure SetParent(AParent: TWinControl); override; public procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; published property Transparent: Boolean read FTransparent write SetTransparent; end;procedure Register;implementationprocedure Register;begin RegisterComponents('Samples', [TTranScrollBox]);end;{ TTranScrollBox }procedure TTranScrollBox.CreateParams(var Params: TCreateParams);begin inherited CreateParams(Params); params.exstyle := params.exstyle or WS_EX_TRANSPARENT;end;procedure TTranScrollBox.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);begin invalidate; inherited setbounds(aleft, atop, awidth, aheight);end;procedure TTranScrollBox.SetParent(AParent: TWinControl);begin inherited setparent(aparent); if (aparent <> nil) and aparent.HandleAllocated and (GetWindowLong(aparent.handle, GWL_STYLE) and WS_CLIPCHILDREN <> 0) then setwindowlong(aparent.handle, GWL_STYLE, GetWindowLong(aparent.handle, GWL_STYLE) and not WS_CLIPCHILDREN);end;procedure TTranScrollBox.SetTransparent(value: Boolean);begin if ftransparent <> value then begin ftransparent := value; invalidate; end;end;procedure TTranScrollBox.WMEraseBkgnd(var Msg: TMessage);begin if ftransparent then msg.result := 1 else inherited;end;end. 我测试了通过了,XP + Delphi7在源代码中添加这一句就行了。 ExStyle := ExStyle or WS_EX_TRANSPARENT;你是在VCL 的源代码中添加的吗? delphi的system error code 203 三层结构主从表子表主表查询问题 更改exe图标 一个较完整的画图软件 发送邮件553的问题! 谁有DBGridEh控件(及EhLib控件包),能安装在D6上,并能脱离D6运行的。我可以用人民币购买,成交地广州。 WINDOWS98速度安全漏洞?高手指教!!! 我想在某一个dbgrid里实现一个combobox以限制用户的输入,怎么实现呢? 谁要——网址编辑器 如何控制窗口的最小化? COM组件中使用线程的问题? 请教如何控制某一线程以一个固定周期执行
按下Ctrl 单击TScrollBox 定位到以下单元的
你在 Froms单元 中找一下
{
TScrollBox = class(TScrollingWinControl)
private
FBorderStyle: TBorderStyle;
procedure SetBorderStyle(Value: TBorderStyle);
procedure WMNCHitTest(var Message: TMessage); message WM_NCHITTEST;
procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
protected
procedure CreateParams(var Params: TCreateParams); override;//找到这里
}
//在这里添加 找到这里
procedure TScrollBox.CreateParams(var Params: TCreateParams);
const
BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style or BorderStyles[FBorderStyle];
if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then
begin
Style := Style and not WS_BORDER;
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
// { 增加透明 }//加上这句 就行了 ////////!!!!!!!!
ExStyle := ExStyle or WS_EX_TRANSPARENT;
end; end;
end;
自己寫個組件:unit TranScrollBox;interfaceuses
SysUtils, Classes, Controls, Forms, Messages, Windows;type
TTranScrollBox = class(TScrollBox)
private
{ Private declarations }
FTransparent: Boolean;
procedure SetTransparent(value: Boolean);
procedure WMEraseBkgnd(var Msg: TMessage); message WM_ERASEBKGND;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure SetParent(AParent: TWinControl); override;
public
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
published
property Transparent: Boolean read FTransparent write SetTransparent;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Samples', [TTranScrollBox]);
end;{ TTranScrollBox }procedure TTranScrollBox.CreateParams(var Params: TCreateParams);
begin inherited CreateParams(Params);
params.exstyle := params.exstyle or WS_EX_TRANSPARENT;
end;procedure TTranScrollBox.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
invalidate;
inherited setbounds(aleft, atop, awidth, aheight);
end;procedure TTranScrollBox.SetParent(AParent: TWinControl);
begin
inherited setparent(aparent);
if (aparent <> nil) and aparent.HandleAllocated
and (GetWindowLong(aparent.handle, GWL_STYLE) and WS_CLIPCHILDREN <> 0) then
setwindowlong(aparent.handle, GWL_STYLE,
GetWindowLong(aparent.handle, GWL_STYLE)
and not WS_CLIPCHILDREN);
end;procedure TTranScrollBox.SetTransparent(value: Boolean);
begin
if ftransparent <> value then
begin
ftransparent := value;
invalidate;
end;
end;procedure TTranScrollBox.WMEraseBkgnd(var Msg: TMessage);
begin
if ftransparent then msg.result := 1
else inherited;
end;end.
ExStyle := ExStyle or WS_EX_TRANSPARENT;
你是在VCL 的源代码中添加的吗?