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

Similar Articles

[PageSpeed] 5

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:

MFC .exe gets access violation exception in release version but not debug
Hello, thanks for trying to help. I have an MFC .exe that gets an access violation (C0000005) exception in the release version but not the debug version. So I don't know what line of code causes it. But why should they act differently in this way at all? The exception occurs when a tab on a property sheet is being clicked. The only output in the debug screen when the tab is being clicked is "Warning: skipping non-radio button in group." Would that cause it? Does tab order determine groups along with the tab stop property? What are reasons why MFC code would get an access ...

Strange Output
Hello, everybody !!! Why this fragment of code shows : ac cout<<"a\??/??/bc"; Thanks All !!! "Alex Dmitriev" <firejump@mail.ru> wrote in message news:ecTgPp8pEHA.3800@TK2MSFTNGP14.phx.gbl... > Hello, everybody !!! > Why this fragment of code shows : ac > > cout<<"a\??/??/bc"; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/elconTrigraphs.asp '??/' is a '\' so you end up with "a\\\bc" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/elc...

Excel Object showing strange behavior
Hello, I have a sheet that I created that contains an Excel object (small spreadsheet) that when double clicked, will open up and allow it to be populated. After they populate it, and close it,...the data is automatically reflected in the object on the original sheet. This is shared with everyone and it's working great. BUT.....(always the but) Why have a few people sent the form back to me saying that when they double click the object it opens up a "Format Object" dialogue box rather than the editable sheet that it was supposed to do? They sent it back to me and sure enough...

store.exe takes 100 % cpu exchange 5.0 with sp 4
yesterday my exchange server store.exe started to use 100 % cpu and its stays constant. is there any fix's out there. i have scan for viruses but i none. anyone out there who can help my..?? "kenneth" <kenneth@discussions.microsoft.com> wrote: >yesterday my exchange server store.exe started to use 100 % cpu and its stays constant. is there any fix's out there. i have scan for viruses but i none. >anyone out there who can help my..?? Just stop your virus scanning services and see if it calms down.. Mark Arnold MCSA MCSE+M MVP, FAQ: http://www.swinc.com/resou...

Exchange Permissions--Strange One
Hi by default, domain admins (and ent. admins) are denied "receive as" and "send as" permissions to the mailbox store. additionally, by default, on the exchange advanced tab under the mailbox rights button, domain admins are DENIED Full Mailbox Access. However, if you look at the security tab for each user object, by default domain admins are allowed "send as" and "receive as" permissions. now i know that the "receive as" right is ignored on the ad user object, but i ran a small test. i logged on as a domain admin, opened up the domain admin...

