unit Unit_MDIform;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls;type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
     FclientInstance,
     FprevClientProc:TFarProc;
     procedure ClientWndProc(var MEssage:tmessage);
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation
{$R *.dfm}
 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;
procedure TForm1.FormCreate(Sender: TObject);
begin
FClientInstance:=MakeObjectInstance(clientwndProc);
FprevClientProc:=Pointer(getwindowLong(clientHandle,GWL_WNDPROC));
SetWindowLong(clientHandle,GWL_WNDPROC,longInt(FClientInstance));
end;end.

解决方案 »

  1.   

    for Ro := 0 to clientHeight  div   Image1.Picture.Height do
        for co := 0 to Clientwidth  div Image1.Picture.Width do
    这两句总是报错:division by zero
      

  2.   

    ft,你进入消息循环时picture对象好像还没来得及加载,
    if (Image1.Picture <> null) and !(Image1.Picture.Height) and (!Image1.Picture.Width )
    begin
    for Ro := 0 to clientHeight  div   Image1.Picture.Height do
        for co := 0 to Clientwidth  div Image1.Picture.Width do
      

  3.   

    //改一下控件属性
    image1.Align:=alClient;
      

  4.   

    你要加载bmp图,不能用jpg图,如果是jpg图也会出division by zero错误
      

  5.   

    to firetoucher(蹈火者)你说的不行
    我试了
    还是报同样的错
      

  6.   

    to 等你一生你说的对
    我原来用的时jpg格式的