Click here to Skip to main content
15,881,938 members
Articles / Mobile Apps
Tip/Trick

correct simulate OnClick-Event on every Control in .NET Compact Framework

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
25 Aug 2010CPOL 12.1K   4   1
.NET Compact Framework
Your search ends here...

Here is the correct Source to simulate an OnClick-Event on every Control in .NET Compact Framework.


[DllImport("coredll")]
        private static extern void SendMessage(IntPtr hWnd, int msg, int wparam, int lparam);
        const int WM_LBUTTONDOWN = 0x201;
        const int WM_LBUTTONUP = 0x202;
        public void PerformClick(System.Windows.Forms.Control control)
        {
            SendMessage(control.Handle, WM_LBUTTONDOWN, 0, 0);
            control.Update();
            System.Threading.Thread.Sleep(100);
            SendMessage(control.Handle, WM_LBUTTONUP, 0, 0);
        }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionWebBrowser Pin
EduardoDW14-Oct-14 8:37
EduardoDW14-Oct-14 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.