Hi,
I am trying to make a programatic call to a PictureBox.Click event. I have searched these forums with many different combinations of search terms, I even found an article that said this topic had been discussed several times - http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=961689&SiteID=1.
However I cannot find anything!
As said above I am trying to programatically call a PictureBox's Click event, what I've read so far seems to point to using SendMessage() which best I can tell is com interop with the compact framework but thats as far as i've got.
Any help you can give would be great.

SendMessage - button click
kc ppm
DoubleDangerBat
Hey Andrew,
Thanks for your replies so far.
I don't need to send a specific key stroke description as part of the click event... all I need is to simulate the click itself, the event args are pretty much irrelevant in this case, are there some straight forward articles relating to how you achieve this
Many Thanks
Michael Hansen
Hi,
It's my bad for not giving you full context on what it is I'm trying to do.
I have written a control that inherits from PictureBox (MyPictureBox).
I also have a form which I use as a base class for all of the forms in my application. This form base class has an array of MyPictureBox[] in it and assigns the same keyup event handler to each of them. This is absolutely fine, except for when the key pressed is the Enter button - or whatever you call the button inbetween the 4 arrow keys ;-) which needs a instance specific event handler - which is the same code as the click event.
So what i'm trying to do is programatically cause the click event from my generic keyup event handler.
I'm not sure that my explanation was all that clear, but I am sure I need to programatically simulate a mouse click.
DTHMTLGOD
*Update*
I have been able to simulate a click using mouse_event in a call to the coredll using the following code:
[
DllImport("coredll")]static extern bool SetCursorPos(int X, int Y);
[
DllImport("coredll")]static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[
Flags]public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
bool tempVal = SetCursorPos(x, y);
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
however I have one outstanding problem (that I know of!).
I am struggling to capture the corrext X and Y co-ordinates of the control. I have tried many different methods and they all return values of 0 for both axis.
How do you guys do it
Many Thanks
Blueforce
jortiz