473,386 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Controling Event Sequencing...

New VB user...developer...

Situation...simplified...

- I want to wrap a pre and post event around a system generated where the
pre-event will always execute before the system event and the post event
will always execuate after the system is completed...
- I want to wrap this functionality in a framework, so I could possibly have
3 or 4 levels of inherited objects that need to have these pre / post events
executed before and after the system event is starting and completed...
- basically, i want to be able to add a 'Post' event to the message queue
and have it executed after the system event is completed...

ie. button clicked ... post my event ... button done clicking, system does
what is does on a completed clicked ... my event that i posted runs now...

Example...simplified...

- I want to build to custom class inherited from the common command button.

- I want to add a 'pre-click' and a 'post-click' event to the buttons click
event ... and still allow the developer to use the clicked event...

so ... on my base class object ...
I add to custom subs/functions/events...whatever you want to call them to
the control...
ue_PreClick()
ue_PostClick() ...

in the click event i call them by....Click Event...
ue_preClick(...) ... calls the User Event - Pre-Click for the button...
POST ue_postClick() ... posts a User Event - Post-Click that will be
executed after the click event is completed...

Now, the sequence of events I am looking for is....

in any descendant class...if I code the pre-click event....the code will
execute before the click and postclick events...simple, this works.

now, in any descendant class...i want the post-click event to fire only when
the Click event is completed for the button...

So, for example...

ButtonBaseClass...base object inherited from the windows controls buttons
....

Add two functions...

uePreClick (arg...)
uePostClick(arg...)

Now, I inherit from this and create another button...

ButtonFirstChild

I place this code the the uePreClick

MessageBox.Show("Hello, I am in the PreClick Event")

I place this code in the uePostClick event ...
Messagebox.Show("Hello, I am in the PostClick Event")

and finalling, I put this code in the Clicked Event...system event...
Messagebox.show("Hello, I am in the Clicked Event")

So, when I click the button ... I want to see message boxes ...

PreClick...
Click...click is done...
PostClick...

So, my question is, is there anyway in the ancestor / parent / base class to
code it such that is will execute the events in this order ... I know I
could code three custom events .... uePreClick , ueClick, and uePostClick
.... and code accordingly, but what I am after here is I want the uePostClick
event to fire after the system Click event has completed...

Is this possible in VB .Net....this is a technique I user with Powerbuilder
and it works just fine...unfortunately, I can see not how to handle this is
VB...and help of guidance would be great...

the Application.DoEvent will flush the message queue but it will not
complete the current event before calling the 'POSTED' event...what I need
is the current event to be done ... than the post event fired.

Any help would be greatly appreciated...

Thanks
Jeff
Jun 26 '06 #1
9 2443
in addition....

I want to post the raise the event so that it will execuate after the
current system event has completed...

Jeff.

"jeff" <jhersey at allnorth dottt com> wrote in message
news:e6**************@TK2MSFTNGP03.phx.gbl...
New VB user...developer...

Situation...simplified...

- I want to wrap a pre and post event around a system generated where the
pre-event will always execute before the system event and the post event
will always execuate after the system is completed...
- I want to wrap this functionality in a framework, so I could possibly
have 3 or 4 levels of inherited objects that need to have these pre / post
events executed before and after the system event is starting and
completed...
- basically, i want to be able to add a 'Post' event to the message queue
and have it executed after the system event is completed...

ie. button clicked ... post my event ... button done clicking, system does
what is does on a completed clicked ... my event that i posted runs now...

Example...simplified...

- I want to build to custom class inherited from the common command
button.

- I want to add a 'pre-click' and a 'post-click' event to the buttons
click event ... and still allow the developer to use the clicked event...

so ... on my base class object ...
I add to custom subs/functions/events...whatever you want to call them to
the control...
ue_PreClick()
ue_PostClick() ...

in the click event i call them by....Click Event...
ue_preClick(...) ... calls the User Event - Pre-Click for the button...
POST ue_postClick() ... posts a User Event - Post-Click that will be
executed after the click event is completed...

Now, the sequence of events I am looking for is....

in any descendant class...if I code the pre-click event....the code will
execute before the click and postclick events...simple, this works.

now, in any descendant class...i want the post-click event to fire only
when the Click event is completed for the button...

So, for example...

ButtonBaseClass...base object inherited from the windows controls buttons
...

Add two functions...

uePreClick (arg...)
uePostClick(arg...)

Now, I inherit from this and create another button...

ButtonFirstChild

I place this code the the uePreClick

MessageBox.Show("Hello, I am in the PreClick Event")

I place this code in the uePostClick event ...
Messagebox.Show("Hello, I am in the PostClick Event")

and finalling, I put this code in the Clicked Event...system event...
Messagebox.show("Hello, I am in the Clicked Event")

So, when I click the button ... I want to see message boxes ...

PreClick...
Click...click is done...
PostClick...

So, my question is, is there anyway in the ancestor / parent / base class
to code it such that is will execute the events in this order ... I know I
could code three custom events .... uePreClick , ueClick, and uePostClick
... and code accordingly, but what I am after here is I want the
uePostClick event to fire after the system Click event has completed...

Is this possible in VB .Net....this is a technique I user with
Powerbuilder and it works just fine...unfortunately, I can see not how to
handle this is VB...and help of guidance would be great...

the Application.DoEvent will flush the message queue but it will not
complete the current event before calling the 'POSTED' event...what I need
is the current event to be done ... than the post event fired.

Any help would be greatly appreciated...

Thanks
Jeff

Jun 26 '06 #2
Define when an event has completed (and when it begins).

The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub

Not sure if this meet your definition of completed though

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
in addition....

I want to post the raise the event so that it will execuate after the
current system event has completed...

Jeff.

"jeff" <jhersey at allnorth dottt com> wrote in message
news:e6**************@TK2MSFTNGP03.phx.gbl...
New VB user...developer...

Situation...simplified...

- I want to wrap a pre and post event around a system generated where the
pre-event will always execute before the system event and the post event
will always execuate after the system is completed...
- I want to wrap this functionality in a framework, so I could possibly
have 3 or 4 levels of inherited objects that need to have these pre /
post events executed before and after the system event is starting and
completed...
- basically, i want to be able to add a 'Post' event to the message queue
and have it executed after the system event is completed...

ie. button clicked ... post my event ... button done clicking, system
does what is does on a completed clicked ... my event that i posted runs
now...

Example...simplified...

- I want to build to custom class inherited from the common command
button.

- I want to add a 'pre-click' and a 'post-click' event to the buttons
click event ... and still allow the developer to use the clicked event...

so ... on my base class object ...
I add to custom subs/functions/events...whatever you want to call them to
the control...
ue_PreClick()
ue_PostClick() ...

