Strange ActiveX-Exe behaviour

I have an ActiveX exe and I am having a hard time to have it raise an event.

My problem is that the class of the ActiveX-Exe does not receive the 
withevent from the form. Is that a known problem? What am I missing?

When I instantitate the ActiveX-Exe on a form I have the following code:

Option Explicit

Private WithEvents d As DeviceNotifier6.clsDeviceNotifier

Private Sub d_DeviceChanged()

     Stop

End Sub

Private Sub Form_Load()

     Set d = New DeviceNotifier6.clsDeviceNotifier

End Sub



The code of my ActiveX-Exe looks like this

'*** clsDeviceNotifier ****
Option Explicit

Public Event DeviceChanged()

Private WithEvents F As frmMain

Private Sub Class_Initialize()

     Set F = New frmMain
     Load F

End Sub

Private Sub Class_Terminate()

     Unload F

End Sub

Private Sub f_DeviceChanged()

     RaiseEvent DeviceChanged

End Sub

'*** frmMain.frm
Option Explicit

Private WithEvents cDevChange As clsDeviceChange

Public Event DeviceChanged()

Private Sub cDevChange_DevChangeInfo(ByVal Info As String)

	'This sub IS called

     lbDevInfo.AddItem Info

	'But this event is not received by the ActiveX-Exe's class
     RaiseEvent DeviceChanged

End Sub

Private Sub Form_Load()

	'all this works fine
     Set cDevChange = New clsDeviceChange

     Call cDevChange.Hook(Me)

End Sub

Private Sub Form_Unload(Cancel As Integer)

     Call cDevChange.Unhook(Me)

     Set cDevChange = Nothing

End Sub



0
Anders
9/7/2010 11:32:26 AM
vb.general.discussion 1016 articles. 0 followers. Follow

8 Replies
1127 Views

Similar Articles

[PageSpeed] 58

I think you want to change this:

Private Sub f_DeviceChanged()
   RaiseEvent DeviceChanged
End Sub

to this:

Friend Sub f_DeviceChanged()
   RaiseEvent DeviceChanged
End Sub

   Also, this may not be a problem, but it
seems risky and a case of poor design
to me that you've named both events
exactly the same -- in the class as well as
in the form. Since the form is
essentially internal I'd be inclined to name
that event something like FormDeviceChanged.



-- 
--
"Anders Jorgenson" <a.jorg@lycos.com> wrote in message 
news:eQHMMCoTLHA.620@TK2MSFTNGP06.phx.gbl...
|I have an ActiveX exe and I am having a hard time to have it raise an 
event.
|
| My problem is that the class of the ActiveX-Exe does not receive the
| withevent from the form. Is that a known problem? What am I missing?
|
| When I instantitate the ActiveX-Exe on a form I have the following code:
|
| Option Explicit
|
| Private WithEvents d As DeviceNotifier6.clsDeviceNotifier
|
| Private Sub d_DeviceChanged()
|
|     Stop
|
| End Sub
|
| Private Sub Form_Load()
|
|     Set d = New DeviceNotifier6.clsDeviceNotifier
|
| End Sub
|
|
|
| The code of my ActiveX-Exe looks like this
|
| '*** clsDeviceNotifier ****
| Option Explicit
|
| Public Event DeviceChanged()
|
| Private WithEvents F As frmMain
|
| Private Sub Class_Initialize()
|
|     Set F = New frmMain
|     Load F
|
| End Sub
|
| Private Sub Class_Terminate()
|
|     Unload F
|
| End Sub
|
| Private Sub f_DeviceChanged()
|
|     RaiseEvent DeviceChanged
|
| End Sub
|
| '*** frmMain.frm
| Option Explicit
|
| Private WithEvents cDevChange As clsDeviceChange
|
| Public Event DeviceChanged()
|
| Private Sub cDevChange_DevChangeInfo(ByVal Info As String)
|
| 'This sub IS called
|
|     lbDevInfo.AddItem Info
|
| 'But this event is not received by the ActiveX-Exe's class
|     RaiseEvent DeviceChanged
|
| End Sub
|
| Private Sub Form_Load()
|
| 'all this works fine
|     Set cDevChange = New clsDeviceChange
|
|     Call cDevChange.Hook(Me)
|
| End Sub
|
| Private Sub Form_Unload(Cancel As Integer)
|
|     Call cDevChange.Unhook(Me)
|
|     Set cDevChange = Nothing
|
| End Sub
|
|
| 


