这个问题我已经解决了。现在又有新问题:我在MDI的主窗体中放置一张图片,
程序如下。但在子窗体的大小发生变化(尤其从最大化到常规时)图片闪得
厉害,请问各位高人有何解决方法。
TFrmMDIMain=Class(TForm)
private
FOldClientProc,
FNewClientProc: TFarProc;
procedure DrawStretched;
procedure ClientWndProc(var Message: TMessage);
protected
procedure CreateWnd; override;
public
end ;
procedure TFrmMDIMain.DrawStretched;
var
CR: TRect;
begin
GetWindowRect(ClientHandle, CR);
StretchBlt(FDrawDC, 0, 0, CR.Right, CR.Bottom,
imgMain.Picture.Bitmap.Canvas.Handle, 0, 0,
imgMain.Picture.Width, imgMain.Picture.Height, SRCCOPY);
end;
procedure TFrmMDIMain.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 TFrmMDIMain.CreateWnd;
begin
inherited CreateWnd;
FNewClientProc := MakeObjectInstance(ClientWndProc);
FOldClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FNewClientProc));
end;