我的背景为什么不能显示?高分求解!!来者有份

shangxuesong 2003-04-22 03:13:33
unit Unit_MDIform;

interface

uses
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.
...全文
99 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
shangxuesong 2003-05-04
  • 打赏
  • 举报
回复
to 等你一生

你说的对
我原来用的时jpg格式的
shangxuesong 2003-05-04
  • 打赏
  • 举报
回复
to firetoucher(蹈火者)

你说的不行
我试了
还是报同样的错
zhangkeus 2003-05-01
  • 打赏
  • 举报
回复
接分
我不要昵称 2003-04-22
  • 打赏
  • 举报
回复
你要加载bmp图,不能用jpg图,如果是jpg图也会出division by zero错误
boz 2003-04-22
  • 打赏
  • 举报
回复
//改一下控件属性
image1.Align:=alClient;
firetoucher 2003-04-22
  • 打赏
  • 举报
回复
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
cscer 2003-04-22
  • 打赏
  • 举报
回复
Image1没有图片吗

或者尺寸为0
shangxuesong 2003-04-22
  • 打赏
  • 举报
回复
for Ro := 0 to clientHeight div Image1.Picture.Height do
for co := 0 to Clientwidth div Image1.Picture.Width do
这两句总是报错:division by zero

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