in the click event i call them by....Click Event...
ue_preClick(...) ... calls the User Event - Pre-Click for the button...
POST ue_postClick() ... posts a User Event - Post-Click that will be
executed after the click event is completed...

Now, the sequence of events I am looking for is....

in any descendant class...if I code the pre-click event....the code will
execute before the click and postclick events...simple, this works.

now, in any descendant class...i want the post-click event to fire only
when the Click event is completed for the button...

So, for example...

ButtonBaseClass...base object inherited from the windows controls buttons
...

Add two functions...

uePreClick (arg...)
uePostClick(arg...)

Now, I inherit from this and create another button...

ButtonFirstChild

I place this code the the uePreClick

MessageBox.Show("Hello, I am in the PreClick Event")

I place this code in the uePostClick event ...
Messagebox.Show("Hello, I am in the PostClick Event")

and finalling, I put this code in the Clicked Event...system event...
Messagebox.show("Hello, I am in the Clicked Event")

So, when I click the button ... I want to see message boxes ...

PreClick...
Click...click is done...
PostClick...

So, my question is, is there anyway in the ancestor / parent / base class
to code it such that is will execute the events in this order ... I know
I could code three custom events .... uePreClick , ueClick, and
uePostClick ... and code accordingly, but what I am after here is I want
the uePostClick event to fire after the system Click event has
completed...

Is this possible in VB .Net....this is a technique I user with
Powerbuilder and it works just fine...unfortunately, I can see not how to
handle this is VB...and help of guidance would be great...

the Application.DoEvent will flush the message queue but it will not
complete the current event before calling the 'POSTED' event...what I
need is the current event to be done ... than the post event fired.

Any help would be greatly appreciated...

Thanks
Jeff


Jun 27 '06 #3

Thanks, unfortunately this does not solve my problem...another example...
the problem is ... the initial 'click event' will not be completed before
the OnPostClick event is fired / executed ... that is the problem ... i need
the OnPostClick event fire after the OnClick event is completely finished
.... I need some way to put to the OnPostClick in the windows event queue and
have it execute AFTER the OnClick in completely done ... at all levels...

Another example...

say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to capture
and code on it according ... however once the control fires this event - the
ItemChanged -, it continues processing the rest of 'its' system events to
complete the ItemChanged action ... say some internal stuff ... writes data
to a buffer / file and so on ... These events will happen right after the
programmer exposed Itemchanged, as the control has already put them in the
windows event queue - ItemChanged for the Programmer, ItemChanged Write to
File (control event not exposed), ItemChanged write to Buffer (control event
not exposed) and so on ... So, these system / control events will
immidiately fire after the programmer's - ItemChanged event ...

So, what I want to be able to do, is create a base class object for this
control ... myControl...

in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file ...
or a buffer...or whereever...my event will be next...so, using the event
sequence from above...ItemChanged for Programmer, ItemChanged Write to File
(control event), ItemChanged write to buffer (control event), and now my
ueMyEvent_AfterChange fires.

Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access the
information in the File / Buffer... because I know the control's entire
ItemChanged event has completed and MyEventChanged will not fire until it is
completely done. Simply calling the event inside the Itemchanged event will
not give me what I want ... I need someway to tell vb to delay my custom
event until the control's ItemChanged event or or System OnClick of the
button is completed and run it course ...

Does this make since...or sound a little stretched...

Jeff.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Define when an event has completed (and when it begins).

The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub

Not sure if this meet your definition of completed though

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
in addition....

I want to post the raise the event so that it will execuate after the
current system event has completed...

Jeff.

"jeff" <jhersey at allnorth dottt com> wrote in message
news:e6**************@TK2MSFTNGP03.phx.gbl...
New VB user...developer...

Situation...simplified...

- I want to wrap a pre and post event around a system generated where
the pre-event will always execute before the system event and the post
event will always execuate after the system is completed...
- I want to wrap this functionality in a framework, so I could possibly
have 3 or 4 levels of inherited objects that need to have these pre /
post events executed before and after the system event is starting and
completed...
- basically, i want to be able to add a 'Post' event to the message
queue and have it executed after the system event is completed...

ie. button clicked ... post my event ... button done clicking, system
does what is does on a completed clicked ... my event that i posted runs
now...

Example...simplified...

- I want to build to custom class inherited from the common command
button.

- I want to add a 'pre-click' and a 'post-click' event to the buttons
click event ... and still allow the developer to use the clicked
event...

so ... on my base class object ...
I add to custom subs/functions/events...whatever you want to call them
to the control...
ue_PreClick()
ue_PostClick() ...

in the click event i call them by....Click Event...
ue_preClick(...) ... calls the User Event - Pre-Click for the button...
POST ue_postClick() ... posts a User Event - Post-Click that will be
executed after the click event is completed...

Now, the sequence of events I am looking for is....

in any descendant class...if I code the pre-click event....the code will
execute before the click and postclick events...simple, this works.

now, in any descendant class...i want the post-click event to fire only
when the Click event is completed for the button...

So, for example...

ButtonBaseClass...base object inherited from the windows controls
buttons ...

Add two functions...

uePreClick (arg...)
uePostClick(arg...)

Now, I inherit from this and create another button...

ButtonFirstChild

I place this code the the uePreClick

MessageBox.Show("Hello, I am in the PreClick Event")

I place this code in the uePostClick event ...
Messagebox.Show("Hello, I am in the PostClick Event")

and finalling, I put this code in the Clicked Event...system event...
Messagebox.show("Hello, I am in the Clicked Event")

So, when I click the button ... I want to see message boxes ...

PreClick...
Click...click is done...
PostClick...

So, my question is, is there anyway in the ancestor / parent / base
class to code it such that is will execute the events in this order ...
I know I could code three custom events .... uePreClick , ueClick, and
uePostClick ... and code accordingly, but what I am after here is I want
the uePostClick event to fire after the system Click event has
completed...

Is this possible in VB .Net....this is a technique I user with
Powerbuilder and it works just fine...unfortunately, I can see not how
to handle this is VB...and help of guidance would be great...

the Application.DoEvent will flush the message queue but it will not
complete the current event before calling the 'POSTED' event...what I
need is the current event to be done ... than the post event fired.

Any help would be greatly appreciated...

Thanks
Jeff



Jun 27 '06 #4
You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls your
method. That way your OnClick event handler will be finished before the
PostClick stuff runs. Something like this (assumin you inherit Button)

Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub

Private Sub OnPostClick()
....
End Sub

This won't help you with PreClick though. Not sure how to solve that (if you
still need it)

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Thanks, unfortunately this does not solve my problem...another example...
the problem is ... the initial 'click event' will not be completed before
the OnPostClick event is fired / executed ... that is the problem ... i
need the OnPostClick event fire after the OnClick event is completely
finished ... I need some way to put to the OnPostClick in the windows
event queue and have it execute AFTER the OnClick in completely done ...
at all levels...