0
Mayayana
9/7/2010 2:03:27 PM
Mayayana,

I have changed the sub to friend sub. I also renamed the one event.
But it is still not raised.

The sub

Friend Sub f_pDeviceChanged()

     Beep 1000, 500

    RaiseEvent DeviceChanged 'This does not work

End Sub

in the ActiveX-Exe is called, I here it from the Beep, but then the 
event to the "outside world" is not raised or not received by the 
outside world.

Any more ideas?
0
Anders
9/7/2010 5:55:33 PM
| I have changed the sub to friend sub. I also renamed the one event.
| But it is still not raised.
|

 Maybe it has to do with the order. In class
initialize you have:

  Set F = New frmMain
  Load F

You've set the object for events and then
load it. Again, I'm not certain that won't
work, but the way I do it is like this:

Load frmMain
Set F = frmMain

  It's hard to test your code as-is, but I have
done what you want to do and made it work.
But I'm also not clear on what you did. With
your new code sample you seem to be saying
the EXE is not raising the event, but before you
said the EXE was not receiving the form event.


| The sub
|
| Friend Sub f_pDeviceChanged()
|
|     Beep 1000, 500
|
|    RaiseEvent DeviceChanged 'This does not work
|
| End Sub
|
| in the ActiveX-Exe is called, I here it from the Beep, but then the
| event to the "outside world" is not raised or not received by the
| outside world.
|
| Any more ideas? 


0
Mayayana
9/7/2010 11:51:10 PM
Changing to this did not change anything:
>
> Load frmMain
> Set F = frmMain

>    It's hard to test your code as-is, but I have
> done what you want to do and made it work.
> But I'm also not clear on what you did. With
> your new code sample you seem to be saying
> the EXE is not raising the event, but before you
> said the EXE was not receiving the form event.

Yes. I don't know if the ActiveX exe is not raising the event or if it's 
not received by the instantiating app.

I do know that this sub is called:

>
>
> | The sub
> |
> | Friend Sub f_pDeviceChanged()
> |
> |     Beep 1000, 500
> |
> |    RaiseEvent DeviceChanged 'This does not work
> |
> | End Sub

But the RaiseEvent DeviceChanged is either not send (by the ActiveX-exe) 
or not received (by the instantiating application).

Any more ideas? How could I check if it's a) not being sent or b) not 
being received?



0
Anders
9/8/2010 6:30:07 AM
Private Sub cDevChange_DevChangeInfo(ByVal Info As String)

     'This sub IS called

     lbDevInfo.AddItem Info

     'But this event is not received by the ActiveX-Exe's class
     RaiseEvent DeviceChanged

End Sub

For some reason, this did not work.
But when I do this....


Private Sub cDevChange_DevChangeInfo(ByVal Info As String)

     'This sub IS called

     lbDevInfo.AddItem Info

     'But this event is not received by the ActiveX-Exe's class
     'RaiseEvent DeviceChanged

	Me.Timer1.Interval = 50
	Me.Timer1.Enabled = True

End Sub
Private sub Timer1_Timer()

	Me.Timer1.Enabled = False
	RaiseEvent DeviceChanged

End Sub

, it will work.

Why????? Why is the RaiseEvent in the cDevChange_DevChangeInfo ignored?

0
Anders
9/8/2010 7:15:07 AM
| Why????? Why is the RaiseEvent in the cDevChange_DevChangeInfo ignored?
|

   I thought that maybe someone else would have
an idea about this, but I guess not. If you
don't get it then you might want to post a sample
project that shows the problem.
   You seem to have an event coming from
a custom control, that's picked up by a form, that
then fires an event that's picked up by a class.
It's hard for anyone else to test that scenario. 


0
Mayayana
9/9/2010 1:54:06 PM
Should I post a project? Would anybody download and test it?

> | Why????? Why is the RaiseEvent in the cDevChange_DevChangeInfo ignored?
> |
>
>     I thought that maybe someone else would have
> an idea about this, but I guess not. If you
> don't get it then you might want to post a sample
> project that shows the problem.
>     You seem to have an event coming from
> a custom control, that's picked up by a form, that
> then fires an event that's picked up by a class.
> It's hard for anyone else to test that scenario.
>
>

