For some reason, my calls to Crea*hMetafile seem to be NULL, but when
querying GetLastError returns always 0?
(I use a NULL hRefDC handle)
'**FROM MICROSOFT KNOWLEDGE BASE
Dim sMMRect As RECTL
Dim iWidthMM As Long, iHeightMM As Long
Dim iWidthPels As Long, iHeightPels As Long
iWidthMM = apiGetDeviceCaps(hDC, HORZSIZE)
iHeightMM = apiGetDeviceCaps(hDC, VERTSIZE)
iWidthPels = apiGetDeviceCaps(hDC, HORZRES)
iHeightPels = apiGetDeviceCaps(hDC, VERTRES)
sMMRect.Left = (.Left * iWidthMM * 100) / iWidthPels
sMMRect.Top = (.Top * iHeightMM * 100) / iHeightPels
sMMRect.Right = (.Right * iWidthMM * 100) / iWidthPels
sMMRect.Bottom = (.Bottom * iHeightMM * 100) / iHeightPels
'OK let's create the enhanced Metafile
'If you need to also create a disk file use this line
'hdcMeta = apiCrea*hMetaFile(hDC, "SLemf.emf", sMMRect,
hdcMeta = apiCrea*hMetaFile(hDC, 0&, sMMRect, vbNullString)
Quote:>For some reason, my calls to Crea*hMetafile seem to be NULL, but
>querying GetLastError returns always 0?
>(I use a NULL hRefDC handle)
Since it is a bit of a problem to grab to context if I havn't specified any,
I will show you the code that is offending and describe more precisely when
the error occurs.
I have written a component (ActiveX DLL, Apartment Threaded, VB6 SP2) which
contains code that creates a metafile. It receives the dimensions, the
reference DC, a filename and an optional comment as parameters (as you will
see in the code).
With the using code, I do not pass a references hDC in, so that
Crea*hMetafile relies on the display device (by default). Passing a
filename or not doesn't change a thing. Neither does the comment stuff.
When running the project in the IDE (both the ActiveX project and the main
project are loaded) then no error occurs at all: it simply works fine.
But when I compile the project, my call to Crea*hMetafile returns NULL
(sorry, I mean 0&) , this will be catched an finally an Err is raised in the
call to RaiseApiError (which retrieves the message description from the
passed in error code). But the error raised is: Err.Number := 0,
Description:= The operation completed successfully; which implies that no
error has been set by the failing call in Crea*hMetafile.
Friend Sub Init(ByVal hRefDC As Long, _
ByVal Width As Long, ByVal Height As Long, _
ByVal Filename As String, _
ByVal Application As String, _
ByVal Description As String)
Dim R As RECT, Comment As String
m_Recording = True
m_Extent.cx = Width
m_Extent.cy = Height
m_Origin.Y = Height
SetRect R, 0, 0, Width, Height
If Application <> vbNullString Or Description <> vbNullString Then
Comment = Application & Chr$(0) & Description & Chr$(0) & Chr$(0)
Comment = vbNullString
m_hDC = Crea*hMetaFile(hRefDC, Filename, R, Comment)
If m_hDC = 0 Then
m_Recording = False
m_hMF = 0
If you might be able to track this down, please let me know.
PS: Should I have created a new thread here?
I'm not sure why baseWidget() is returning NULL. It should build the
menu and return the widget if necessary. But you can get what you want
1) Calling VkMenu::useWorkProcs(FALSE); before you create your windows.
This disables the delayed build of menus, so the widget will exist right
away, possibly at the cost (small) of some startup time.
2) Update to 6.2. The latest viewkit already supports what I think you
are doing. (Showing help text as the user moves over widgets).
Incidently, I'd use arm and disarm callbacks to detect the user entering
and leaving an item rather than event handlers. That way, gadgets will