0

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 ?

Alcor Prism
  • 137
  • 7
  • Please provide a [mre] that includes your actual `PaintProc` that demonstrates the issue. Without knowing how you're actually painting, it's impossible to help troubleshoot the issue. Also, have you seen [this post](https://stackoverflow.com/q/6142954/62576)? – Ken White Mar 04 '23 at 23:47
  • Also, see Danny Thorpe's answer to [this question](https://stackoverflow.com/q/6363954/62576), which specifically addresses painting a scrolling window like TScrollbox. – Ken White Mar 05 '23 at 00:01
  • Ken, the link seems very interesting, I'll look at it. – Alcor Prism Mar 05 '23 at 00:38

0 Answers0