How can I simulate a button click given the handle to the button's window?

后端 未结 5 1185
星月不相逢
星月不相逢 2020-12-16 01:07

I want to simulate a click on a button located in a dialog box.

I have the handle to that window. This is an Abort/Retry/Ignore kind of window.

I don\'t wan

5条回答
  •  遥遥无期
    2020-12-16 01:14

    Send a BM_CLICK message to the HWND of the button:

    SendMessage(hButton, BM_CLICK, 0, 0);
    

    That causes the button to receive WM_LBUTTONDOWN and WM_LBUTTONUP messages, and the parent to receive an BN_CLICKED notification, as if the user had physically clicked on the button.

提交回复
热议问题