可以通过下列程序例程实现MDI主窗口丰富的背景:
1、将Form1设置为fsMDIForm;
2、在Form1的Private中定义:
FClientInstance,FPrevClientProc:TFarProc;
Procedure ClientWndProc(Var Message:TMessage);
3、在Form1中增加一个Timage组件,将待设置的背景加到Timage的Picture中;
4、过程Procedure ClientWndProc(Var Message:TMessage)内容:
Procedure 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
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:=CallWindowsProc
(FPrevClientProc,ClientHandle,Msg,wParam,lParam);
end;
end;
5、在Form1的OnCreat事件中加入:
FClientInstance:=MakeObjectInstance(ClientWndProc);
FPrevClientProc:=Pointer(GetWindowsLong(ClientHandle,GWL_WndProc));
SetWindowsLong(ClientHandle,GWL_WndProc,LongInt(FClientInstance);
6、试试看!