Another example...

say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to capture
and code on it according ... however once the control fires this event -
the ItemChanged -, it continues processing the rest of 'its' system events
to complete the ItemChanged action ... say some internal stuff ... writes
data to a buffer / file and so on ... These events will happen right after
the programmer exposed Itemchanged, as the control has already put them in
the windows event queue - ItemChanged for the Programmer, ItemChanged
Write to File (control event not exposed), ItemChanged write to Buffer
(control event not exposed) and so on ... So, these system / control
events will immidiately fire after the programmer's - ItemChanged event
...

So, what I want to be able to do, is create a base class object for this
control ... myControl...

in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file
... or a buffer...or whereever...my event will be next...so, using the
event sequence from above...ItemChanged for Programmer, ItemChanged Write
to File (control event), ItemChanged write to buffer (control event), and
now my ueMyEvent_AfterChange fires.

Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access the
information in the File / Buffer... because I know the control's entire
ItemChanged event has completed and MyEventChanged will not fire until it
is completely done. Simply calling the event inside the Itemchanged event
will not give me what I want ... I need someway to tell vb to delay my
custom event until the control's ItemChanged event or or System OnClick of
the button is completed and run it course ...

Does this make since...or sound a little stretched...

Jeff.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Define when an event has completed (and when it begins).

The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub

Not sure if this meet your definition of completed though

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
in addition....

I want to post the raise the event so that it will execuate after the
current system event has completed...

Jeff.

"jeff" <jhersey at allnorth dottt com> wrote in message
news:e6**************@TK2MSFTNGP03.phx.gbl...
New VB user...developer...

Situation...simplified...

- I want to wrap a pre and post event around a system generated where
the pre-event will always execute before the system event and the post
event will always execuate after the system is completed...
- I want to wrap this functionality in a framework, so I could possibly
have 3 or 4 levels of inherited objects that need to have these pre /
post events executed before and after the system event is starting and
completed...
- basically, i want to be able to add a 'Post' event to the message
queue and have it executed after the system event is completed...

ie. button clicked ... post my event ... button done clicking, system
does what is does on a completed clicked ... my event that i posted
runs now...

Example...simplified...

- I want to build to custom class inherited from the common command
button.

- I want to add a 'pre-click' and a 'post-click' event to the buttons
click event ... and still allow the developer to use the clicked
event...

so ... on my base class object ...
I add to custom subs/functions/events...whatever you want to call them
to the control...
ue_PreClick()
ue_PostClick() ...

in the click event i call them by....Click Event...
ue_preClick(...) ... calls the User Event - Pre-Click for the button...
POST ue_postClick() ... posts a User Event - Post-Click that will be
executed after the click event is completed...

Now, the sequence of events I am looking for is....

in any descendant class...if I code the pre-click event....the code
will execute before the click and postclick events...simple, this
works.

now, in any descendant class...i want the post-click event to fire only
when the Click event is completed for the button...

So, for example...

ButtonBaseClass...base object inherited from the windows controls
buttons ...

Add two functions...

uePreClick (arg...)
uePostClick(arg...)

Now, I inherit from this and create another button...

ButtonFirstChild

I place this code the the uePreClick

MessageBox.Show("Hello, I am in the PreClick Event")

I place this code in the uePostClick event ...
Messagebox.Show("Hello, I am in the PostClick Event")

and finalling, I put this code in the Clicked Event...system event...
Messagebox.show("Hello, I am in the Clicked Event")

So, when I click the button ... I want to see message boxes ...

PreClick...
Click...click is done...
PostClick...

So, my question is, is there anyway in the ancestor / parent / base
class to code it such that is will execute the events in this order ...
I know I could code three custom events .... uePreClick , ueClick, and
uePostClick ... and code accordingly, but what I am after here is I
want the uePostClick event to fire after the system Click event has
completed...

Is this possible in VB .Net....this is a technique I user with
Powerbuilder and it works just fine...unfortunately, I can see not how
to handle this is VB...and help of guidance would be great...

the Application.DoEvent will flush the message queue but it will not
complete the current event before calling the 'POSTED' event...what I
need is the current event to be done ... than the post event fired.

Any help would be greatly appreciated...

Thanks
Jeff



Jun 28 '06 #5
thank you .. i will give it a try...

the pre-click is the easy on...in the base class I will put a call to a
preClick envet ...and this will run normally ... be called before the
clicked event ...

thanks

Jeff

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls
your method. That way your OnClick event handler will be finished before
the PostClick stuff runs. Something like this (assumin you inherit Button)

Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub

Private Sub OnPostClick()
...
End Sub

This won't help you with PreClick though. Not sure how to solve that (if
you still need it)

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Thanks, unfortunately this does not solve my problem...another example...
the problem is ... the initial 'click event' will not be completed before
the OnPostClick event is fired / executed ... that is the problem ... i
need the OnPostClick event fire after the OnClick event is completely
finished ... I need some way to put to the OnPostClick in the windows
event queue and have it execute AFTER the OnClick in completely done ...
at all levels...

Another example...

say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to
capture and code on it according ... however once the control fires this
event - the ItemChanged -, it continues processing the rest of 'its'
system events to complete the ItemChanged action ... say some internal
stuff ... writes data to a buffer / file and so on ... These events will
happen right after the programmer exposed Itemchanged, as the control has
already put them in the windows event queue - ItemChanged for the
Programmer, ItemChanged Write to File (control event not exposed),
ItemChanged write to Buffer (control event not exposed) and so on ... So,
these system / control events will immidiately fire after the
programmer's - ItemChanged event ...

So, what I want to be able to do, is create a base class object for this
control ... myControl...

in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file
... or a buffer...or whereever...my event will be next...so, using the
event sequence from above...ItemChanged for Programmer, ItemChanged Write
to File (control event), ItemChanged write to buffer (control event), and
now my ueMyEvent_AfterChange fires.

Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access
the information in the File / Buffer... because I know the control's
entire ItemChanged event has completed and MyEventChanged will not fire
until it is completely done. Simply calling the event inside the
Itemchanged event will not give me what I want ... I need someway to tell
vb to delay my custom event until the control's ItemChanged event or or
System OnClick of the button is completed and run it course ...

Does this make since...or sound a little stretched...

Jeff.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Define when an event has completed (and when it begins).

The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub

Not sure if this meet your definition of completed though

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
in addition....

I want to post the raise the event so that it will execuate after the
current system event has completed...

Jeff.

