Re: Call Sub vs. fake a key press

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 07/31/04


Date: Sat, 31 Jul 2004 14:01:27 -0500

Ricky,
What kind of "buttons" are we talking about?

Rather then calling an event handler directly, as there may actually be
multiple event handlers attached to the button. You can simply call
Button.PerformClick.

Hope this helps
Jay

"Ricky W. Hunt" <rhunt22@hotmail.com> wrote in message
news:PINOc.220130$Oq2.52920@attbi_s52...
> First, the subject probably doesn't use the correct terms but I'm not sure
> what it's called in VB.
>
> I'm writing a media player app. The subroutine that handles the "open
file"
> button contains an If statement to see if a file was already playing and
if
> so executes some code to stop the previous file from playing among other
> things. There's also a "stop" button on the form that contains the exact
> same code. Obviously it would be easier if there was just one subroutine
> containing the code and that sub would be called from the If in the open
> routine and from the stop routine. My question is, is there a way to make
> the program think the "Stop" button was pressed? I.E. is there anything
> statement I can put in the If statement in the "open file" sub that will
> "trigger" just the same as if the "stop" button had been pressed? If so,
are
> there any caveats to faking a button click from within the program versus
> just putting the code in a sub and calling it from both events?
>
> --
> Thanks,
> Ricky W. Hunt
> freendeed
>
>



Relevant Pages

  • Re: Event enqueing in PostMessage style
    ... >> invoked not earlier as the calling thread returns to the central message ... >> meaning that the event handler is called immediately and interrupts the ... >> Private WithEvents MyEventObj As New MyEventClass ... >> Private Sub MyHandler() Handles MyEventObj.MyEvent ...
    (microsoft.public.dotnet.general)
  • Re: Trouble with DeselectAll()
    ... DoCmdbehaves exactly like calling DeselectAll(), ... Calling DoCmdtwice also works. ... from an event handler seems to be what is broken. ...
    (microsoft.public.visio.developer)
  • Re: Spanning thread in WS Async Call
    ... I am calling a web service asynchronously as follows ... I want to span thread here to do some operation on the the result data and ... Why don't you do your processing within the event handler? ... John Saunders | MVP – Windows Server System – Connected System Developer ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: How to programmatically invoke Click event of the Button ?
    ... Or if I need to invoke an event of Label class? ... click event handler should call the TakeOrdermethod. ... you can call TakeOrderinstead of calling the ... was just calling your button's OnClick() method to do what the button was ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Idea
    ... its context object could be the control. ... that Sender is a requisite in every event handler, ... And I take it you mean the called code, not the calling code? ... > called in which you pass in a method pointer to set values in the ...
    (comp.lang.pascal.delphi.misc)