PtPolygon and PtBezier versus Memory Context

I need to draw the content of the window to the memory context to create image for some reason. I used the example that is in the documetation - function PmMemCreateMC().
Everything works except PtPolygon and PtBezier widgets that are not drawn at all (simple window) or are drawn in wrong way (in case of window with many widgets). :frowning:

Does anybody have any experience ? Am I doing anything wrong ?
Thanks for any ideas.

The sample project attached.

Hmm, … no reply yet.

I tried to draw to the OffScreenContext. It works properly. So I guess that ?bug? is somewhere inside of the Memory context ?

However, HOW TO PUT OffScreenContext TO THE IMAGE AND THEN TO WRITE IT TO THE FILE ? The application should work on the background without any change of the screen.

Thanks in advance for any help.