Draw on a component with canvas lazarus / 39-Graphics ---------------------------------------------------------------------- mmxngg · 2012-02-15 09:53 I want to draw a rectangle on a component (a scrollbox) for dinamically select (at runtime) other components inside it. I have tried this : Code: [Select]{ Save the canvas } DesignBuffer := TBitmap.Create; DesignBuffer.LoadFromDevice(ScrollBoxDesign.Canvas.Handle); DesignArea.Top    := ScrollBoxDesign.VertScrollBar.Position; DesignArea.Bottom := DesignArea.Top  + ScrollBoxDesign.Height - 1; DesignArea.Left   := ScrollBoxDesign.HorzScrollBar.Position; DesignArea.Right  := DesignArea.Left + ScrollBoxDesign.Width  - 1; { Draw something (Selection are inside bounds) } ScrollBoxDesign.Canvas.Rectangle(SelectionLeft, SelectionTop, SelectionRight, SelectionBottom); { Restore the canvas } ScrollBoxDesign.Canvas.CopyRect(DesignArea, DesignBuffer.Canvas, DesignArea); Works well when scrollbox don't have scrolling else i get SIGSEGV error when i try to restore the canvas. What's wrong ? ---------------------------------------------------------------------- User137 · 2012-02-15 11:17 How is DesignBuffer handled? You are creating new instance of TBitmap every time you save, are you freeing it properly after it is used to restore? ---------------------------------------------------------------------- mmxngg · 2012-02-15 18:32 OnMouseDown - Create and save OnMouseMove - Restore and draw OnMouseUp - Restore and free All my issues are with TScrollbox....i will cut off it and replaced by custom component for making a scroll... :/