L
louiszheng
Unregistered / Unconfirmed
GUEST, unregistred user!
给主窗体加背景,用老方法(在论坛里找的)
将Form的FormStyle设置为fsMDIForm,加入一个TImage,把你背景图象文件放到TImage中。
在你的Form中的private如下定义:
FClientInstance,
FPrevClientPro: TFarProc;
procedure ClientWndProc(Var Message: TMessage);
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(FPrevClientPro,ClientHandle,Msg,wParam,lParam);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientPro := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC,LongInt(FClientInstance));
end;
可是老出现一下错误:raised exception class EDivByZero with message 'division by zero',晕!
将Form的FormStyle设置为fsMDIForm,加入一个TImage,把你背景图象文件放到TImage中。
在你的Form中的private如下定义:
FClientInstance,
FPrevClientPro: TFarProc;
procedure ClientWndProc(Var Message: TMessage);
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(FPrevClientPro,ClientHandle,Msg,wParam,lParam);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientPro := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC,LongInt(FClientInstance));
end;
可是老出现一下错误:raised exception class EDivByZero with message 'division by zero',晕!