TMemo
虽然可以显示文本,倒入文本
但如何让他背景透明呀?
虽然可以显示文本,倒入文本
但如何让他背景透明呀?
解决方案 »
- 关于嵌套线程内存管理问题
- 为什么要关闭两次才能将数据库里的数据删除?
- MIDAS在客户端执行SQL的问题!!急....
- 网络图获取程序
- 再问ADO为何如此之慢?
- 在使用adoquery控件时,总提示出错???
- 谁能告诉我完整的正式版本Dream_controls_collection for D6的下载地址呢?
- 怎么我的电脑中的输入法有些不能用??
- Wh7577,强子送分给你!
- 什么情况下用指针p^?????
- sql server 7.0 和sql server 2000 能否共存与一台机器上
- 菜鸟求救:我在一个unit中定义了一个procedure ,怎样在别的unit中也能使用它。赠分100
并给出具体点的代码嘛?
拜托了!
(就是那些没有handle属性, 不能有focus的控件, 如image)
都有Transparent属性. 对TWinControl类的控件, 要实现透明只要完成以下
四步基本上就成了.
1.在Create中设定ControlStyle :=
ControlStyle - [csOpaque];)
2. override 它的CreateParams方法, exstyle 里加上WS_EX_TRANSPARENT.
3. 修改它的parent的window style, 去掉WS_CLIPCHILDREN. inherited CreateParams(Params);
with Params do
begin
{ 完全重画 }
Style := Style and not WS_CLIPCHILDREN;
Style := Style and not WS_CLIPSIBLINGS;
{ 增加透明 }
ExStyle := ExStyle or WS_EX_TRANSPARENT;
end;
4. 截获WM_ERASEBKGND, 什么都不做直接返回1.(不搽除背景)
一般有上面3步能成. 有些控件比如TPanel, 在它的paint中用了fillrect, 所以要实现透明的话还要override 它的paint方法, 自己画.
按钮透明需要进一步处理.
createparams里加上style := style or BS_OWNERDRAW;
然后在WM_DRAWITEM中自己画吧
unit MySpeedButton;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, Buttons;type
TMySpeedButton = class(TspeedButton)
protected
procedure CMMouseLeave(var Message: TMessage);message CM_MOUSELEAVE;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('ActiveX', [TMySpeedButton]);
end;{ TMySpeedButton }
procedure TMySpeedButton.CMMouseLeave(var Message: TMessage);
var
Rect:TRect;
begin
if (Visible) and (Parent <> nil) and Parent.HandleAllocated then
begin
Rect := BoundsRect;
InvalidateRect(Parent.Handle, @Rect,True);
end;
end;end.