Simulate button control bn_clicked message event

Source: Internet
Author: User

1. The existing dialog box is as follows:

Click the button to bring up the Hello message box, as shown in:

The following code simulates the click RESPONSE event when you click the button:

Void ctestdlg: onbnclickedbtntest ()

{

// Todo: add your control notification handler code here

Wparam;

Wparam = bn_clicked;

Wparam <= 16; // shifts 16 bits to the left

Wparam | = idc_btn_say_hello; // bitwise OR

Lparam;

Lparam = (lparam): getdlgitem (this-> getsafehwnd (), idc_btn_say_hello );

: Postmessage (this-> getsafehwnd (), wm_command, wparam, lparam );

}

In this way, the Hello message box will pop up when you click the button.

 

II. The following two dialogs are available: test.exeand hisin.exe.

Click the button to bring up the Hello message box, as shown in:

 

Click the button in the hisin dialog box to simulate the click event in the test dialog box. The implementation code is as follows:

Void chisindlg: onbnclickedbtntest ()

{

// Todo: add your control notification handler code here

Hwnd hwnddlgtest =: findwindow (null, text ("test "));

Hwnd hwndbtnsayhello =: find1_wex (hwnddlgtest, null, null, text ("Say hello "));

Wparam;

Wparam = bn_clicked;

Wparam <= 16; // shifts 16 bits to the left

Wparam | =: getdlgctrlid (hwndbtnsayhello );

Lparam;

Lparam = (lparam) hwndbtnsayhello;

: Postmessage (hwnddlgtest, wm_command, wparam, lparam );

}

In this way, clicking the button in the hisin dialog box will bring up the Hello message box in the test dialog box.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.