Gradients on Walls, not using the canvas buffer, and Draw()
Posted: Tue Jul 24, 2007 8:27 pm
Using TChart ActiveX 7.0.1.4
I've found that using the following VB code doesn't show the gradient for the left wall, instead it is transparent.
If you set Canvas.UseBuffer to True, or you set the viewport and window extent to the same thing, then it works, otherwise it doesn't. TChart seems to be not respecting the mapping mode for the device context when drawing the gradients for the walls.
Is there a workaround to make this work under these conditions? Or is this just a bug that will have to be fixed?
I've found that using the following VB code doesn't show the gradient for the left wall, instead it is transparent.
If you set Canvas.UseBuffer to True, or you set the viewport and window extent to the same thing, then it works, otherwise it doesn't. TChart seems to be not respecting the mapping mode for the device context when drawing the gradients for the walls.
Is there a workaround to make this work under these conditions? Or is this just a bug that will have to be fixed?
Code: Select all
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type size
CX As Long
CY As Long
End Type
Private Declare Function SetMapMode Lib "gdi32" (ByVal hdc As Long, _
ByVal nMapMode As Integer) As Integer
Private Declare Function SetViewportExtEx Lib "gdi32" _
(ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, _
lpSize As size) As Long
Private Declare Function SetViewportOrgEx Lib "gdi32" _
(ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, _
lpPoint As POINTAPI) As Long
Private Declare Function SetWindowExtEx Lib "gdi32" _
(ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, _
lpSize As size) As Long
Private Declare Function SetWindowOrgEx Lib "gdi32" _
(ByVal hdc As Long, ByVal nX As Long, ByVal nY As Long, _
lpPoint As POINTAPI) As Long
Dim tchart1 As TChart
Dim nX As Integer
Dim nY As Integer
Private Sub Form_Load()
Set tchart1 = CreateObject("TeeChart.TChart")
tchart1.AutoRepaint = False
tchart1.Canvas.UseBuffer = False
With tchart1.Walls.Left.Gradient
.Visible = True
.StartColor = RGB(255, 0, 0)
.EndColor = RGB(0, 255, 0)
End With
With tchart1.Panel.Gradient
.Visible = True
.StartColor = RGB(0, 0, 255)
.EndColor = RGB(255, 0, 255)
.Direction = gdDiagonalUp
End With
Dim lpPoint As POINTAPI
Dim lpSize As size
nX = 400
nY = 400
SetMapMode Me.hdc, 7
SetViewportOrgEx Me.hdc, 0, 0, lpPoint
SetWindowOrgEx Me.hdc, 0, 0, lpPoint
SetViewportExtEx Me.hdc, nX, nY, lpSize
SetWindowExtEx Me.hdc, nX * 2, nY * 2, lpSize
End Sub
Private Sub Form_Paint()
tchart1.Draw Me.hdc, 0, 0, nX * 2, nY * 2
End Sub