procedure TFormMdiMain.NewWinProcedure(var msg: TMessage);
var
BmpWidth, BmpHeight,picwidth,picheight: Integer;
I, J: Integer;
begin
Msg.Result := CallWindowProc (OldWinProc,
ClientHandle, Msg.Msg, Msg.wParam, Msg.lParam); if Msg.Msg = wm_EraseBkgnd then
begin
BmpWidth := Image1.Width;
BmpHeight := Image1.Height;
if (BmpWidth <> 0) and (BmpHeight <> 0) then
begin
OutCanvas.Handle := Msg.wParam;
if picFeature=PIC_TITLE then
begin
for I := 0 to Formmdimain.ClientWidth div BmpWidth do
for J := 0 to Formmdimain.ClientHeight div BmpHeight do
OutCanvas.Draw (I * BmpWidth,
J * BmpHeight, Formmdimain.Image1.Picture.Graphic);
end;
if picFeature=PIC_CENTER then
begin
picWidth:=round((FormMdiMain.ClientWidth-BmpWidth) / 2);
picHeight:=round((FormMdiMain.ClientHeight-BmpHeight-ControlBar1.Height) /2);
OutCanvas.Draw(picWidth,picheight,Formmdimain.Image1.Picture.Graphic);
end;
end;
Msg.Result:=1;
end;
end;
在delphi5种写过这样一个mdi窗体背景绘图代码,不过最近用delphi 7重新编译的时候出现了问题,如果选择图片居中时,会出现两幅图片,以前delphi 5中则是正常的,请大家帮帮忙!
var
BmpWidth, BmpHeight,picwidth,picheight: Integer;
I, J: Integer;
begin
Msg.Result := CallWindowProc (OldWinProc,
ClientHandle, Msg.Msg, Msg.wParam, Msg.lParam); if Msg.Msg = wm_EraseBkgnd then
begin
BmpWidth := Image1.Width;
BmpHeight := Image1.Height;
if (BmpWidth <> 0) and (BmpHeight <> 0) then
begin
OutCanvas.Handle := Msg.wParam;
if picFeature=PIC_TITLE then
begin
for I := 0 to Formmdimain.ClientWidth div BmpWidth do
for J := 0 to Formmdimain.ClientHeight div BmpHeight do
OutCanvas.Draw (I * BmpWidth,
J * BmpHeight, Formmdimain.Image1.Picture.Graphic);
end;
if picFeature=PIC_CENTER then
begin
picWidth:=round((FormMdiMain.ClientWidth-BmpWidth) / 2);
picHeight:=round((FormMdiMain.ClientHeight-BmpHeight-ControlBar1.Height) /2);
OutCanvas.Draw(picWidth,picheight,Formmdimain.Image1.Picture.Graphic);
end;
end;
Msg.Result:=1;
end;
end;
在delphi5种写过这样一个mdi窗体背景绘图代码,不过最近用delphi 7重新编译的时候出现了问题,如果选择图片居中时,会出现两幅图片,以前delphi 5中则是正常的,请大家帮帮忙!
varDC:hDC;
begin
if Message.Msg=WM_ERASEBKGND then
begin
varDC:=TWMERASEBKGND(Message).DC;
StretchBlt(varDC,0,0,ClientWidth,ClientHeight,Image1.Picture.Bitmap.Canvas.Handle,0,0,Image1.Picture.Width,Image1.Picture.Height,SRCCOPY);
Message.result:=1;
end else if Message.Msg = WM_SIZE then
begin
InvalidateRect(ClientHandle, nil, True);
Message.Result:=CallWindowProc(FPrevClientProc,ClientHandle,Message.Msg,Message.wParam,Message.lParam);
end
else Message.Result:=CallWindowProc(FPrevClientProc,ClientHandle,Message.Msg,Message.wParam,Message.lParam);
end;