Does anybody have experience of using HandleTypeHDC with Direct2D versions of Xojo?
We have a custom control that draws its content via the WM_PAINT message of a custom WndProc. Part of the content is a Xojo picture which is drawn by grabbing its HDC Handle and calling BitBlt.
This works perfectly in Xojo 2014 but doesn’t work correctly in Xojo 2019r1.1
As soon as we grab the HDC, the picture content seems to get cached. This means that if we make further changes to the picture and draw it again we still get the original content.
I’ve managed to distill the problem down to a few lines of code which I have included below.
When the code hits the first break, ‘p’ will consist of a red oval on a black background. However, when the second break is hit, both ‘p’ and ‘p2’ will just contain the black background.
So far, the only solution we have found is to create a temporary copy of the picture, grab its HDC, call BitBlt and then throw the temporary copy away. Although this appears to solve the problem we would prefer to find a solution that is more efficient.
[code]Dim p As New Picture(100, 100, 32)
Dim hdc As Integer
p.Graphics.FillRect(0, 0, 100, 100)
hdc = p.Graphics.Handle(Graphics.HandleTypeHDC)
p.Graphics.ForeColor = RGB(255, 0, 0)
p.Graphics.FillOval(0, 0, 100, 100)
'check the contents of p - it should be a red circle on a black background
Break
Dim p2 As New Picture(p.Width, p.Height, p.Depth)
p2.Graphics.DrawPicture(p, 0, 0)
'check the contents of p2 - it should be the same as p but it is p at the point we retrieved the HDC
'check the contents of p - it has actually reverted back
Break[/code]