0
Anders
9/10/2010 5:24:26 AM
| Should I post a project? Would anybody download and test it?
|

  If you do post it you should put it on a website
in a zip. And it shouldn't be a "code dump" of
what you're working on, but rather the simplest
possible demo that shows the problem in a
repeatable way. I'd look at it if I'm not too busy and
it's not too complex. I find ActiveX controls interesting.


0
Mayayana
9/10/2010 12:51:35 PM
Reply:

Similar Artilces:

A question about Cygwin's link tool
Could Cygwin's link tool(ld.exe) build a project to a DLL file and its LIB file? ...

"Pdftohtml.exe" "verclsid.exe" no disc error
Everytime i run anything or do anything at all, even nothing at times a windows error pops up and goes "There is no disc in the drive. Please insert disc into drive k:". The error title is Pdftohtml.exe then another one follows up after it names Verclsid.exe. Its a freshly reformatted computer SP3 xp. There are processes for these applications which are 212K/216K respectively. Any help would be appreciated Ren wrote: > Every time I run anything or do anything at all, even nothing at times a > Windows error pops up and states "There is no disc in the dri...

Question about win32 exe format.
Is there a method or class/construct in MFC which can give me information about an Win32 exe file? I've done *some* reading and have learned *some* stuff, like determining if a file IS a Win32 exe, but I was wondering about all the other stuff that you get when you right click on an exe and select 'properties' such as 'Description', 'Copyright', 'Comments' etc. If nothing in MFC, can someone provide a link/article/resource where I might learn such info? Paul The values you are referring to have nothing to do with knowing how to read the executable. Y...

> behaviour.
After clearing up the text formatting quirk (so far...), perhaps someone can explain a further one: I am noticing in some of my replies (not necessarily happened in this group...), that sometimes '>' marks fail to be added to the last entry above mine. Any ideas why? Cheers, S If you reply to someone that was posting in Quoted Printable, OE does not insert the indent marks, (>). You will often see this with posters using Google Groups as well. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "spamlet" <spam...

uninstall dpm server, but ntbackup.exe stops detecting tape device
I uninstall dpm server (no protected server) successfullu. However when i run ntbackup, it cannot detect the TAPE device anymore. How shld i approach the problem ? Update the drivers, and possibly firmware. I had a problem where DPM suddendly sent my tape offline. I flashed the firmware to the latest version and updated the drivers, it fixed it. Don't know whether it was a driver of firmware problem, maybe it just reset the drive! "IT STAFF" wrote: > I uninstall dpm server (no protected server) successfullu. > > However when i run ntbackup,...

Strange connectivity issue
Windows XP SP3, Dell laptop. Cannot ping the default gateway, which is our router. Can ping any other computers on the subnet, either by hostname or IP. Other computers on the subnet can ping this laptop, either by IP or hostname. Cannot ping the laptop from the router. The laptop has built-in wireless. If I enable that, I can ping the router's IP address. I tried resetting TCPIP with this command: Netsh int ip reset Didn't help. Windows firewall is disabled. The computer does not appear to have any viruses. Nothing in Event Viewer. I'm stumped. Any ...

Automating MS Word in an ActiveX Control
Hello, I'm developing an ActiveX control that automates MS Word. My control is based on 2 samples from MSDN, the first one employs doc/view model as described in the following article: http://www.microsoft.com/mind/0497/mfc.asp the second one explains how to automate MS Word in a MFC SDI application. The function that automates Word in the second sample looks as follows: /******************************************************************** * This method encapsulates the process of embedding an Word * document in a View object and automating that document to add * some text. *****...

Store.exe 100(ish)%
Recently my exchange 5.5 box ran out of space and in the process of freeing up my Support Technician moved log files (drag and dropped1). This caused the priv.edb and pub.edb to become corrupt. (he has now moved on!). I 1st checked that the databases were corrupt. We then ran eseutil /r to soft repair which worked on the pub.edb but not the priv.edb. We then ran eseutil /P on the priv.edb, which found inconsistencies. The information store is now up and running though my store.exe process is running at or near 100%. I have service packed the box with 5.5 SP4 but this does not seem solved the ...

