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
1204 Views

Similar Articles

[PageSpeed] 22

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:

Faulting application dynamics.exe
I am not sure what is going on but there are times when this error occurs for users in GP 7.5... "Faulting application dynamics.exe, version 7.5.0.3, faulting module mfc42.dll, version 6.0.8665.0, fault address 0x000048ab." After getting this error, GP shuts down. I have been trying to pinpoint when it does not happen in a consistent spot. It also does not happen to all users. I also can not get this error to occur on the development machine. I have researched the heck out of this on the web but have found no resolution. The only thing that I can see different is the deve...

Strange "Last Logged On By" in my System Manager
I've been having some really big problems with my Exchange 2003 server and am gearing up to do a rebuild this weekend. When I was looking at the user mailboxes there is a colum for "Last Logged on By" and most of them indicate the same user. Is it possible there is a virus or spyware issue I am not aware of? Or is this a normal thing with Exchange 2003? It's possible it's your AV scanning the mailboxes and shows up as last logged on. "kfehrenbach" <kfehrenbach@discussions.microsoft.com> wrote in message news:9C5EC790-C45D-42ED-BD7E-8214888407EA...

Slow running of Excel macros embedded in an ActiveX
Can anyone point me in the direction of a handy resource/webpage that can help me with my problem? I have developed a reporting system based within Wonderware's InTouch SCADA package. On one of my screens I have a an iexplore ActiveX object which I use to open some Excel spreadsheets (different ones for different reports.) Wonderware allows me to send macro commands to the embedded spreadsheet via DDE. For instance I have a button which runs a macro to print the active worksheet which consists simply of the one-liner: ActiveSheet.PrintOut This works, however the command takes over...

Inconsistent Form_Open behaviour
I'm all out of ideas on this so I'm hoping someone might have a suggestion of where to look next or what to try. It's a simple concept but long-winded to describe. I have an Access (2003) database. Of interest are 2 forms. The first, frmChooseChild, loads at start-up and is used to call the second form with a chosen record displayed. It is a continuous form and begins by showing all records. RecordSource=Child (linked table 618 records). DataEntry=No, OnLoad runs routines which filters the RecordSet progressively as the user types. I am using t...

