Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying an enhanced metafile to the clipboard

Status
Not open for further replies.

LindaRichard

Programmer
Feb 23, 2001
103
CA
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
 
i have not tried anything with emf but, i tried copying and pasting of bitmaps anywhere i like using the following functions + some others of the same category


Private Declare Function CreateCompatibleDC Lib "gdi32" Alias "CreateCompatibleDC" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" Alias "SelectObject" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long


hopefully this will help
regards
aniket
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top