请问一下关于MDI窗口背景的问题 ( 积分: 100 )

  • 主题发起人 主题发起人 pangqu
  • 开始时间 开始时间
P

pangqu

Unregistered / Unconfirmed
GUEST, unregistred user!
今天学习了如何让MDI父窗体有一个背景。但是按着书上打完代码,发现没有出现背景。最后发现书上没有在form的show或create写上应有的代码,以下是书上的代码:
unit MDIMain;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, buttons,ExtCtrls,Menus,StdCtrls, ComCtrls, ToolWin, jpeg;

type
TFrmMDIMain = class(TForm)
MainMenu: TMainMenu;
N1: TMenuItem;
mminew: TMenuItem;
mmiopen: TMenuItem;
N4: TMenuItem;
mmitile: TMenuItem;
mmicascade: TMenuItem;
mmiarrangeicons: TMenuItem;
N8: TMenuItem;
mmicloseall: TMenuItem;
mmiexit: TMenuItem;
imgMain: TImage;
private
{ Private declarations }
FOldClientProc,
FNewClientProc:TFarProc;
FDrawDC:hDC;
Procedure DrawTiled;
Procedure ClientWndProc(var Message:TMessage);
procedure CreateWnd;override;
public
{ Public declarations }
end;

var
FrmMDIMain: TFrmMDIMain;

implementation
uses REMain;

procedure TFrmMDIMain.CreateWnd;
begin
inherited CreateWnd;
FnewClientProc:=MakeObjectInstance(ClientWndProc);
FOldClientProc:=Pointer(GetWindowLong(ClientHandle,GWL_WNDPROC));
setwindowLong(ClientHandle,GWL_WNDPROC,LongInt(FNewClientProc));
end;

procedure TFrmMDIMain.ClientWndProc(VAR Message:TMessage);
begin
case Message.Msg of
WM_ERASEBKGND:
begin
CallwindowProc(FOldClientProc,ClientHandle,Message.Msg,Message.WParam,Message.LParam);
FDrawDC:=TWMEraseBkGnd(Message).DC;
Drawtiled;
Message.Result:=1;
end;
WM_VSCROLL,WM_HSCROLL:
begin
message.Result:=callwindowproc(FOldClientproc,ClientHandle,message.Msg,message.WParam,message.LParam);
invalidateRect(clientHandle,Nil,true);
end;
else
Message.Result:=callwindowproc(FOldClientProc,ClientHandle,Message.Msg,Message.WParam,Message.LParam)
end;
end;

procedure TFrmMDIMain.DrawTiled;
var
row,col:integer;
CR,IR:TRect;
NumRows,NumCols:integer;
begin
Getwindowrect(clienthandle,CR);
IR:=imgMain.clientRect;
numRows:=CR.Bottom div ir.Bottom;
numcols:=cr.Right div ir.Right;
with imgmain do
for row:=0 to numrows+1 do
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;

{$R *.dfm}

end.


请问一下高手,还要怎么写才能实现如题效果。

后来在Delphi7的父窗口中直接放如image控件,也能实现MDI父窗体的背景效果,但是还是想知道代码怎么写法?
 
procedure TForm1.FormCreate(Sender: TObject);
begin
img1.Picture.Bitmap.LoadFromFile('F:/分词Me/tree分词(最新)/image/cut.bmp');
self.Brush.Bitmap:=img1.Picture.Bitmap;
end;
 
后退
顶部