Outlook.exe will not terminate
Hello, I am using Outlook 2003 on Win XP connected to Exchange 2003, when I boot up and run Outlook everything works fine, If I close Outlook and re-open it Outlook will not re-open. The process is still running though, not sure why - any ideas. Regards, Brent Do you have a PDA (ActiveSync) or WinFax Pro? (you have a 3rd party application that uses, monitors, or syncs with outlook data and it doesn't realize that outlook shutdown. it holds a reference and interferes with the next startup request.) "Brent" <anonymous@discussions.microsoft.com> wrote in message news:2...

end program
Everytime I turn off the computer (as long as I have opened outlook at some point and time)I get a screen that says end program-outlook.exe and it acts like it has to shut down or close the program before it can shut down the computer. ...

svchost.exe
Hi, I reformated my pc last week and after installing Symantec antyvirus and windows defender task manager sometimes it shows CPU usage of over 95% even when wasn't running anything. I uninstalled both programs and it seem to have fixed the problem. But now there is a svchost.exe - application error. Instruction at 0x00b42740 referenced memory at 0x00b42740. the momory could not be written. OK to terminate or CANCEL to debug the program. I'm running Window XP Media Center Edition Version 2002 SP3 I don't know if these two issues are related or not. Can anyone ...

Loading resources from the dll and exe
I am working on a VC++ project.I have pulled out resources from the main application and placed into a resource only dll,I am loading the dll into the main application now...it works fine But i now need to put back some of the resources into main application.thts where the problem starts.it creates a sort of collision Does anyone have a solution to that? Resource IDs must be unique. How are you copying these resources? Is it an Extension DLL? -- Ajay Kalra [VC++ MVP] ajaykalra@yahoo.com "j456" <jim456@rediffmail.com> wrote in message news:1131732685.043371.153810@g49g20...

Strange Forwarding problem!
Hello everyone The problem I have looks bit odd to me and can't find out what's wrong. We have 25cal, SBS2003 SP1/ Exchange SP1 and everything looks good. Now, I'm forwarding messages to Black Berries for some clients. 2 of them cannot get anything. When I type my personal email address into their Contact, I can get it. When I try with that guy's BB email, he cannot get anything. If I send the same message directly to his BB, it works. Other BB users are ok. Only these two poor guys are left behind. Please advise. Thank you. Artur Posted Via Usenet.com Premium Usenet...

strange email issue
we have an outside user, the mail is set up to use their ISPs smtp server and uses our pop3 to get heh mail from our mail server, they can receive mail fine from wihthin our domain, but when they reply the mail goes missing, the mail account otherwise sends mail to other servers without an issue, any reasons for this behaviour?, we recently applied all uptodate service packs, and we use ISA server I think this could be a client configuration. When they receive internal email what is the address they are replying to? If it is not an SMTP address they might be attempting to reply via the...

Strange Behavior with Stock Award in 2005
I have an investment account with stock options and stock awards. I have awards for 2003, 2004 and a one off award. The 2003 award has disappeared from my portfolio view, and from the summary view, in the investment account. It looks just fine in the transaction view. 2004 and the one off are also fine. When I change settings to show the value of vested and unvested shares it reappears. Does anyone know what might be going on? ...

Block .exe files
Hey there; I am trying to screen and block attachments with the following extentsions .exe .vbs .scr and .vb Is there any way to do this and if there is how do you do it. Nothing native will do this; there's attachment blocking in Outlook, but you shouldn't wait till mail gets to the client to handle this. The best way to deal with it would be to get Exchange antivirus software, which you should be running anyway...it can do this and more. Favorites are Trend ScanMail or Sybari Antigen... For a list of attachment types to block, see http://www.swinc.com/resource/exch_faq_appxj.h...

Strange communicaiton problem between E2K3 BE & FE servers
Hi there, Exch2003SP1 with BE & FE config, both running on w2k3 (no sp) servers. All in a sudden, around 11am this morning, outgoing internet emails pending at BE's "Internet Mail - _6f11108f04be1b4fa16208b3824b69aa_S (SMTP Connector)" queue, in which when force it to retry, at additional queue information, it said "the remote server did not respond to a connection attempt". However there is no problem of incoming internet emails at the moment. Already restarted both SMTP virtual server at FE & BE, didn't help on the outgoing mails problem. On both B...

ActiveX and trusted sites
I have a funny situation. I have an MFC activeX which is basically a CDialog I have embedded this into my web page.. When the Site is "Trusted" the activeX loads and COleControl::Oncreate is called When the Site is not Trusted I get the red X and COleControl::OnCreate is not called. The Constructor is called in both cases. There are no warnings or Pop-ups from IE. What the heck??? ...

Date Time Picker - Newbie
Hi All, In a Dialog Based project I am using the following code to get a day , month & year values from the DATETIMEPICKER in VC 6. The Control variable name is m_ctrlGetdate and was added through the Wizard. COleDateTime Date; m_ctrlGetdate.GetTime(Date); int PickDay =Date.ctrlGetdate(); int PickMonth = Date.ctrlGetdate(); int PickYear = Date.ctrlGetdate(); CString PickDate; PickDate.Format(" %d / %d / %d",PickDay ,PickMonth ,PickYear ); AfxMessageBox(PickDate); This works perfectly on my Main Dialog (and any other project I have use...

fullscreen flash activex control
hello- i'm trying to author a MFC application that has, as its main window, a full screen shockwave/flash activex control with no title bar, borders, etc. what i've done so far is to create a new MFC application that has a single document (using the document/view architecture) in the "new project" wizard, and add the activex control to the main dialog. displaying the window as fullscreen is not the hard part -- i did that by defining BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( cs.hMenu != NULL ) { ::DestroyMenu( cs.hMenu ); cs.hMenu = NULL; ...

launching a program (.exe)
Can I launch a program (.exe) from inside an excel macro? Excel 97. You can use the Shell function. You might fare better with a question like this in microsoft.public.excel.programming. -- Regards from Virginia Beach, Earl Kiosterud www.smokeylake.com Note: Top-posting has been the norm here. Some folks prefer bottom-posting. But if you bottom-post to a reply that's already top-posted, the thread gets messy. When in Rome... ----------------------------------------------------------------------- <a924fan@yahoo.com> wrote in message news:1190592704.188221.1...

Can't change the icon on an .exe file
I'd like to change the icon on a .exe file on my desktop, but there is no "Change Icon" button when I go into the Properties of the icon for this type of file. How do I change the icon on a .exe file? Hello Stu, You will need to create a shorcut from the EXE file first, then you should be able to change the icon of the shortcut instead. Hope this helps, Shawn Stu;1236547 Wrote: > I'd like to change the icon on a .exe file on my desktop, but there is > no > "Change Icon" button when I go into the Properties of the icon for this > t...

how can i get the .exe attached file ??
Hi even i modify all the security issues became "low", the outlook 2002 still deny me to download the .exe attached file automatically. how can a disable such security feature?? thank you Sam (Hong Kong) Better is to have scripts and executables send to you in a compressed file format like zip. Anyway, you must edit a registry key for that; http://www.howto-outlook.com/faq/blockedattachments.htm -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Creating Signatures -Create an Office XP CD slipstreamed with Service Pack 3 ----- "sam" <...

"wscript.exe
Win XP SP3. After I eject a CD/DVD from my DVD drive or unmount an disk image from the Daemon Tools virtual drive, I get an error window with the title "wscript.exe - No Disk" and with the message " There is no disk in the drive. Please insert a disk into drive (drive letter):". There are three buttons that I can click: Cancel, Try again, Continue. When I click any of these options, the error window closes but pops up again after an interval of approx. i minute. The only way I can close this window permanently is by rebooting the system. Can anybody h...

Very Strange Problem (Urgent)
On the Line date1 = COleDateTime::GetCurrentTime(); If i use F11 to step into the function GetCurrentTime the control goes to BOOL CHtmlView::GetTheaterMode() const and exception is there for me Can Someone Suggest Why UINT ThreadProc(LPVOID arg) { ::AfxOleInit(); COledateTimeThreadDlg *pDlg; pDlg = (COledateTimeThreadDlg *)arg; for(;;) { COleDateTimeSpan datespan; COleDateTime date1,date2; date1 = COleDateTime::GetCurrentTime(); ::Sleep(100); date2 = COleDateTime::GetCurrentTime(); datespan = date2-date1; } } void COledateTimeThreadDlg::OnButton1() { ::AfxBeginThread(Th...

strange problem with ON_UPDATE_COMMAND_UI handler
Hi all.. I programmed an application that has a dialog containing a tree ctrl. On that tree ctrl I'm showing a popup menu when user right clicks on it. The problem I'm having is concerning enabling and graying of popup menu items. I have this in BEGIN_MESSAGE_MAP: ON_COMMAND(IDM_NUEVO_PRODUCTO_CONSOLA, OnNuevoProductoConsola) ON_UPDATE_COMMAND_UI(IDM_NUEVO_PRODUCTO_CONSOLA, OnUpdateNuevoProductoConsola) The first strange thing is that OnUpdateNuevoProductoConsola handler is being called when I click on the item, and not when the item is shown Another strange thing, is that if I g...

cidaemon.exe - indexing for over 2 weeks
A PC of mine running XP SP3 (all updates etc) has been running slow - a couple of weeks ago I identified cidaemon.exe apparently using 99% CPU most of the time. The PC is too slow to use effectively (eg a new explorer tab takes about 20secs to open) I understand that this is part of the indexing process but as it's been going on for over 2 weeks now, surely something is amiss....? I have rebooted a few times - run 'one-care' - it has firewall and AVG Many thanks in advance Pete Have you run disk cleanup? Have you defragged? Is indexing off? "Billericay Pete...

Many processes of iexplore.exe in task manager
I have IE 8 with XP pro sp3. I had to close my pc because threre was 20 active processes of iexplore.exe in task manager. I just turned on my pc and and open Outlook Express. Without opening any web pages or other application I have 4 instances of iexplore.exe. What's seem to be the problem and how do I solve this. That is the first time I see that. Daniel Sounds like your computer is infected with malware. --- Leonard Grey Errare humanum est Learner wrote: > I have IE 8 with XP pro sp3. I had to close my pc because threre was 20 > active processes of iexp...

COM / ActiveX in dll
Hi, i need to implement a COM interface or an ActiveX Control (both have the same features) in a DLL. Implementing a COM interface seems more complicated than an ActiveX control. I already added the COM interface and the ActiveX control respectively to the project and got the cpp file and/or the header, but i have no idea what to do next. How can i use the COM interface or the ActiveX control. Do i need a window for the ActiveX control? ...