ActiveX-Exe: .Value=True doesn't work while direct click on button works 
Author Message
 ActiveX-Exe: .Value=True doesn't work while direct click on button works
Hello.
I have an ActiveX-exe that has

1) a module with the declare
"Public mForm As frmMain"

2) a class module with
Public WithEvents eButton As CommandButton

Private Sub Class_Initialize()

     Set mForm = New frmMain
     Load mForm
        mForm.Show

     Set eButton = mForm.btnNotification

End Sub

Private Sub eBtnNotification_Click()
        Call Beep(500, 100)
        RaiseEvent Notification
End Sub

3) A form "frmMain" with a command button.

When I click on the button on the mForm, an event is raised in both the
ActiveX-Exe and the Client.
However if I set a timer to call "me.btnNofication.Value=True", the
event is raised ONLY in the ActiveX-exe.

Can anybody help?



Mon, 27 Sep 2010 22:38:37 GMT  
 ActiveX-Exe: .Value=True doesn't work while direct click on button works

Quote:

> When I click on the button on the mForm, an event is raised in both the
> ActiveX-Exe and the Client.
> However if I set a timer to call "me.btnNofication.Value=True", the event
> is raised ONLY in the ActiveX-exe.

> Can anybody help?

I was hoping someone would jump in and ask for more info.

Any problem you may be having isn't caused by the code below, even though I
had to double-check to believe you were able to expose a VB command button
to "the world". That doesn't seem right to me, for some reason.

All of those Publics scare the heck out of me. Do they need to be Public?
You do know that, since your form's declared Public in a module, all
instances of the class will be sharing the same global and stomping on each
others values, right?... that means, if the class init method creates an
instance of the form and your app creates more than one instance of the
class, only the last instance created will be holding a reference to the
object variable that'll be raising events. Any other loaded forms will be
firing events into "thin air"

You say the client app's not getting the events when using a timer... place
some debug.prints in there and add a temporary property you can set to let
you know who VB "thinks" the client is.... basically, there's not enough
info in the post to give any "here, do this" type answers... no "client
side" code at all.

Quote:
> 1) a module with the declare
> "Public mForm As frmMain"

> 2) a class module with
> Public WithEvents eButton As CommandButton

> Private Sub Class_Initialize()

>     Set mForm = New frmMain
>     Load mForm
> mForm.Show

>     Set eButton = mForm.btnNotification

> End Sub

> Private Sub eBtnNotification_Click()
>     Call Beep(500, 100)
> RaiseEvent Notification
> End Sub

> 3) A form "frmMain" with a command button.

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm


Tue, 28 Sep 2010 23:40:19 GMT  
 ActiveX-Exe: .Value=True doesn't work while direct click on button works


Quote:


> > When I click on the button on the mForm, an event is raised in both the
> > ActiveX-Exe and the Client.
> > However if I set a timer to call "me.btnNofication.Value=True", the
event
> > is raised ONLY in the ActiveX-exe.

> > Can anybody help?

> I was hoping someone would jump in and ask for more info.

Me too.

OP,

Besides the items Ken mentioned also consider that an ActiveX Exe is running
on a different thread. When you 'connect' to an ActiveX Exe through
automation that 'sub' becomes part of your client's 'space' via COM, but it
is not complete access to the Exec. ie, the Exec could very well be doing
processing that doesn't have a thing to do with any clients that might be
connected.

Without more information it is not possible to provide any hints.

-ralph



Wed, 29 Sep 2010 02:08:11 GMT  
 ActiveX-Exe: .Value=True doesn't work while direct click on button works
Hmm, I didn't talk about a Timer.
My code got too weird, and I helped myself now by using a Timer which I
fire with an interval of 1 ms and disabling it immediately after that.
For some reason my programmatical changes fire WithEvents but those
WithEvents do not get to the client. When my changes are caused by for
example mouse clicks or direct input into a text box, the clients do get
the message.

Not sure what I mean?
Okay, let's assume your house is burning. You call 911, and the fire
brigade comes.
Now let's assume your house is NOT burning, but you call 911 and say
your house is burning. The fire brigade comes anyway.