"jeff" <jhersey at allnorth dottt com> wrote in message
news:e6**************@TK2MSFTNGP03.phx.gbl...
> New VB user...developer...
>
> Situation...simplified...
>
> - I want to wrap a pre and post event around a system generated where
> the pre-event will always execute before the system event and the post
> event will always execuate after the system is completed...
> - I want to wrap this functionality in a framework, so I could
> possibly have 3 or 4 levels of inherited objects that need to have
> these pre / post events executed before and after the system event is
> starting and completed...
> - basically, i want to be able to add a 'Post' event to the message
> queue and have it executed after the system event is completed...
>
> ie. button clicked ... post my event ... button done clicking, system
> does what is does on a completed clicked ... my event that i posted
> runs now...
>
> Example...simplified...
>
> - I want to build to custom class inherited from the common command
> button.
>
> - I want to add a 'pre-click' and a 'post-click' event to the buttons
> click event ... and still allow the developer to use the clicked
> event...
>
> so ... on my base class object ...
> I add to custom subs/functions/events...whatever you want to call them
> to the control...
> ue_PreClick()
> ue_PostClick() ...
>
> in the click event i call them by....Click Event...
> ue_preClick(...) ... calls the User Event - Pre-Click for the
> button...
> POST ue_postClick() ... posts a User Event - Post-Click that will be
> executed after the click event is completed...
>
> Now, the sequence of events I am looking for is....
>
> in any descendant class...if I code the pre-click event....the code
> will execute before the click and postclick events...simple, this
> works.
>
> now, in any descendant class...i want the post-click event to fire
> only when the Click event is completed for the button...
>
> So, for example...
>
> ButtonBaseClass...base object inherited from the windows controls
> buttons ...
>
> Add two functions...
>
> uePreClick (arg...)
> uePostClick(arg...)
>
> Now, I inherit from this and create another button...
>
> ButtonFirstChild
>
> I place this code the the uePreClick
>
> MessageBox.Show("Hello, I am in the PreClick Event")
>
> I place this code in the uePostClick event ...
> Messagebox.Show("Hello, I am in the PostClick Event")
>
> and finalling, I put this code in the Clicked Event...system event...
> Messagebox.show("Hello, I am in the Clicked Event")
>
> So, when I click the button ... I want to see message boxes ...
>
> PreClick...
> Click...click is done...
> PostClick...
>
> So, my question is, is there anyway in the ancestor / parent / base
> class to code it such that is will execute the events in this order
> ... I know I could code three custom events .... uePreClick , ueClick,
> and uePostClick ... and code accordingly, but what I am after here is
> I want the uePostClick event to fire after the system Click event has
> completed...
>
> Is this possible in VB .Net....this is a technique I user with
> Powerbuilder and it works just fine...unfortunately, I can see not how
> to handle this is VB...and help of guidance would be great...
>
> the Application.DoEvent will flush the message queue but it will not
> complete the current event before calling the 'POSTED' event...what I
> need is the current event to be done ... than the post event fired.
>
> Any help would be greatly appreciated...
>
> Thanks
> Jeff
>



Jun 28 '06 #6
Does not work...

the method invoker ... simply calls the method and executes it within the
same event ... does not execute after the event is fired....

Oh well...from the overwhelm responce and input, I assume this is not
something done with this language ...I will stop beating my head against the
wall and try to work around it ...

thanks.
Jeff.


"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls
your method. That way your OnClick event handler will be finished before
the PostClick stuff runs. Something like this (assumin you inherit Button)

Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub

Private Sub OnPostClick()
...
End Sub

This won't help you with PreClick though. Not sure how to solve that (if
you still need it)

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Thanks, unfortunately this does not solve my problem...another example...
the problem is ... the initial 'click event' will not be completed before
the OnPostClick event is fired / executed ... that is the problem ... i
need the OnPostClick event fire after the OnClick event is completely
finished ... I need some way to put to the OnPostClick in the windows
event queue and have it execute AFTER the OnClick in completely done ...
at all levels...

Another example...

say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to
capture and code on it according ... however once the control fires this
event - the ItemChanged -, it continues processing the rest of 'its'
system events to complete the ItemChanged action ... say some internal
stuff ... writes data to a buffer / file and so on ... These events will
happen right after the programmer exposed Itemchanged, as the control has
already put them in the windows event queue - ItemChanged for the
Programmer, ItemChanged Write to File (control event not exposed),
ItemChanged write to Buffer (control event not exposed) and so on ... So,
these system / control events will immidiately fire after the
programmer's - ItemChanged event ...

So, what I want to be able to do, is create a base class object for this
control ... myControl...

in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file
... or a buffer...or whereever...my event will be next...so, using the
event sequence from above...ItemChanged for Programmer, ItemChanged Write
to File (control event), ItemChanged write to buffer (control event), and
now my ueMyEvent_AfterChange fires.

Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access
the information in the File / Buffer... because I know the control's
entire ItemChanged event has completed and MyEventChanged will not fire
until it is completely done. Simply calling the event inside the
Itemchanged event will not give me what I want ... I need someway to tell
vb to delay my custom event until the control's ItemChanged event or or
System OnClick of the button is completed and run it course ...

Does this make since...or sound a little stretched...

Jeff.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Define when an event has completed (and when it begins).

The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub

Not sure if this meet your definition of completed though

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
in addition....

I want to post the raise the event so that it will execuate after the
current system event has completed...

Jeff.

