What I need
I need to get the DC of a Firemonkey component's TCanvas
. I need this to use Win API drawing functions not accessible through Firemonkey, mainly 100% control over font rendering.
Obviously, this is a pure Windows Application, so any compatibilities with OSX isn't an issue.
What I did
I managed to get hold of the TForm's handle and convert it into a HWND, then getting the DC with GetDC(FmxHandleToHWND(Handle));
This is the OnPaint
handler for the Character_PaintBox
control.
HWND hWND = FmxHandleToHWND(Handle);
HDC hDC = GetDC(hWND);
int x = PreviewBack_Rectangle->Position->X + Character_PaintBox->Position->X;
int y = PreviewBack_Rectangle->Position->Y + Character_PaintBox->Position->Y;
TextOut(hDC,x,y,L"Test",4);
ReleaseDC(hWND,hDC);
How ever this is the Form's DC and anything I write is overwritten at next update.
This was an easy task in VCL and it can't be that complicated in Firemonkey, or?