Metafile Problem Word 2003/VB6

D

Demonic_666

The following code places an EMF onto the clipboard and when pasted
into a Word 97 or Word 2000 document, displays a yellow square
surrounded by a blue border. But in Word 2003 the blue border
disappears.
Can anybody please explain why?
Excuse code (I'm no programmer)
The code needs a command button and picturebox on the form and was
written in VB6.
***************************************************

Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As
Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function CreateEnhMetaFile Lib "gdi32" Alias _
"CreateEnhMetaFileA" (ByVal hdcRef As Long, _
ByVal lpFileName As String, lpRect As RECT, _
ByVal lpDescription As String) As Long
Private Declare Function CloseEnhMetaFile Lib "gdi32" (ByVal _
hDC As Long) As Long
Private Declare Function CopyEnhMetaFile Lib "gdi32" Alias
"CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String)
As Long
Private Declare Function DeleteEnhMetaFile Lib "gdi32" (ByVal _
hemf As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As
Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal _
wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hDC As Long, _
ByVal x As Long, ByVal y As Long, lpPoint As Any) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hDC As Long, _
ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hDC As Long,
_
ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal _
wFillType As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As
Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long,
_
ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As
Long, _
ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor
As Long) As Long
Const FLOODFILLBORDER = 0
Const FLOODFILLSURFACE = 1
Const CF_ENHMETAFILE As Long = 14
Const PS_SOLID = 0
Dim myrect As RECT

Private Sub Command1_Click()
myrect.Left = 0
myrect.Top = 0
myrect.Right = Picture1.Width
myrect.Bottom = Picture1.Height
metadc = CreateEnhMetaFile(Picture1.hDC, vbNullString, myrect,
metafilename)
myPen = SelectObject(metadc, CreatePen(PS_SOLID, 5, 65535))
MoveToEx metadc, 20, 20, ByVal 0&
LineTo metadc, (Picture1.Width / 36), 20
LineTo metadc, (Picture1.Width / 36), (Picture1.Height / 36)
LineTo metadc, 20, (Picture1.Height / 36)
LineTo metadc, 20, 20
fillbrush = SelectObject(metadc, CreateSolidBrush(vbBlue))
x = ExtFloodFill(metadc, 0, 0, 65535, FLOODFILLBORDER)
HmetacloseDC = CloseEnhMetaFile(metadc)
api_return = OpenClipboard(Picture1.hwnd)
If api_return > 0 Then
EmptyClipboard
SetClipboardData CF_ENHMETAFILE, HmetacloseDC
CloseClipboard
Else
DeleteObject HmetacloseDC
End If
DeleteEnhMetaFile HmetacloseDC
DeleteEnhMetaFile HcopymetaDC
End Sub

Hope someone can help

Demonic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top