如何在MDI窗体中放入背景图片.
我在窗口中加入一IMAGE来实现,但程序运行后每当一拖动滚动条,图象变得重叠 
不知各位高手如何实现,可否详加指点,多谢!

解决方案 »

  1.   

    TFormMain=class(TForm)
        ...
      private
        { Private declarations }
        FClientInstance, 
        FPrevClientProc : TFarProc;
        procedure ClientWndProc(VAR Message: TMessage);
      end;procedure TFormMain.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 TFormMain.FormCreate(Sender: TObject);
    begin
      FClientInstance := MakeObjectInstance(ClientWndProc); 
      FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC)); 
      SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
    end;
      

  2.   

    加入panel 
    align 为alclient
    再放入image