D
devil_li
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个控件,继承自TCustomPanel,现在在上面画上一个矩形框:
procedure TBcDrawPanel.MouseMove(Shift: TShiftState; X, Y: Integer);
....
Canvas.Rectangle(FSrcPt.X, FSrcPt.Y, FDestPt.X, FDestPt.Y); //清除前一个图形
Canvas.Rectangle(FSrcPt.X, FSrcPt.Y, X, Y); //画上现在的图形
....
画图时有闪烁.
1.设置窗体和控件的DoubleBuffered:=True都不行,
因为doubleBuffered处理是在WM_PAINT消息中完成的:
procedure TWinControl.WMPaint(var Message: TWMPaint);
....
if not FDoubleBuffered or (Message.DC <> 0) then
....
2.WM_ERASEBKGND也不行:
procedure TBcCustomDrawPanel.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 0;
end;
3.直接画在Canvas.Handle上也不行:
Rectangle(Canvas.Handle, FSrcPt.X, FSrcPt.Y, FDestPt.X, FDestPt.Y); //清除前一个图形
Rectangle(Canvas.Handle, FSrcPt.X, FSrcPt.Y, X, Y); //画上现在的图形
4.控件总体的刷新我用的内存中画图的方法,但是在画矩形时我不希望用内存中画图的方法.
请教各位高招
procedure TBcDrawPanel.MouseMove(Shift: TShiftState; X, Y: Integer);
....
Canvas.Rectangle(FSrcPt.X, FSrcPt.Y, FDestPt.X, FDestPt.Y); //清除前一个图形
Canvas.Rectangle(FSrcPt.X, FSrcPt.Y, X, Y); //画上现在的图形
....
画图时有闪烁.
1.设置窗体和控件的DoubleBuffered:=True都不行,
因为doubleBuffered处理是在WM_PAINT消息中完成的:
procedure TWinControl.WMPaint(var Message: TWMPaint);
....
if not FDoubleBuffered or (Message.DC <> 0) then
....
2.WM_ERASEBKGND也不行:
procedure TBcCustomDrawPanel.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 0;
end;
3.直接画在Canvas.Handle上也不行:
Rectangle(Canvas.Handle, FSrcPt.X, FSrcPt.Y, FDestPt.X, FDestPt.Y); //清除前一个图形
Rectangle(Canvas.Handle, FSrcPt.X, FSrcPt.Y, X, Y); //画上现在的图形
4.控件总体的刷新我用的内存中画图的方法,但是在画矩形时我不希望用内存中画图的方法.
请教各位高招