outlook.exe #3
OUTLOOK.EXE runs in the task manager/processes for every time I launch outlook on our home pc. when I try to shut down, it pops up "outlook.exe not responding" and I have to manually "end task" for each time it is running. Any ideas how to rid this demon? ...

Strange problem with my resources.
Hi, I have created a project with various configurations. The output is the same executable exept for the name, version resource and some minor code variations that depend on a preprocessor defenition. I have about 8 different configurations like this. When I run 1 application, all works well. When I run a few applications simultaneously, some context-menu's can suddenly not be loaded from the resource. GetLastError equals 0. I have linked statically with MFC 8. I am completely in the dark here... can somebody help? Regards, Peter. "Peter Hendrix" <PeterHendrix@discuss...

Strange Outlook Issue
Exchange 2000 and Outlook 2000. Two users open Outlook and it appears they have no new mail. If they hit the Send/Receive button, still no new mail. They then open an existing message in their inbox and new mail starts arriving in their inbox. Any ideas? Strange Outlook issue <StrangeOutlookissue@discussions.microsoft.com> wrote: >Exchange 2000 and Outlook 2000. > >Two users open Outlook and it appears they have no new mail. If they hit >the Send/Receive button, still no new mail. They then open an existing >message in their inbox and new mail starts arriving i...