The problem with my ActiveX-exe was that the fire brigade did NOT come
because my house was not really burning (I did not click on the button,
but said "Me.CommandButton1.Value = True" instead.
That is what I mean by calling 911.

Sounds absolutely strange (well, my story may, too, but I meant the code
part), but it's true. Unfortunately I don't have any more time to check
the reason for that.
Keith.



Wed, 29 Sep 2010 03:25:28 GMT  
 ActiveX-Exe: .Value=True doesn't work while direct click on button works


Quote:
> Hmm, I didn't talk about a Timer.
> My code got too weird, and I helped myself now by using a Timer which I
> fire with an interval of 1 ms and disabling it immediately after that.
> For some reason my programmatical changes fire WithEvents but those
> WithEvents do not get to the client. When my changes are caused by for
> example mouse clicks or direct input into a text box, the clients do get
> the message.

> Not sure what I mean?
> Okay, let's assume your house is burning. You call 911, and the fire
> brigade comes.
> Now let's assume your house is NOT burning, but you call 911 and say
> your house is burning. The fire brigade comes anyway.

> The problem with my ActiveX-exe was that the fire brigade did NOT come
> because my house was not really burning (I did not click on the button,
> but said "Me.CommandButton1.Value = True" instead.
> That is what I mean by calling 911.

> Sounds absolutely strange (well, my story may, too, but I meant the code
> part), but it's true. Unfortunately I don't have any more time to check
> the reason for that.
> Keith.

Better if you drop the allegorical references and just showed a bit of code
for what you are trying to do. [<g> I didn't mean for that to sound as harsh
as it perhaps does.]

It doesn't have to be all the code, perhaps a pseudo-code view of the
over-all architecture. Generally what you are up to. The client is doing
this. The Exec is doing this. ... .... Something at least that we could use
to duplicate the problem.

There are other people around here that are experts (you can exclude me)
that can solve the problem - but they need something more substantial to
chew on.

-ralph



Wed, 29 Sep 2010 07:24:49 GMT  
 ActiveX-Exe: .Value=True doesn't work while direct click on button works
Maybe I'm missing something but your BtnNotification seems to have changed
its name Keith.

In one bit of code, you set eButton to mForm.btnNotification, but later on
your event handler is for something called eBtnNotification (i.e. with "e"
prefix). If the control isn't called that then this handler will never be
called and so never raise the Notification event

    Tony Proctor


Quote:
> Hello.
> I have an ActiveX-exe that has

> 1) a module with the declare
> "Public mForm As frmMain"

> 2) a class module with
> Public WithEvents eButton As CommandButton

> Private Sub Class_Initialize()

>     Set mForm = New frmMain
>     Load mForm
> mForm.Show

>     Set eButton = mForm.btnNotification

> End Sub

> Private Sub eBtnNotification_Click()
>     Call Beep(500, 100)
> RaiseEvent Notification
> End Sub

> 3) A form "frmMain" with a command button.

> When I click on the button on the mForm, an event is raised in both the
> ActiveX-Exe and the Client.
> However if I set a timer to call "me.btnNofication.Value=True", the event
> is raised ONLY in the ActiveX-exe.

> Can anybody help?



Wed, 29 Sep 2010 18:05:27 GMT  
 ActiveX-Exe: .Value=True doesn't work while direct click on button works


Quote:
> Maybe I'm missing something but your BtnNotification seems to have changed
> its name Keith.

> In one bit of code, you set eButton to mForm.btnNotification, but later on
> your event handler is for something called eBtnNotification (i.e. with "e"
> prefix). If the control isn't called that then this handler will never be
> called and so never raise the Notification event

>     Tony Proctor

lol!

I 'assumed' that was merely an an artifact of the OP posting 'Air Code'.
Quite funny if that was the problem all along. (Not that I haven't done that
myself on more occasions than I would ever admit. <g>)

-ralph



Wed, 29 Sep 2010 21:40:11 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. ActiveX.exe /UNREGISTER doesn't work

2. dotnetfx.exe bootstrapper example setup.exe doesn't work

3. TreeView.Sorted = True doesn't work

4. Why DCOM ActiveX Exe is Working and ActiveX Dll is not working

5. dbList.BoundColumn doesn't work with MatchEntry in Click event

6. dbList.BoundColumn doesn't work with MatchEntry in Click event

7. dbList.BoundColumn doesn't work with MatchEntry in Click event

8. dbList.BoundColumn doesn't work with MatchEntry in Click event

9. Why doesn't this button work?

10. Button doesn't work in new document

11. Button.Focus() method doesn't work (sometimes)

12. Windows Service Calling VB6 dll doesn't work but works with VB6

 

 
Powered by phpBB® Forum Software