Canvas.Brush.Color in OnLegendDrawSymbol
Posted: Wed Jun 06, 2007 7:47 pm
If I use the following code, it appears that the Canvas.Brush.Color is not getting picked up, when it draws the brush pattern, black is the fore color used instead of the color I want:
If I use a "regular" Brush.Style like bsHorizontal, bsCross, bsVertical, etc.. it seems fine. Only when I use one of the styles above bsDiagCross does it not work.
My standard way of fixing this is a strategically placed Brush.ClearImage() call, but when called on the canvas brush here, it fails/crashes.
Note that I am doing this in the first place because it appears the standard drawing code for the legend inverts the foreground and background colors for the brushes. For example, running below:
You can see that in the actual chart, red is the background, and green is the foreground. In the legend, the symbol is drawn with green as the background, and red as the foreground.
So, I guess if either one of these issues is fixed, it will help me.
Thanks.
Code: Select all
Private Sub Form_Load()
TChart1.AddSeries scArea
TChart1.Series(0).FillSampleValues (10)
TChart1.Legend.Visible = True
End Sub
Private Sub TChart1_OnLegendDrawSymbol(ByVal Series As Long, ByVal ValueIndex As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
TChart1.Canvas.Pen.Color = RGB(0, 0, 255)
TChart1.Canvas.Pen.Style = psSolid
'Can't do this, it fails
'TChart1.Canvas.Brush.ClearImage
TChart1.Canvas.Brush.Color = RGB(255, 0, 0)
TChart1.Canvas.Brush.Style = bsCrossSmall
TChart1.Canvas.BackColor = RGB(0, 255, 0)
TChart1.Canvas.BackMode = cbmOpaque
TChart1.Canvas.Rectangle Left, Top, Right, Bottom
End Sub
My standard way of fixing this is a strategically placed Brush.ClearImage() call, but when called on the canvas brush here, it fails/crashes.
Note that I am doing this in the first place because it appears the standard drawing code for the legend inverts the foreground and background colors for the brushes. For example, running below:
Code: Select all
Private Sub Form_Load()
TChart1.AddSeries scArea
TChart1.Series(0).FillSampleValues (10)
TChart1.Legend.Visible = True
TChart1.Series(0).asArea.AreaChartBrush.Color = RGB(255, 0, 0)
TChart1.Series(0).asArea.AreaChartBrush.Style = bsDiagSmall
TChart1.Series(0).asArea.AreaColor = RGB(0, 255, 0)
End Sub
So, I guess if either one of these issues is fixed, it will help me.
Thanks.