CRMWorkFlowService.exe (CRM 3.0)
Hi all, I've noticed that CRMWorkFlowService.exe never closes it's DB connections, so after a few weeks, I can have up to 1909 db connections to the SQL server (easily seen both on the DB server and with TCPView from Syinternals). If I restart IIS and all the CRM services (including CRMWorkFlowService.exe), then the CRMWorkFlowService.Exe no longer connects to the DB, which results in forms such as ACCOUNT to take several minutes to load... A reboot of both the IIS and the SQL server seems to be the only solution, but that is not really a good solution (and from my IT manager&...

w3wp.exe CPU utilization
After starting wokflows on my CRM 4 system, the w3wp.exe blocks the CPU. The system is a Windows 2003 SP2. Is there a hotfix I shoud know? thx When you first call a .Net web application. The application is compiled by the framework, this is what is causing the high CPU usage. Depending on resources this should take a few minutes at most. If this takes a lot more time and/or also happens on subsequent requests there may be something else. -- Patrick Verbeeten (MCPD) Lead Developer Aviva IT Extended Entity and Plug-in browser: http://www.patrickverbeeten.com/maps/CrmTool.aspx &quo...

Dellinks.exe wizard
hi, I have downloaded this wizard (to delete links in excel) and cannot get it to work!! I try to open it, it asks where I want the files, I specify the add-ins folder in Program files, then I go to excel -> tools -> add ins, browse to find my file, and it says it's not a valid add in. How do I use this wizard? It's exacltly what I need but I can't seem to get it to work! thank you. I don't know what dellinks.exe is. But I really like: Bonnie McCracken wrote: > > hi, > I have downloaded this wizard (to delete links in excel) > and cannot get it to w...

strange characters in OWA
hello, we upgraded from exch2000 to exch2003 sp1 on Server 2003. When some people are sending emails from OWA, there is a '?' (question mark symbol) that is inserted at the beginning of the message body as well as strange characters that are inserted in place of an apostrophe character. Anybody see this and know what might be the cause ? thanks Did you ever get a resolution for this issue? I have had the mysterious ? inserted into every mail sent from OWA since the day I launched Small Business server 2003. I have not seen any other strange characters though. Sounds like...

strange behavior #2
I have formatted cells to have borders and they do show in print preview but they are not printed ?? I resovled this by adjusting the row height of the first few rows can anyone explain this phenomenon AFD Depending from your printer and / or printer driver, thin lines may not be printed. Daniel "afdmello" <afdmello@hotmail.com> a �crit dans le message de news: OfPc8dFEJHA.5732@TK2MSFTNGP04.phx.gbl... >I have formatted cells to have borders and they do show in print preview >but they are not printed ?? > > I resovled this by adjusting the row height of th...

Strange error message
Hello, I am getting a strange message when I am trying to copy a graph that I use in a payroll document that we use. It contains data and a graph for each employee. It worked just fine for 80% of the document then all of a sudden I started to get this message: "No more new fonts may be applied in this workbook" with an OK button. I can hit the OK button and it will eventually continue on (after multiple clicks). But each time I copy and paste the graph, it gives me this message. I am using Excel 2002 on Win 2000 Pro with all the latest updates and patches available. T...

Outlook.exe generating errors
Can anyone help me. Whilst in email, if I click on the Outlook Shortcuts button and then click on My Documents and attempt to open a document within My Documents, I get the error message "Outlook.exe has generated erros and will be shutdown". Originally this used to come up with a Dr Watson log file error which I have managed to clear, but this other one has flumoxed me. Many thanks Ann ...

strange recurring problem
When I save a file in Excel or for that matter Word, I am unable to open the file(s). I get a prompt saying that 'my virus scanner has detected a problem with the file'. I don't know of any virus scanner and I just saved the file a few minutes ago! Please help!! Steven You can have a virus scanner without knowing about it. So, open My Computer, Control Panel, Add/Remove Programs and check if something like Anti-Virus Software is installed. If yes and you do not need it, just uninstall it. Next, if the problem is not solved, click Start, and check what is in the Start-up section....

EXE running from network share larger than EXE itself?
I have a statically linked MFC EXE compiled with VS.NET 7.1 (2003). The EXE is 1.7MB. Hooking up a network bandwidth monitor I noticed that if I run the EXE from a UNC path (ie. Start | Run | \\servername\share\blah.exe), the 1.7MB EXE causes 5.3MB of network traffic to occur between my workstation and \\servername. The WMI is statically linked, like I said, although it does #import the WMI libs and also some network libs (ADSI, Directory Services Object Picker, etc.), but these libs will be used on the local machine, not the remote. In other words, if I run my EXE from \\servername...

opening an exe file from within Access
Is it possible to open up an external program from access VBA? When I click cmdCalc, I'd like the Windows calculator (calc.exe) to open in its own window. Thanks for any clues. ------------ Victoria Take a look at the Shell function. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Victoria" <Victoria@discussions.microsoft.com> wrote in message news:3F929196-BE3A-41F3-89E3-8471413F60DC@microsoft.com... > Is it possible to open up an external program from access VBA? When I > click > cmdCalc, I'd like the Wi...

ldp.exe in Exch 5.5 ResKit??
OK, here is the deal. I run an Exchange 5.5 server on Windows NT in an NT4 domain. I have a mailbox that I created from the command line incorrectly. When I created the account I accedentally inserted an invalid character in the display name (and possibly elsewhere in the account, the character was the [`] character...not sure what it is called). Everytime I double click on the account to attempt to modify it (or delete it) I get an error (The object cannot be found in the directory. This may be because replication has not completed. c1010aae) and I cannot get rid of the account. I want t...

winword.exe process remains after word is closed (error on turn of
I am using Word 2007 on XP and when I exit from Word the winword.exe process remains open. I don't have any other office application open. The winword.exe process does not use any CPU but is about 50000k. When I attempt to turn off the computer I am told that the winWord application has not terminated. How can I fix this error? Any assistance VERY GRATEFULLY received. Peter Evans This is a multi-part message in MIME format. ------=_NextPart_000_0091_01CB049D.F1E340D0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ...

Outlook.exe #6
When I start Microsoft Outlook I receive the following message: ********************************************************** Outlook Today - Microsoft Outlook: Outlook.Exe Entry point not found. The procedure entry point GETIUMS could not be located in the dynamic link library MSDART.DLL ********************************************************** I have attempted to uninstall and reload Outlook from my original installation disk. I don't know what to do at this point. Please help. Go to Windows Update and install MDAC 2.8. --� Milly Staples [MVP - Outlook] Post all replies to th...

money plus-dlx-us-qfe1.exe
Error message Money Plus-Dlx-US-Qfe1.exe is not a valid win32 application I purchased this today from Microsoft, and took the 3 hour download. I was disappointed that it would not install. No where in the MS descriptions does it say that it cannot run on Vista Home Premium. Do I have to try to get a refund from Microsoft, or is there a workaround?? I explored that error message on google, but got nothing useful. Thanks Honeydew "honeydew" <honeydew@mfi.net> wrote: >Error message >Money Plus-Dlx-US-Qfe1.exe is not a valid win32 application > >I purchased t...