"jeff" <jhersey at allnorth dottt com> wrote in message
news:e6**************@TK2MSFTNGP03.phx.gbl...
> New VB user...developer...
>
> Situation...simplified...
>
> - I want to wrap a pre and post event around a system generated where
> the pre-event will always execute before the system event and the post
> event will always execuate after the system is completed...
> - I want to wrap this functionality in a framework, so I could
> possibly have 3 or 4 levels of inherited objects that need to have
> these pre / post events executed before and after the system event is
> starting and completed...
> - basically, i want to be able to add a 'Post' event to the message
> queue and have it executed after the system event is completed...
>
> ie. button clicked ... post my event ... button done clicking, system
> does what is does on a completed clicked ... my event that i posted
> runs now...
>
> Example...simplified...
>
> - I want to build to custom class inherited from the common command
> button.
>
> - I want to add a 'pre-click' and a 'post-click' event to the buttons
> click event ... and still allow the developer to use the clicked
> event...
>
> so ... on my base class object ...
> I add to custom subs/functions/events...whatever you want to call them
> to the control...
> ue_PreClick()
> ue_PostClick() ...
>
> in the click event i call them by....Click Event...
> ue_preClick(...) ... calls the User Event - Pre-Click for the
> button...
> POST ue_postClick() ... posts a User Event - Post-Click that will be
> executed after the click event is completed...
>
> Now, the sequence of events I am looking for is....
>
> in any descendant class...if I code the pre-click event....the code
> will execute before the click and postclick events...simple, this
> works.
>
> now, in any descendant class...i want the post-click event to fire
> only when the Click event is completed for the button...
>
> So, for example...
>
> ButtonBaseClass...base object inherited from the windows controls
> buttons ...
>
> Add two functions...
>
> uePreClick (arg...)
> uePostClick(arg...)
>
> Now, I inherit from this and create another button...
>
> ButtonFirstChild
>
> I place this code the the uePreClick
>
> MessageBox.Show("Hello, I am in the PreClick Event")
>
> I place this code in the uePostClick event ...
> Messagebox.Show("Hello, I am in the PostClick Event")
>
> and finalling, I put this code in the Clicked Event...system event...
> Messagebox.show("Hello, I am in the Clicked Event")
>
> So, when I click the button ... I want to see message boxes ...
>
> PreClick...
> Click...click is done...
> PostClick...
>
> So, my question is, is there anyway in the ancestor / parent / base
> class to code it such that is will execute the events in this order
> ... I know I could code three custom events .... uePreClick , ueClick,
> and uePostClick ... and code accordingly, but what I am after here is
> I want the uePostClick event to fire after the system Click event has
> completed...
>
> Is this possible in VB .Net....this is a technique I user with
> Powerbuilder and it works just fine...unfortunately, I can see not how
> to handle this is VB...and help of guidance would be great...
>
> the Application.DoEvent will flush the message queue but it will not
> complete the current event before calling the 'POSTED' event...what I
> need is the current event to be done ... than the post event fired.
>
> Any help would be greatly appreciated...
>
> Thanks
> Jeff
>



Jun 29 '06 #7
Did you use BeginInvoke (Invoke won't work)? What are you doing in your
methods? Can you show the code you're using to test this?

It works fine for me. Maybe you have a different definition of "after the
event is fired"...

The Click event is fired in response to a WM_COMMAND message that gets sent
to the message queue by Windows. When you call BeginInvoke as shown below,
the framework will post a message (using PostMessage) to the message queue
and immediately return. This message will be placed last in the queue, so
when the framework eventually gets to it, the Click event (and the
WM_COMMAND message that triggered it) have long since been completed. The
event can't be any more finished than this, so not sure what you're after.

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:eo**************@TK2MSFTNGP05.phx.gbl...
Does not work...

the method invoker ... simply calls the method and executes it within the
same event ... does not execute after the event is fired....

Oh well...from the overwhelm responce and input, I assume this is not
something done with this language ...I will stop beating my head against
the wall and try to work around it ...

thanks.
Jeff.


"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls
your method. That way your OnClick event handler will be finished before
the PostClick stuff runs. Something like this (assumin you inherit
Button)

Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub

Private Sub OnPostClick()
...
End Sub

This won't help you with PreClick though. Not sure how to solve that (if
you still need it)

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Thanks, unfortunately this does not solve my problem...another
example...
the problem is ... the initial 'click event' will not be completed
before the OnPostClick event is fired / executed ... that is the problem
... i need the OnPostClick event fire after the OnClick event is
completely finished ... I need some way to put to the OnPostClick in the
windows event queue and have it execute AFTER the OnClick in completely
done ... at all levels...

Another example...

say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to
capture and code on it according ... however once the control fires this
event - the ItemChanged -, it continues processing the rest of 'its'
system events to complete the ItemChanged action ... say some internal
stuff ... writes data to a buffer / file and so on ... These events will
happen right after the programmer exposed Itemchanged, as the control
has already put them in the windows event queue - ItemChanged for the
Programmer, ItemChanged Write to File (control event not exposed),
ItemChanged write to Buffer (control event not exposed) and so on ...
So, these system / control events will immidiately fire after the
programmer's - ItemChanged event ...

So, what I want to be able to do, is create a base class object for this
control ... myControl...

in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file
... or a buffer...or whereever...my event will be next...so, using the
event sequence from above...ItemChanged for Programmer, ItemChanged
Write to File (control event), ItemChanged write to buffer (control
event), and now my ueMyEvent_AfterChange fires.

Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access
the information in the File / Buffer... because I know the control's
entire ItemChanged event has completed and MyEventChanged will not fire
until it is completely done. Simply calling the event inside the
Itemchanged event will not give me what I want ... I need someway to
tell vb to delay my custom event until the control's ItemChanged event
or or System OnClick of the button is completed and run it course ...

Does this make since...or sound a little stretched...

Jeff.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Define when an event has completed (and when it begins).

The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub

Not sure if this meet your definition of completed though

/claes

"jeff" <jhersey at allnorth dottt com> wrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl...
> in addition....
>
> I want to post the raise the event so that it will execuate after the
> current system event has completed...
>
> Jeff.
>
> "jeff" <jhersey at allnorth dottt com> wrote in message
> news:e6**************@TK2MSFTNGP03.phx.gbl...
>> New VB user...developer...
>>
>> Situation...simplified...
>>
>> - I want to wrap a pre and post event around a system generated where
>> the pre-event will always execute before the system event and the
>> post event will always execuate after the system is completed...
>> - I want to wrap this functionality in a framework, so I could
>> possibly have 3 or 4 levels of inherited objects that need to have
>> these pre / post events executed before and after the system event is
>> starting and completed...
>> - basically, i want to be able to add a 'Post' event to the message
>> queue and have it executed after the system event is completed...
>>
>> ie. button clicked ... post my event ... button done clicking, system
>> does what is does on a completed clicked ... my event that i posted
>> runs now...
>>
>> Example...simplified...
>>
>> - I want to build to custom class inherited from the common command
>> button.
>>
>> - I want to add a 'pre-click' and a 'post-click' event to the buttons
>> click event ... and still allow the developer to use the clicked
>> event...
>>
>> so ... on my base class object ...
>> I add to custom subs/functions/events...whatever you want to call
>> them to the control...
>> ue_PreClick()
>> ue_PostClick() ...
>>
>> in the click event i call them by....Click Event...
>> ue_preClick(...) ... calls the User Event - Pre-Click for the
>> button...
>> POST ue_postClick() ... posts a User Event - Post-Click that will be
>> executed after the click event is completed...
>>
>> Now, the sequence of events I am looking for is....
>>
>> in any descendant class...if I code the pre-click event....the code
>> will execute before the click and postclick events...simple, this
>> works.
>>
>> now, in any descendant class...i want the post-click event to fire
>> only when the Click event is completed for the button...
>>
>> So, for example...
>>
>> ButtonBaseClass...base object inherited from the windows controls
>> buttons ...
>>
>> Add two functions...
>>
>> uePreClick (arg...)
>> uePostClick(arg...)
>>
>> Now, I inherit from this and create another button...
>>
>> ButtonFirstChild
>>
>> I place this code the the uePreClick
>>
>> MessageBox.Show("Hello, I am in the PreClick Event")
>>
>> I place this code in the uePostClick event ...
>> Messagebox.Show("Hello, I am in the PostClick Event")
>>
>> and finalling, I put this code in the Clicked Event...system event...
>> Messagebox.show("Hello, I am in the Clicked Event")
>>
>> So, when I click the button ... I want to see message boxes ...
>>
>> PreClick...
>> Click...click is done...
>> PostClick...
>>
>> So, my question is, is there anyway in the ancestor / parent / base
>> class to code it such that is will execute the events in this order
>> ... I know I could code three custom events .... uePreClick ,
>> ueClick, and uePostClick ... and code accordingly, but what I am
>> after here is I want the uePostClick event to fire after the system
>> Click event has completed...
>>
>> Is this possible in VB .Net....this is a technique I user with
>> Powerbuilder and it works just fine...unfortunately, I can see not
>> how to handle this is VB...and help of guidance would be great...
>>
>> the Application.DoEvent will flush the message queue but it will not
>> complete the current event before calling the 'POSTED' event...what I
>> need is the current event to be done ... than the post event fired.
>>
>> Any help would be greatly appreciated...
>>
>> Thanks
>> Jeff
>>
>
>



