以下代码明显抄的
但是别的写的不错
顺便文一句你英文几级呀
变量的英文使用真的不错 最少应该4级以上吧
procedure TMDIMainForm.CreateWnd;
//画背景图代码需要的部分,用自己的过程代替系统过程
begin
inherited CreateWnd;
FNewClientProc := MakeObjectInstance(ClientWndProc);
FOldClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FNewClientProc));
end;
procedure TMDIMainForm.DrawImage(Style:integer);
//画背景图
var
Row, Col: Integer;
CR, IR: TRect;
NumRows, NumCols: Integer;
begin
if not FDrawImage then
exit;
GetWindowRect(ClientHandle, CR);
case Style of
0:with imgMaindo
BitBlt(FDrawDC, ((CR.Right - CR.Left) - Picture.Width) div 2,
((CR.Bottom - CR.Top) - Picture.Height) div 2,
Picture.Graphic.Width, Picture.Graphic.Height,
Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
1:StretchBlt(FDrawDC, 0, 0, CR.Right, CR.Bottom,
imgMain.Picture.Bitmap.Canvas.Handle, 0, 0,
imgMain.Picture.Width, imgMain.Picture.Height, SRCCOPY);
2:begin
IR := imgMain.ClientRect;
NumRows := CR.Bottom div IR.Bottom;
NumCols := CR.Right div IR.Right;
with imgMaindo
for Row := 0 to NumRows+1do
for Col := 0 to NumCols+1 do
BitBlt(FDrawDC, Col * Picture.Width, Row * Picture.Height,
Picture.Width, Picture.Height, Picture.Bitmap.Canvas.Handle,
0, 0, SRCCOPY);
end;
end;
end;
procedure TMDIMainForm.ClientWndProc(var Msg: TMessage);
//画背景图过程,用本过程代替了系统过程处理消息
begin
case Msg.Msg of
WM_ERASEBKGND:
begin
CallWindowProc(FOldClientProc, ClientHandle, Msg.Msg, Msg.wParam,
Msg.lParam);
FDrawDC := TWMEraseBkGnd(Msg).DC;
DrawImage(iDrawStyle);
Msg.Result := 1;
end;
WM_VSCROLL, WM_HSCROLL:
begin
Msg.Result := CallWindowProc(FOldClientProc, ClientHandle, Msg.Msg,
Msg.wParam, Msg.lParam);
InvalidateRect(ClientHandle, nil, True);
end;
else
Msg.Result := CallWindowProc(FOldClientProc, ClientHandle, Msg.Msg,
Msg.wParam, Msg.lParam);
end;
end;
procedure TMDIMainForm.FormResize(Sender: TObject);
//窗体尺寸变化让背景失效
begin
InvalidateRect(ClientHandle, nil, True);
end;
end.