I've had this sort of thing before with Enhanced MetaFiles, but solved the previous problem. This one is proving very puzzling indeed!!!
Basically, create a small EMF containing an image and some text. No problem. 'Play' this EMF into a larger EMF and generally - no problem.
However, the following code plays the smaller memory based EMF into a larger disc based one 3 times (one under the other). The first two copies appear fine. In the third one, however, the image disappears leaving just the text!!! This one has me stumped!
Code: Select all
LoadImage(1, "header.bmp") ;Use your own image.
hdc = CreateEnhMetaFile_(0, 0, 0, 0)
If hdc
;Create a small memory based EMF with a copy of the image and some text.
hBrush = GetStockObject_(#WHITE_BRUSH)
SetRect_(rc.RECT, 0, 0, 1000, 1000)
oldBrush = SelectObject_(hdc, hBush)
Rectangle_(hdc, 0, 0, 1000, 1000)
hdcImage = CreateCompatibleDC_(hdc)
oldImage = SelectObject_(hdcImage, ImageID(1))
StretchBlt_(hdc, 0, 0, 1000, 400, hdcImage, 0, 0, ImageWidth(1), ImageHeight(1), #SRCCOPY)
TextOut_(hdc, 0,500,@"HELLO!",6)
SelectObject_(hdcImage, oldImage)
SelectObject_(hdc, oldBrush)
DeleteDC_(hdcImage)
hEMF = CloseEnhMetaFile_(hdc)
;Render to a larger filebased emf.
If hEMF
hdc = CreateEnhMetaFile_(0, @"test.emf", 0, 0)
hBrush = GetStockObject_(#GRAY_BRUSH)
SetRect_(rc.RECT, 0, 0, 1000, 3000)
FillRect_(hdc, rc, hBrush)
SetRect_(rc.RECT, 0, 0, 1000, 500)
PlayEnhMetaFile_(hdc, hEMF, @rc)
SetRect_(rc.RECT, 0, 500, 1000, 1000)
PlayEnhMetaFile_(hdc, hEMF, @rc)
SetRect_(rc.RECT, 0, 1000, 1000, 1500) ;Only the text appears here!!!!!! Where is the image?
PlayEnhMetaFile_(hdc, hEMF, @rc)
hEMFPage = CloseEnhMetaFile_(hdc)
DeleteEnhMetaFile_(hEMFPage)
EndIf
DeleteEnhMetaFile_(hEMF)
EndIf
I've tried resetting view-point origins etc. but to no avail!
Any ideas what is going on here?
Thanks.