Jun 29 '06 #8
This appears to be a problem in VB 6 as well...

.....for a previous post ....

I'm writing an add-in for a software (SolidWorks) that sends me an event. In
my event handler, I'm not allowed to do a certain thing, but I want to do it
immediately after the event is handled.
I expected that calling RaiseEvent from the handler would call an Event
which would do the job, but it doesn't work : the call is done immediately
(BTW: what's the interest of RaiseEvent if it calls the handler directly ?).
My idea would be to call the PostMessage API (that's what I do in C and it
works), but how to make it call a VB Event ?
Any other idea ? Thanks¨!

....and appears everybody answered with 'write a timer event and make sure
you include enough time so you event is completed'...

....essentially what I am trying to do with Sybases datawindow .net control.
Post an event for the itemchanged event ... because data is not writed to
the buffer until after the itemchanged event is completed....and I have
tried ... with no luck to use your suggested method...and even if I could
get it to work as desired .... not being able to include parameters is a
huge limitation and would not work ... I would have to create a bunch in
instance variables (or members) for the class to store my data for use
between events.
"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:uZ**************@TK2MSFTNGP03.phx.gbl...
Did you use BeginInvoke (Invoke won't work)? What are you doing in your
methods? Can you show the code you're using to test this?

It works fine for me. Maybe you have a different definition of "after the
event is fired"...

The Click event is fired in response to a WM_COMMAND message that gets
sent to the message queue by Windows. When you call BeginInvoke as shown
below, the framework will post a message (using PostMessage) to the
message queue and immediately return. This message will be placed last in
the queue, so when the framework eventually gets to it, the Click event
(and the WM_COMMAND message that triggered it) have long since been
completed. The event can't be any more finished than this, so not sure
what you're after.

/claes

"jeff" <jhersey at allnorth dottt comwrote in message
news:eo**************@TK2MSFTNGP05.phx.gbl...
>Does not work...

the method invoker ... simply calls the method and executes it within the
same event ... does not execute after the event is fired....

Oh well...from the overwhelm responce and input, I assume this is not
something done with this language ...I will stop beating my head against
the wall and try to work around it ...

thanks.
Jeff.


"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>>You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls
your method. That way your OnClick event handler will be finished before
the PostClick stuff runs. Something like this (assumin you inherit
Button)

Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub

Private Sub OnPostClick()
...
End Sub

This won't help you with PreClick though. Not sure how to solve that (if
you still need it)

/claes

"jeff" <jhersey at allnorth dottt comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .

Thanks, unfortunately this does not solve my problem...another
example...
the problem is ... the initial 'click event' will not be completed
before the OnPostClick event is fired / executed ... that is the
problem ... i need the OnPostClick event fire after the OnClick event
is completely finished ... I need some way to put to the OnPostClick in
the windows event queue and have it execute AFTER the OnClick in
completely done ... at all levels...

Another example...

say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to
capture and code on it according ... however once the control fires
this event - the ItemChanged -, it continues processing the rest of
'its' system events to complete the ItemChanged action ... say some
internal stuff ... writes data to a buffer / file and so on ... These
events will happen right after the programmer exposed Itemchanged, as
the control has already put them in the windows event queue -
ItemChanged for the Programmer, ItemChanged Write to File (control
event not exposed), ItemChanged write to Buffer (control event not
exposed) and so on ... So, these system / control events will
immidiately fire after the programmer's - ItemChanged event ...

So, what I want to be able to do, is create a base class object for
this control ... myControl...

in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file
... or a buffer...or whereever...my event will be next...so, using the
event sequence from above...ItemChanged for Programmer, ItemChanged
Write to File (control event), ItemChanged write to buffer (control
event), and now my ueMyEvent_AfterChange fires.

Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access
the information in the File / Buffer... because I know the control's
entire ItemChanged event has completed and MyEventChanged will not fire
until it is completely done. Simply calling the event inside the
Itemchanged event will not give me what I want ... I need someway to
tell vb to delay my custom event until the control's ItemChanged event
or or System OnClick of the button is completed and run it course ...

Does this make since...or sound a little stretched...

Jeff.

"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl...
Define when an event has completed (and when it begins).
>
The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub
>
Not sure if this meet your definition of completed though
>
/claes
>
"jeff" <jhersey at allnorth dottt comwrote in message
news:OT**************@TK2MSFTNGP04.phx.gbl.. .
>in addition....
>>
>I want to post the raise the event so that it will execuate after the
>current system event has completed...
>>
>Jeff.
>>
>"jeff" <jhersey at allnorth dottt comwrote in message
>news:e6**************@TK2MSFTNGP03.phx.gbl. ..
>>New VB user...developer...
>>>
>>Situation...simplified...
>>>
>>- I want to wrap a pre and post event around a system generated
>>where the pre-event will always execute before the system event and
>>the post event will always execuate after the system is completed...
>>- I want to wrap this functionality in a framework, so I could
>>possibly have 3 or 4 levels of inherited objects that need to have
>>these pre / post events executed before and after the system event
>>is starting and completed...
>>- basically, i want to be able to add a 'Post' event to the message
>>queue and have it executed after the system event is completed...
>>>
>>ie. button clicked ... post my event ... button done clicking,
>>system does what is does on a completed clicked ... my event that i
>>posted runs now...
>>>
>>Example...simplified...
>>>
>>- I want to build to custom class inherited from the common command
>>button.
>>>
>>- I want to add a 'pre-click' and a 'post-click' event to the
>>buttons click event ... and still allow the developer to use the
>>clicked event...
>>>
>>so ... on my base class object ...
>>I add to custom subs/functions/events...whatever you want to call
>>them to the control...
>>ue_PreClick()
>>ue_PostClick() ...
>>>
>>in the click event i call them by....Click Event...
>>ue_preClick(...) ... calls the User Event - Pre-Click for the
>>button...
>>POST ue_postClick() ... posts a User Event - Post-Click that will be
>>executed after the click event is completed...
>>>
>>Now, the sequence of events I am looking for is....
>>>
>>in any descendant class...if I code the pre-click event....the code
>>will execute before the click and postclick events...simple, this
>>works.
>>>
>>now, in any descendant class...i want the post-click event to fire
>>only when the Click event is completed for the button...
>>>
>>So, for example...
>>>
>>ButtonBaseClass...base object inherited from the windows controls
>>buttons ...
>>>
>>Add two functions...
>>>
>>uePreClick (arg...)
>>uePostClick(arg...)
>>>
>>Now, I inherit from this and create another button...
>>>
>>ButtonFirstChild
>>>
>>I place this code the the uePreClick
>>>
>>MessageBox.Show("Hello, I am in the PreClick Event")
>>>
>>I place this code in the uePostClick event ...
>>Messagebox.Show("Hello, I am in the PostClick Event")
>>>
>>and finalling, I put this code in the Clicked Event...system
>>event...
>>Messagebox.show("Hello, I am in the Clicked Event")
>>>
>>So, when I click the button ... I want to see message boxes ...
>>>
>>PreClick...
>>Click...click is done...
>>PostClick...
>>>
>>So, my question is, is there anyway in the ancestor / parent / base
>>class to code it such that is will execute the events in this order
>>... I know I could code three custom events .... uePreClick ,
>>ueClick, and uePostClick ... and code accordingly, but what I am
>>after here is I want the uePostClick event to fire after the system
>>Click event has completed...
>>>
>>Is this possible in VB .Net....this is a technique I user with
>>Powerbuilder and it works just fine...unfortunately, I can see not
>>how to handle this is VB...and help of guidance would be great...
>>>
>>the Application.DoEvent will flush the message queue but it will not
>>complete the current event before calling the 'POSTED' event...what
>>I need is the current event to be done ... than the post event
>>fired.
>>>
>>Any help would be greatly appreciated...
>>>
>>Thanks
>>Jeff
>>>
>>
>>
>
>




Jul 6 '06 #9
You can include parameters with the method I suggested. I used the
MethodInvoker delegate because it's the simplest of them. You can define
your own delegate in whatever way you want it. Not sure why it doesn't work
for you though. I've successfully used it to handle the exact same scenario
that you're describing.
You can always use P/Invoke and call PostMessage directly:

Public Declare Auto Function SendMessage Lib "User32.dll" (ByVal hwnd As
IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As
IntPtr) As Integer
(you can change the wParam and lParam parameters to other types if you need)

Then in order to catch your message you need to implement the IMessageFilter
interface
/claes
"jeff" <jhersey at allnorth dottt comwrote in message
news:Ot*************@TK2MSFTNGP04.phx.gbl...
This appears to be a problem in VB 6 as well...

....for a previous post ....

I'm writing an add-in for a software (SolidWorks) that sends me an event.
In
my event handler, I'm not allowed to do a certain thing, but I want to do
it
immediately after the event is handled.
I expected that calling RaiseEvent from the handler would call an Event
which would do the job, but it doesn't work : the call is done immediately
(BTW: what's the interest of RaiseEvent if it calls the handler directly
?).
My idea would be to call the PostMessage API (that's what I do in C and it
works), but how to make it call a VB Event ?
Any other idea ? Thanks¨!

...and appears everybody answered with 'write a timer event and make sure
you include enough time so you event is completed'...

...essentially what I am trying to do with Sybases datawindow .net
control. Post an event for the itemchanged event ... because data is not
writed to the buffer until after the itemchanged event is completed....and
I have tried ... with no luck to use your suggested method...and even if I
could get it to work as desired .... not being able to include parameters
is a huge limitation and would not work ... I would have to create a bunch
in instance variables (or members) for the class to store my data for use
between events.
"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:uZ**************@TK2MSFTNGP03.phx.gbl...
>Did you use BeginInvoke (Invoke won't work)? What are you doing in your
methods? Can you show the code you're using to test this?

It works fine for me. Maybe you have a different definition of "after the
event is fired"...

The Click event is fired in response to a WM_COMMAND message that gets
sent to the message queue by Windows. When you call BeginInvoke as shown
below, the framework will post a message (using PostMessage) to the
message queue and immediately return. This message will be placed last in
the queue, so when the framework eventually gets to it, the Click event
(and the WM_COMMAND message that triggered it) have long since been
completed. The event can't be any more finished than this, so not sure
what you're after.

/claes

"jeff" <jhersey at allnorth dottt comwrote in message
news:eo**************@TK2MSFTNGP05.phx.gbl...
>>Does not work...

the method invoker ... simply calls the method and executes it within
the same event ... does not execute after the event is fired....

Oh well...from the overwhelm responce and input, I assume this is not
something done with this language ...I will stop beating my head against
the wall and try to work around it ...

thanks.
Jeff.


"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls
your method. That way your OnClick event handler will be finished
before the PostClick stuff runs. Something like this (assumin you
inherit Button)

Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub

Private Sub OnPostClick()
...
End Sub

This won't help you with PreClick though. Not sure how to solve that
(if you still need it)

/claes

"jeff" <jhersey at allnorth dottt comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>
Thanks, unfortunately this does not solve my problem...another
example...
>
>
the problem is ... the initial 'click event' will not be completed
before the OnPostClick event is fired / executed ... that is the
problem ... i need the OnPostClick event fire after the OnClick event
is completely finished ... I need some way to put to the OnPostClick
in the windows event queue and have it execute AFTER the OnClick in
completely done ... at all levels...
>
Another example...
>
say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to
capture and code on it according ... however once the control fires
this event - the ItemChanged -, it continues processing the rest of
'its' system events to complete the ItemChanged action ... say some
internal stuff ... writes data to a buffer / file and so on ... These
events will happen right after the programmer exposed Itemchanged, as
the control has already put them in the windows event queue -
ItemChanged for the Programmer, ItemChanged Write to File (control
event not exposed), ItemChanged write to Buffer (control event not
exposed) and so on ... So, these system / control events will
immidiately fire after the programmer's - ItemChanged event ...
>
So, what I want to be able to do, is create a base class object for
this control ... myControl...
>
in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the
file ... or a buffer...or whereever...my event will be next...so,
using the event sequence from above...ItemChanged for Programmer,
ItemChanged Write to File (control event), ItemChanged write to buffer
(control event), and now my ueMyEvent_AfterChange fires.
>
Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access
the information in the File / Buffer... because I know the control's
entire ItemChanged event has completed and MyEventChanged will not
fire until it is completely done. Simply calling the event inside the
Itemchanged event will not give me what I want ... I need someway to
tell vb to delay my custom event until the control's ItemChanged event
or or System OnClick of the button is completed and run it course ...
>
Does this make since...or sound a little stretched...
>
Jeff.
>
"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:eE**************@TK2MSFTNGP03.phx.gbl.. .
>Define when an event has completed (and when it begins).
>>
>The simplest solution is to do this:
>Protected Overrides Sub OnClick(...)
> OnPreClick(...)
> MyBase.OnClick(...)
> OnPostClick(...)
>End Sub
>>
>Not sure if this meet your definition of completed though
>>
> /claes
>>
>"jeff" <jhersey at allnorth dottt comwrote in message
>news:OT**************@TK2MSFTNGP04.phx.gbl. ..
>>in addition....
>>>
>>I want to post the raise the event so that it will execuate after
>>the current system event has completed...
>>>
>>Jeff.
>>>
>>"jeff" <jhersey at allnorth dottt comwrote in message
>>news:e6**************@TK2MSFTNGP03.phx.gbl.. .
>>>New VB user...developer...
>>>>
>>>Situation...simplified...
>>>>
>>>- I want to wrap a pre and post event around a system generated
>>>where the pre-event will always execute before the system event and
>>>the post event will always execuate after the system is
>>>completed...
>>>- I want to wrap this functionality in a framework, so I could
>>>possibly have 3 or 4 levels of inherited objects that need to have
>>>these pre / post events executed before and after the system event
>>>is starting and completed...
>>>- basically, i want to be able to add a 'Post' event to the message
>>>queue and have it executed after the system event is completed...
>>>>
>>>ie. button clicked ... post my event ... button done clicking,
>>>system does what is does on a completed clicked ... my event that i
>>>posted runs now...
>>>>
>>>Example...simplified...
>>>>
>>>- I want to build to custom class inherited from the common command
>>>button.
>>>>
>>>- I want to add a 'pre-click' and a 'post-click' event to the
>>>buttons click event ... and still allow the developer to use the
>>>clicked event...
>>>>
>>>so ... on my base class object ...
>>>I add to custom subs/functions/events...whatever you want to call
>>>them to the control...
>>>ue_PreClick()
>>>ue_PostClick() ...
>>>>
>>>in the click event i call them by....Click Event...
>>>ue_preClick(...) ... calls the User Event - Pre-Click for the
>>>button...
>>>POST ue_postClick() ... posts a User Event - Post-Click that will
>>>be executed after the click event is completed...
>>>>
>>>Now, the sequence of events I am looking for is....
>>>>
>>>in any descendant class...if I code the pre-click event....the code
>>>will execute before the click and postclick events...simple, this
>>>works.
>>>>
>>>now, in any descendant class...i want the post-click event to fire
>>>only when the Click event is completed for the button...
>>>>
>>>So, for example...
>>>>
>>>ButtonBaseClass...base object inherited from the windows controls
>>>buttons ...
>>>>
>>>Add two functions...
>>>>
>>>uePreClick (arg...)
>>>uePostClick(arg...)
>>>>
>>>Now, I inherit from this and create another button...
>>>>
>>>ButtonFirstChild
>>>>
>>>I place this code the the uePreClick
>>>>
>>>MessageBox.Show("Hello, I am in the PreClick Event")
>>>>
>>>I place this code in the uePostClick event ...
>>>Messagebox.Show("Hello, I am in the PostClick Event")
>>>>
>>>and finalling, I put this code in the Clicked Event...system
>>>event...
>>>Messagebox.show("Hello, I am in the Clicked Event")
>>>>
>>>So, when I click the button ... I want to see message boxes ...
>>>>
>>>PreClick...
>>>Click...click is done...
>>>PostClick...
>>>>
>>>So, my question is, is there anyway in the ancestor / parent / base
>>>class to code it such that is will execute the events in this order
>>>... I know I could code three custom events .... uePreClick ,
>>>ueClick, and uePostClick ... and code accordingly, but what I am
>>>after here is I want the uePostClick event to fire after the system
>>>Click event has completed...
>>>>
>>>Is this possible in VB .Net....this is a technique I user with
>>>Powerbuilder and it works just fine...unfortunately, I can see not
>>>how to handle this is VB...and help of guidance would be great...
>>>>
>>>the Application.DoEvent will flush the message queue but it will
>>>not complete the current event before calling the 'POSTED'
>>>event...what I need is the current event to be done ... than the
>>>post event fired.
>>>>
>>>Any help would be greatly appreciated...
>>>>
>>>Thanks
>>>Jeff
>>>>
>>>
>>>
>>
>>
>
>




Jul 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul Daly (MCP) | last post by:
Hello, Situation: I have a drop down list on a main form in my program. I have another form for entering a new item that will reside in the drop down list of the main form. When the Add item...
1
by: Joe Saliba | last post by:
Hi Folks, am working on an archiving project which they use a little format of paper on which they type on it code and descriptions on each line, and they append on it new lines later on via a...
2
by: robboll | last post by:
Here is a sequencing problem for MS Access (or I guess T-SQL) if someone can assist. I am trying to build a function that counts the members of the group. In this case, the group consists of...
2
by: Claudia Fong | last post by:
Hi, I have 4 reports created in Ms-access and I will use VB to print those reports. My problem is I'm not sure if I can control wich report to print.. Those reports are almost the same, what...
1
by: Mohammed Abdel-Razzak | last post by:
Dear sirs I want you to give me link to some articles talking about controling the computer hardware from C#. But what I most need now: How can I open the CDRom from my C# application??? ...
0
by: Tom Houston via .NET 247 | last post by:
I have built vb.net application that runs on my SBS2003 thatconsists of 20 plus form and menus. I am having problems with aweb form using textboxes. There are also three buttons,back/exit/save. The...
5
by: David C. Allen | last post by:
I have a vb.net app that is controling excel 2000 thru the com interop interface. I have referenced the excel 9.0 library and have cut down the code in the problem subroutine to this: Dim...
5
by: Andy Fish | last post by:
Hi, I have an asp.net web application which uses a pop-up form that works a bit like a dialog box. when the user clicks "OK" it does a postback (basically a form post if you don't know .net) to...
0
by: apondu | last post by:
Hi, I have a doubt in Packing and deployment using DotNet. I have 3 project which are indepenedent of each other. I have created a new project which uses these 3 independent project. Now i want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.