Updated: Dec 16, 2023
Follow on twitter

Receiving of background image for the TChart from the skin.

Here is a code of procedure which helps to receive a background for the TChart:

// Receive a background for the control and repainting of chart procedure UpdateChartBackImage(Chart: TChart); var bgInfo: TacBGInfo; begin if not InUpdating(Form1.sSkinProvider1.SkinData) then begin // If parent background is ready // Receive a BG data from a skinned parent of control GetBGInfo(@bgInfo, Chart.Parent); // Creation of bitmap for the Chart.BackImage property (if not exists) if Chart.BackImage.Bitmap = nil then Chart.BackImage.Bitmap := TBitmap.Create; Chart.BackImage.Bitmap.Width := Chart.Width; Chart.BackImage.Bitmap.Height := Chart.Height; Chart.BackImage.Bitmap.PixelFormat := pf32bit; if bgInfo.BgType = btCache then // If BG should be copied (complex image) BitBlt(Chart.BackImage.Bitmap.Canvas.Handle, 0, 0, Chart.Width, Chart.Height, bgInfo.Bmp.Canvas.Handle, bgInfo.Offset.X + Chart.Left, bgInfo.Offset.Y + Chart.Top, SRCCOPY) else // otherwise fill BG by received color FillDC(Chart.BackImage.Bitmap.Canvas.Handle, Rect(0, 0, Chart.Width, Chart.Height), bgInfo.Color); // Update a BG of chart Chart.BackImage.Assign(Chart.BackImage.Bitmap); Chart.Invalidate; end; end;

Example of using of the above code look in this demo

Similar code may be used for receiving of background for other custom controls, also.






Installing, using and licensing the demo programs © Sergii Goncharov, Ukraine, Odessa 2004-2023