Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an AciveX exe program that is started be another app and is unloaded by that app. Recently in dev I noticed the Activex exe was staying loaded. (not again I thought)... what did I do now?

So I jump around recent code additions to try and get it to unload.
With no luck I commented out the call to EnumDisplayMonitors that I stuck in Formload to gain some info on the display environment.

With EnumDisplayMonitors commented out the program unloads as it should.
With EnumDisplayMonitors in play it won't without killing it in task mgr.

EnumDisplayMonitors ByVal 0&, ByVal 0&, AddressOf MonitorEnumProc, ByVal 0&

WT?
Thanks

:Ron
Posted
Updated 21-Aug-11 9:03am
v2
Comments
[no name] 21-Aug-11 15:24pm    
What does EnumDisplayMonitors do? It would help if you can post it's code.
#realJSOP 21-Aug-11 15:42pm    
It enumerates monitors attached to the system.
Ron Anders 21-Aug-11 15:48pm    
Here is the MonitorEnumProc code. it is tutorial code I found on the net that I am not really using in it's entirety.

I'll take a better look at that code. Thanks for making me think.

Here it is for better or worse.

Public Function MonitorEnumProc(ByVal hMonitor As Long, ByVal hdcMonitor As Long, lprcMonitor As RECT, ByVal dwData As Long) As Long
Dim MI As MONITORINFO, r As RECT
Debug.Print "Moitor handle: " + CStr(hMonitor)
'initialize the MONITORINFO structure
MI.cbSize = Len(MI)
'Get the monitor information of the specified monitor
GetMonitorInfo hMonitor, MI
'write some information on teh debug window
Debug.Print "Monitor Width/Height: " + CStr(MI.rcMonitor.Right - MI.rcMonitor.Left) + "x" + CStr(MI.rcMonitor.Bottom - MI.rcMonitor.Top)
Debug.Print "Primary monitor: " + CStr(CBool(MI.dwFlags = MONITORINFOF_PRIMARY))
'check whether frmConsole is located on this monitor
'' If MonitorFromWindow(frmConsole.hwnd, MONITOR_DEFAULTTONEAREST) = hMonitor Then
'' Debug.Print "frmConsole is located on this monitor"
'' End If
'heck whether the point (0, 0) lies within the bounds of this monitor
If MonitorFromPoint(0, 0, MONITOR_DEFAULTTONEAREST) = hMonitor Then
Debug.Print "The point (0, 0) lies wihthin the range of this monitor..."
End If
'check whether frmConsole is located on this monitor


GetWindowRect BCRScribbleStrip.frmBCRConsole.hWnd, r
If MonitorFromRect(r, MONITOR_DEFAULTTONEAREST) = hMonitor Then
Debug.Print "The rectangle of frmConsole lies within this monitor"
End If
Debug.Print ""
'Continue enumeration
MonitorEnumProc = 1
End Function

1 solution

This might steer you toward an answer:

MSDN - Starting and Ending a Component [^]
 
Share this answer
 
Comments
Ron Anders 21-Aug-11 16:33pm    
Thanks everyone.

Those MSDN Documents a golden. I've never seen them before.
The problem is somewhere in MonitorEnumProc.

I'll find it.

Thank you again. ;-)

:Ron

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900