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 9 2337
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
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
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
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
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 >
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 >
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 >> > >
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 >>> >> >> > >
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 >>>> >>> >>> >> >> > > This discussion thread is closed Replies have been disabled for this discussion. Similar topics
5 posts
views
Thread by Paul Daly (MCP) |
last post: by
|
1 post
views
Thread by Joe Saliba |
last post: by
|
2 posts
views
Thread by robboll |
last post: by
|
2 posts
views
Thread by Claudia Fong |
last post: by
|
1 post
views
Thread by Mohammed Abdel-Razzak |
last post: by
|
reply
views
Thread by Tom Houston via .NET 247 |
last post: by
|
5 posts
views
Thread by David C. Allen |
last post: by
|
5 posts
views
Thread by Andy Fish |
last post: by
|
reply
views
Thread by apondu |
last post: by
| | | | | | | | | | |