I jumped into an old MFC application which has a problem when run under Windows 10 1703/Creators update. It works fine for XP to Windows 10/1607. After some investigation, it seems that in Windows 10/1703 the app cannot paste metafiles (wmf and emf) from the clipboard into an CRichTextView and save it. The graphics data is not embedded in the rtf file. Here is a stripped down example:
static void testFn(CRichEditView* View)
{
// Minimal Example
// Init MetaFileDC
CMetaFileDC MetaFileDC;
CClientDC DC(NULL);
MetaFileDC.CreateEnhanced(NULL, NULL, NULL, NULL);
CRect Recht(0, 0, 400, 300);
MetaFileDC.SetAttribDC(DC.m_hDC);
MetaFileDC.SetWindowOrg(0, 0);
MetaFileDC.SetWindowExt(Recht.Size());
// draw : "ABC" and a line
MetaFileDC.TextOutA(0, 0, "ABC");
MetaFileDC.MoveTo(0, 0);
MetaFileDC.LineTo(Recht.right, Recht.bottom);
// to clipboard
View->OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_ENHMETAFILE, MetaFileDC.CloseEnhanced());
CloseClipboard();
// paste from clipboard
View->GetRichEditCtrl().Paste();
// save rtf file
View->GetDocument()->OnSaveDocument("abc.rtf");
}
This example pastes a enhanced metafile mit "ABC" and a line into the CRichTextView and saves the document as "abc.rtf"
- From Windows XP to Windows 10/1607 this works fine
- with the latest Creators update the file is smaller and the data is not saved
It is probably related to RichEditBox: picture and content after the picture disappear (Windows 10 1703 Creators Update)
Any ideas? Is there a way to get the metafile graphics in the document without the clipboard? Bitmaps still work.
We had the same problem in our software after creators update. We also get our graphic via the clipboard. After some research on Google and SO I came up with this:
We use this now to insert graphics into our document. I have not tried it as a standalone document.