Button click in sendmessage API

北慕城南 提交于 2020-01-04 05:16:14

问题


How can I simulate a button click in the sendmessage API in C#?


回答1:


C code:

#include <Windows.h>
//...
SendMessage(hWndButton, BM_CLICK, 0, 0);

C# code:

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

...
Button myButton = ...;
const int BM_CLICK = 0x00F5;
SendMessage(myButton.Handle, BM_CLICK, IntPtr.Zero, IntPtr.Zero);

But be aware that, in C#, you can just as easily do:

myButton.PerformClick();


来源:https://stackoverflow.com/questions/4665463/button-click-in-sendmessage-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!