In C++ with GDI+ I would like to draw a metafile, but modifying it in such a way that the brushes and pens are replaced by the ones I created in my program. I would like this brush and this pen to be used instead of any others specified in the metafile itself.
How could I achieve this?
I tried to use EnumerateMetafile and PlayRecord, but I don't see how to get control on the pen and brush being used. I tried the code below to select the current Pen and Brush of the underlying HDC, but as I was expecting it does not work...
Any suggestion please? (I would like to avoid rewriting a full handling of all EMF record types)
Thanks in advance.
Tentative code (does not do anything, as expected):
// callback function called by EnumerateMetafile:
BOOL CALLBACK metaCallback(
EmfPlusRecordType recordType,
unsigned int flags, unsigned int dataSize, const unsigned char* pStr, void* metafile)
{
HDC hdc = myGraphics->GetHDC ();
SelectObject(hdc, GetStockObject(WHITE_PEN));
myGraphics->ReleaseHDC(hdc);
static_cast <Metafile*>(metafile)->PlayRecord(recordType, flags, dataSize, pStr);
return TRUE;
}