25 To Life.exe (7/7)
=ybegin part=7 line=128 size=1593880 name=25 To Life.exe =ypart begin=1497601 end=1593880 �C[=@a=}�/��`�5Ҵ�b��,�'���r�?������/��3NV���q���w�3x��`A���7,$D2=J_SOfu�4p�"��Z&N�褜#-n���̷�@��r�/��5�QҬу��� I͠)?{7@�%��[�ym�z��^�~�:���ڑYdkŝ��� Dx���@3��8�p+�"y��$E�ޓeْ2�b<=}STTY]�=@T9W�6����P�%��C��^o�x+1��c�5[O|N�I�KD xb��1Œ�bz$Ӭk�#⺶H���C:��h��,E�?�\?���~��0볈�j�+���T���ay�$���Y%��-��5���<=}�i+�?O�7�#�m�%V�d��9Bc>Qv_;=}�V��w� ��&�S�F6����3���/;^�n�x��=J���>�$��H���WK�\�-�v�+:dyw�=J��A���n���J-����J�haak�]w���e��Z�f~��O�7r...

Strange Email failure error
Can anyone help? Using Outlook 2002 and POP3 mail. I've always been able to send emails to my wife's work email address until this week, when I get this very strange failure notice. "Connected to 213.2.49.230 but greeting failed. Remote host said: 421 reppsrv01.repp.co.uk is not accepting new connections. Please try later I'm not going to try again; this message has been in the queue too long." Does anyone know what the hell this means? thanks -- Google is your Friend Email address deliberately false to avoid spam: gordonATgbpcomputingDOTcoDOTuk www.gbpcomputin...

Using Windows Media Player activex control in an MS Access form
I have added a Windows Media Player activex control in an MS Access form and I want to play a video file when I click on an command button. The file to be played is that of the content of a field on that form. For example, if field A contains the text c:\test video1.iso and I click the command button, then play video c:\test video1.iso. If this value changes to another vodeo file name, then play that file. I can't find how to set the URL of the windows media activex control to read a field on a form. Is there a way to do this? Thanks in advance. ...

How to register activex in access 2007?
I have file access project 2003 version. When I try to use access 2007 to continue my designing form, the control name Date and Time picker didnot work. And I donot know how to register activeX control. ...

Very Strange
Hi I have a Word 2007 document. In this I am using 3 different heading styles. I want to use the feature 'Select Text with Similar Formatting' but it is not working. I have 5 headings that are all Title Case, size 10, Times New Roman, Left aligned and Bold there is exactly the same formatting applied to all 5 headings - I even checked the paragraph spacing - all headings are 0pt before and 12pt after. I checked show and hide - everything I repeat everything is the same - can you tell me why oh why will this feature only select 3 of my headings and not the 5???? ...

why this strange result with vlookup
hi i have this formula in a cell =VLOOKUP(A3,'LookUp Data'!A2:O740,2,FALSE) but any time i pick a code from my list items in column A it gives #NA but as soon as i change to a different code it gives the name. any help why My best guess would be a data type mismatch. Looking up text in a column of numbers. When you change the value the type gets converted and the result is returned. Hard to say though based on yoru description. The ohter thig to look for might be blank characters padded at the end of the input. -- HTH... Jim Thomlinson "Amin" wrot...

DestroyWindow ASSERT problem....strange, strange!
Hi I have derived a dialog-class in a DLL (shared MFC) I can construct an object of this class in my app, and when overloading DoModal() and adding an AFX_MANAGE_STATE(AfxGetStaticModuleState( )); call, I can see the CMyDialog dialog. But here is the issue, I have a timer set for a certain time, it posts a message and the dialog has to be killed - so I use CDialog::OnCancel. Then DoModal calls DestroyWindow() - Here a copy of the m_hWnd is made in hWndOrig. #ifdef _DEBUG hWndOrig = m_hWnd; #endif Then m_hWnd gets set to Null by ::DestroyWndow (which calls OnNcDestroy). But later in Dest...

18 Year Old Virgin 2009.exe (7/7)
=ybegin part=7 line=128 size=1593867 name=18 Year Old Virgin 2009.exe =ypart begin=1497601 end=1593867 �C[=@a=}�/��`�5Ҵ�b��,�'���r�?������/��3NV���q���w�3x��`A���7,$D2=J_SOfu�4p�"��Z&N�褜#-n���̷�@��r�/��5�QҬу��� I͠)?{7@�%��[�ym�z��^�~�:���ڑYdkŝ��� Dx���@3��8�p+�"y��$E�ޓeْ2�b<=}STTY]�=@T9W�6����P�%��C��^o�x+1��c�5[O|N�I�KD xb��1Œ�bz$Ӭk�#⺶H���C:��h��,E�?�\?���~��0볈�j�+���T���ay�$���Y%��-��5���<=}�i+�?O�7�#�m�%V�d��9Bc>Qv_;=}�V��w� ��&�S�F6����3���/;^�n�x��=J���>�$��H���WK�\�-�v�+:dyw�=J��A���n���J-����J�haak�]w���e...

Strange behavior #3
Hello. I use Outlook 2003 with a internal pop/smtp server (Merak). Using Oulook 2003 (it's the case for all users in the company), when we send mails to internal addresses, in the recipient mailbox our address doesn't appear, we are considered as ghost users! But, if on the same PC we use another email client (Outlook express for example), the mail arrives with my address as sender! Does anyone feel a ghostbuster? Thanks by advance. ...

I want to uninstall Office 97 but the setup.exe will not launch
I want to uninstall Office 97 but the setup.exe will not launch. My OS is Windows 98 SE. When I put the Office 97 CD in the drive, it will not launch. I tried running it manually by going to Run>drive:/setup but then my PC hangs and I have to crash it. I have checked the CD and it works fine on my other PC and I have also made sure it is not the DVD drive. Anyhelp on this one? Is there a way I can remove Office97 without going through setup or how would I fix this THanks Laurie Am I the only person who's never heard of doing an uninstall with setup? Setup, to me, is to install ...

CRM 4.0 Downloadreports.exe?
I have read a few blogs that discuss this tool in regards to CRM 3.0, however there does not seem to be a CRM 4.0 equilvalent. I want to pull down all reports from CRM into their respective rdl files and copy them to another location. Does anyone have a method of doing this in CRM 4.0? Thanks in advance. On Jun 15, 1:45=A0pm, jimtait <jimtai...@gmail.com> wrote: > I have read a few blogs that discuss this tool in regards to CRM 3.0, > however there does not seem to be a CRM 4.0 equilvalent. > I want to pull down all reports from CRM into their respective rdl > files and cop...

How to copy a dialog resource from an EXE to a DLL
Does anyone know how to do this? I tried using the sample code in MSDN, condensed below. Using the IDE I looked at "result" and it was true. All the preceding variables appeared to have valid handles. But when I check the second instance of "DlgStep1Resource", it is NULL. Can anyone help me. Thank you very much. void CImportController::SetResource(UINT DlgResourceID) { HGLOBAL DlgStep1ResourceHandle; HMODULE ParentModule; HRSRC DlgStep1Resource; HANDLE hdlUpdateResource; LPVOID pTemplate; ParentModule = ::LoadLibrary("ImportPrototype.exe"); ...

strange Icon
I'm running Office 2007, and always back up my files to a flash drive which I can then open in my laptop. The "Icons" always look normal until today When I backed up an Excel file. The new Icon on the flash drive has a big exclamation mark (!) in the center of it!! I have reviewed the file and can't find anything wrong with it -- have been doing this for years and have never seen this before. Will someone please tell me what this means!! The icon in my "documents and settings", where the file was saved originally is normal. big john This is a cross post wi...

Dynamics.EXE process hangs in 8.0
Occassionally one of our IM jobs fails and we end up with multiple copies of Dynamics.exe running in Windows Task manager on the server (IM runs on the server box). We use standard macros to log in. In 6.0 when this happened we could delete the IM log in if necessary from the Activity window and go to the Windows Task Manager and kill the Dynamics.exe process. This doesn't work in 8.0 with Windows 2003 server. If Dynamics.exe hangs, it requires a reboot. Is there a workaround or some programmatic way of killing this process? ...

strange
hi, why if I load Dialog from satelite DLL it display with white background? When from local resources its ok. thanks ...

xsd.exe and XmlType?
I have a relatively simple xsd which I am turning into a class using "xsd.exe". I then create a collection of these classes. I have run into one minor problem. When serializing my collection, I would like the names of the elements to be different from the class name as generated by xsd.exe. I don't want to change the class name itself, due to naming conventions. This is trivial to do after-the-fact by adding the "XmlType" tag to the signature of the class. However, when I regenerate from the xsd, the tag disappears. Is there some way of putting the "XmlType&...

Strange problems
All, A standalone Exchange 2003 SP2 server acted up the other day and needed to be restated. After the first reboot it only stayed stable for about 10 minutes. After the second, it's been running but generating the errors listed below. I ran the "Performance Troubleshooting Analyzer" and "Troubleshooting Assistant" tools from Microsoft's websites but didn't get anything that was too useful. Any suggestions? Event Type: Warning Event Source: MSExchangeIS Mailbox Store Event Category: General Event ID: 1025 Date: 3/28/2007 Time: 8:44:43 AM User: N/A C...

Too Strange!!
Today I had a user receive a NEW email from another user in the company (it showed up as a new email message and displayed the new email notification message) - the strange thing is, the email had a sent date that was over a month old. She tells me that she remembers receiving this exact same email on the actual send date which was over a month ago. I checked her inbox - which is in her personal folders and there is only one copy of it which has the sent date from a month ago. I've seen this happen before but could never figure it out. It's almost as if an old email turns up ...

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...

Strange color "smudge"
A cell in one of the spreadsheets I've been working on has developed a complexion problem! I noticed this afternoon a small smudge of color one of the cells near the top. The color is whatever I select in the Windows "Appearance" box for 3D objects. It looks like someone drew it with a sharpie or something. Just a short vertical line, about an 1/8 inch long in the lower left of the cell. If I change column widths of the column it's in or nearby, or change row height, it will be in a different column or row but in the same position relative to the overall window the spreadshee...