关于壁纸(100分)

  • 主题发起人 主题发起人 俞雷
  • 开始时间 开始时间

俞雷

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在MDI父窗口中的客户区显示自己的壁纸(如显示 *.BMP)。
 
在form中加入一个image控件,align=client,在image控件中加入你需要的图片.
 
没这么简单, 虽然我想肯定已经有人问过这个问题而且有了解答,我还是贴

private
{ Private declarations }
FClientInstance, FDefClientProc: TFarProc;
procedure ClientWndProc(var message:tmessage);

procedure TForm1.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FDefClientProc := pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(clienthandle, GWL_WNDPROC, LongInt(FClientInstance));
end;

procedure TForm1.ClientWndProc(var message:tmessage);
var
DC: HDC;
Row, Col: WORD;
begin
if Assigned(@Form1) then
begin
with message do
begin
case Msg of
WM_ERASEBKGND:
begin
try
DC := TWMEraseBkgnd(message).DC;
for Row := 0 to ClientHeight div Image1.Picture.Height do
for Col := 0 to ClientWidth div Image1.Picture.Width do
begin
BitBlt(DC, Col*Image1.Picture.Width,
Row*Image1.Picture.Height, Image1.Picture.Width,
Image1.Picture.Height,
Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
end;
Result:=1;
except
end;
end;
else
Result := CallWindowProc(
FDefClientProc, ClientHandle, Msg, WParam, LParam);
end;
end
end;
end;
 
接受答案了.
 
后退
顶部