问题如下解决,但是当用户区动态变小时(一个Panel变成Visible),图片严重闪烁。
procedure TBBMainFrm.DrawStretched;
// This procedure stretches the image on the form's client area
var
CR: TRect;
begin
GetWindowRect(ClientHandle, CR);
StretchBlt(FDrawDC, 0, 0, CR.Right, CR.Bottom,
Image1.Picture.Bitmap.Canvas.Handle,
0, 0,Image1.Picture.Width, Image1.Picture.Height,
SRCCOPY);
end;
procedure TBBMainFrm.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;
DrawStretched
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 TBBMainFrm.CreateWnd;
begin
inherited CreateWnd;
FNewClientProc := MakeObjectInstance(ClientWndProc);
FOldClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FNewClientProc));
end;