I have a MDI application that has MDI child windows.
Those windows have a TEventScrollBox
TEventScrollBox = class(TScrollBox)
private
FVScrollEvent: TNotifyEvent;
FHScrollEvent: TNotifyEvent;
FCanvas : TCanvas;
Procedure WMVScroll( Var msg: TWMVScroll ); Message WM_VSCROLL;
Procedure WMHScroll( Var msg: TWMHScroll ); Message WM_HSCROLL;
Procedure WMPaint( Var Message: TWMPaint ); Message WM_PAINT;
public
PaintProc : TNotifyEvent;
Procedure DoVScroll;
Procedure DOHSCroll;
property OnVScroll: TNotifyEvent read FVScrollEvent write FVScrollEvent;
property OnHScroll: TNotifyEvent read FHScrollEvent write FHScrollEvent;
property Canvas : TCanvas read FCanvas;
Constructor Create(Owner: TComponent); override;
Destructor Destroy; override;
end;
Where I paint an image inside it using its ScrollBox.Canvas.Handle and in the end SetDIBitsToDevice() in the WMpaint call
It works OK, but from time to time it flickers. Setting Doublebuffered to true does not help. I have tried with putting "invalidate" but this is worse.
Here is the implementation of the WMPaint
Procedure TEventScrollBox.WMPaint( Var Message: TWMPaint );
Begin
Inherited;
If Assigned(PaintProc) then
PaintProc(Self);
End;
the constructor of TEventScrollBox
constructor TEventScrollBox.Create(Owner: TComponent);
begin
inherited Create(Owner);
PaintProc := Nil;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
end;
I tried many things without a clear success... Flickering is still visible. Any idea ?