A bit of reflection will get you there:-
using System.Reflection;
MethodInfo method = typeof(Control).GetMethod("OnClick",
BindingFlags.NonPublic | BindingFlags.Instance);
method.Invoke(button1, new object[]{EventArgs.Empty});
If you want to do this alot in your app then store the method info and reuse
it calling invoke with any button (or any class derived from Control).
mouse_event should also work, but the co-ordinate system requires you to
specify the co-ordinates in a scale from 0 to ffff in each direction. also
you'll need to call it twice once with left button down and again with a
left button up.
Peter
--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com |
http://blog.opennetcf.org/pfoot/
"Jared Miniman" <(E-Mail Removed)> wrote in message
news:u9H$(E-Mail Removed)...
> Seems like a simple scenario: I have a form with a single button. When
> the button has focus, and the user presses a hardware key, I want to
> invoke the button's onClick. In this baby case, I can just capture the
> KeyDown on the one button and manually call the onClick handler with null
> arguments (since I can look up in the code and find the button's OnClick
> delegate name).
>
> However, what if I want to do this across an application with hundreds of
> buttons? I have a component that, for each class, when a button has focus
> and a specific hardware key is KeyDown'ed on it, I trap that event.
> Great, I have the button's properties. I can't click it! I've tried
> P/Invoking mouse_event with the button's absolute coordinates, but it
> merely passes a WM_LBUTTONDN to the parent window, getting me no where.
> If I start using WM_COMMAND, then I assume I need a
> WindowsCE.Forms.MessageWindow object sitting inside each form, which I am
> trying to avoid.
>
> Perhaps the OpenNET folks have come up with something useful in this
> department. mouse_event is failing me . . .
>
> --
> _________________________________
> Jared Miniman
> Accenture Mobile Solutions Group
>
>