LindaRichard
Programmer
I am trying to modify the code from Dan Appleman's book which copies a standard
Windows metafile to the clipboard so that it will copy an enhanced metafile instead.
The following code is very simple, it draws an ellipse in a picture box called picture1.
This part works fine. The problem seems to be in the part that copies to the clipboard. I don't get any error messages but the image is not copied properly
to the clipboard. When I go to Word 2000 is doesn't recognize the image as emf.
Any suggestions?
Thanks Linda
Private Sub mnu_MetafileCopy_Click()
Dim hdcMeta&
Dim dl&, di&
Dim newmf&
Dim dc&
Dim rc As RECT
Dim oldsize As SIZE
rc.Left = Picture1.ScaleWidth 'x size
rc.Top = Picture1.ScaleHeight 'y size
rc.Right = 0 'x location
rc.Bottom = 0 'y location
dc = Picture1.hdc
Picture1.Cls
hdcMeta = CreateEnhMetaFile(0, vbNullString, rc, vbNullString)
dl& = SetWindowExtEx(hdcMeta, Picture1.ScaleWidth, Picture1.ScaleHeight, oldsize)
di = Ellipse(dc, Picture1.ScaleWidth * 0.2, Picture1.ScaleHeight * 0.2, Picture1.ScaleWidth * 0.8, Picture1.ScaleHeight * 0.8)
newmf = CloseEnhMetaFile(hdcMeta)
' Place the metafile into the clipboard
di = OpenClipboard(Picture1.hwnd)
di = EmptyClipboard()
'note CF_ENHMETAFILE = 14
di = SetClipboardData(CF_ENHMETAFILE, newmf)
di = CloseClipboard()
End Sub
Windows metafile to the clipboard so that it will copy an enhanced metafile instead.
The following code is very simple, it draws an ellipse in a picture box called picture1.
This part works fine. The problem seems to be in the part that copies to the clipboard. I don't get any error messages but the image is not copied properly
to the clipboard. When I go to Word 2000 is doesn't recognize the image as emf.
Any suggestions?
Thanks Linda
Private Sub mnu_MetafileCopy_Click()
Dim hdcMeta&
Dim dl&, di&
Dim newmf&
Dim dc&
Dim rc As RECT
Dim oldsize As SIZE
rc.Left = Picture1.ScaleWidth 'x size
rc.Top = Picture1.ScaleHeight 'y size
rc.Right = 0 'x location
rc.Bottom = 0 'y location
dc = Picture1.hdc
Picture1.Cls
hdcMeta = CreateEnhMetaFile(0, vbNullString, rc, vbNullString)
dl& = SetWindowExtEx(hdcMeta, Picture1.ScaleWidth, Picture1.ScaleHeight, oldsize)
di = Ellipse(dc, Picture1.ScaleWidth * 0.2, Picture1.ScaleHeight * 0.2, Picture1.ScaleWidth * 0.8, Picture1.ScaleHeight * 0.8)
newmf = CloseEnhMetaFile(hdcMeta)
' Place the metafile into the clipboard
di = OpenClipboard(Picture1.hwnd)
di = EmptyClipboard()
'note CF_ENHMETAFILE = 14
di = SetClipboardData(CF_ENHMETAFILE, newmf)
di = CloseClipboard()
End Sub