在Form的Private中加入如下定义: FClientInstance,FPrevClientProc:TFarProc; procedure ClientWndProc(var Message:TMessage); 在实现(implementation)部分加入上述过程的具体内容: procedure TForm1.ClientWndProc(var Message:TMessage); var MyDC:hDC; Ro,Co:Word; begin with Message do case Msg of WM_ERASEBKGND: begin MyDC:=TWMEraseBkGnd(Message).DC; for Ro:=0 to ClientHeight div Image1.Picture.Height do for Co:=0 to ClientWidth div Image1.Picture.Width do BitBlt(MyDC,Co*Image1.Picture.Width,Ro*Image1.Picture.Height,Image1.Picture.Width,Image1.Picture.Height,Image1.Picture.Bitmap.Canvas.Handle,0,0,SRCCOPY); Result:=1; end; else Result:=CallWindowProc(FPrevClientProc,ClientHandle,Msg,wParam,lParam); end; end;在Form的Create事件中加入: FClientInstance:=MakeObjectInstance(ClientWndProc); FPrevClientProc:=Pointer(GetWindowLong(ClientHandle,GWL_WNDPROC)); SetWindowLong(ClientHandle,GWL_WNDPROC,LongInt(FClientInstance));当然,不要忘了在Form上放一个名字为Image1的TImage,而且其Picture要为BMP格式,OK!
FClientInstance,FPrevClientProc:TFarProc;
procedure ClientWndProc(var Message:TMessage);
在实现(implementation)部分加入上述过程的具体内容:
procedure TForm1.ClientWndProc(var Message:TMessage);
var
MyDC:hDC;
Ro,Co:Word;
begin
with Message do
case Msg of
WM_ERASEBKGND:
begin
MyDC:=TWMEraseBkGnd(Message).DC;
for Ro:=0 to ClientHeight div Image1.Picture.Height do
for Co:=0 to ClientWidth div Image1.Picture.Width do
BitBlt(MyDC,Co*Image1.Picture.Width,Ro*Image1.Picture.Height,Image1.Picture.Width,Image1.Picture.Height,Image1.Picture.Bitmap.Canvas.Handle,0,0,SRCCOPY);
Result:=1;
end;
else
Result:=CallWindowProc(FPrevClientProc,ClientHandle,Msg,wParam,lParam);
end;
end;在Form的Create事件中加入:
FClientInstance:=MakeObjectInstance(ClientWndProc);
FPrevClientProc:=Pointer(GetWindowLong(ClientHandle,GWL_WNDPROC));
SetWindowLong(ClientHandle,GWL_WNDPROC,LongInt(FClientInstance));当然,不要忘了在Form上放一个名字为Image1的TImage,而且其Picture要为BMP格式,OK!