乙個使TEdit透明的例子

2021-04-02 07:52:24 字數 3687 閱讀 8524

unit bktransparentedit;

inte***ce

uses

windows, messages, sysutils, classes, graphics, controls, forms, dialogs,

stdctrls;

const

twm_bkinvalidate=wm_user+1;

type

tbktransparentedit = class(tedit)

private

procedure bkinvalidate(var message:tmessage); message

twm_bkinvalidate;

procedure cnctlcoloredit(var message:twmctlcoloredit); message

cn_ctlcoloredit;

procedure wmerasebkgnd(var message: twmerasebkgnd); message wm_erasebkgnd;

procedure wmmove(var message: tmessage); message wm_move;

protected

ftransparent: boolean;

procedure createwnd; override;

procedure createparams(var params: tcreateparams); override;

procedure doexit; override;

procedure doenter; override;

public

constructor create(aowner: tcomponent); override;

procedure invalidate; override;

published

end;

procedure register;

implementation

constructor tbktransparentedit.create(aowner:tcomponent);

begin

inherited create(aowner);

ftransparent:=true;

end;

procedure tbktransparentedit.createwnd;

begin

inherited createwnd;

if ftransparent then  begin

setwindowlong(parent.handle, gwl_style,getwindowlong(parent.handle, gwl_style) and not ws_clipchildren);

end;

end;

procedure tbktransparentedit.bkinvalidate(var message:tmessage);

varr:trect;

begin

if (parent<>nil) and ftransparent then  begin

r:=clientrect;

r.topleft:=parent.screentoclient(clienttoscreen(r.topleft));

r.bottomright:=parent.screentoclient(clienttoscreen(r.bottomright));

redrawwindow(handle,nil,0,rdw_frame+rdw_invalidate);

end;

end;

procedure tbktransparentedit.cnctlcoloredit(var message:twmctlcoloredit);

begin

if ftransparent then

with message do

begin

setbkmode(childdc,windows.transparent);

result:=getstockobject(hollow_brush)

endelse

inherited;

end;

procedure tbktransparentedit.wmerasebkgnd(var message:twmerasebkgnd);

begin

if ftransparent and not (csdesigning in componentstate) then

postmessage(handle,twm_bkinvalidate,0,0)

else

inherited;

end;

procedure tbktransparentedit.wmmove(var message:tmessage);

begin

inherited;

if ftransparent then

sendmessage(handle,twm_bkinvalidate,0,0)

else

invalidate;

end;

procedure tbktransparentedit.createparams(var params:tcreateparams);

begin

inherited createparams(params);

if (csdesigning in componentstate) then exit;

with params do

begin

exstyle:=exstyle or ws_ex_transparent;

end;

end;

procedure tbktransparentedit.doexit;

begin

inherited;

ftransparent:=true;

setcursor(0);

recreatewnd;

end;

procedure tbktransparentedit.doenter;

varexstyle,stdstyle:longint;

begin

inherited;

ftransparent:=false;

stdstyle:= windows.getwindowlong(handle, gwl_exstyle);

exstyle:= stdstyle and not ws_ex_transparent;

windows.setwindowlong(handle, gwl_exstyle, exstyle);

invalidate;

end;

procedure tbktransparentedit.invalidate;

begin

if ftransparent then

sendmessage(handle,twm_bkinvalidate,0,0)

else

inherited;

end;

procedure register;

begin

registercomponents('bktransparentcomps', [tbktransparentedit]);

end;

end.

乙個struts spring的例子

第乙個struts spring的例子 呵呵剛學spring 寫還望各位大蝦指教!配置struts就不用說了吧,如果用myeclipse直接add一下就可以了.接下來就來配置讓它支援spring 可 一,新建專案後,開啟struts confing.xml在後面加人下面 簡單吧!二然後就開始寫我們的...

乙個sql的例子

select dbo.userinfo.username,dbo.userinfo.usertruename,dbo.userinfo.useremail,dbo.userinfo.usermobile,dbo.userinfo.usertelephone,dbo.userinfo.usercar,...

乙個API HOOK的例子

乙個api hook的例子 2010年07月20日 include include 執行緒操作api hinstance hinst 任務例項id hwnd mainfrmhwnd 主視窗控制代碼 hfont globalfont 字型 typedef struct remoteparam 視窗類名...