Dynamically add an ATL Control

Source: Internet
Author: User

First, an ATL control must be added to generate the corresponding class.
1. contains header files.
# Include <atlctrls. h>
2. Define the resource ID
# Define idc_btn_play 6000
3. Define members in the class declaration.
Cbutton m_btnplay;
4. In the wm_create message
Rect RC1;
Rc1.left = 60;
Rc1.top = 0;
Rc1.bottom = rc1.top + 18;
Rc1.right = rc1.left + 50;
M_btnplaycreate (m_hwnd, & RC1, _ T ("stop"), ws_child | ws_visible, 0, idc_btn_play );
5. Define Click Event and message ing.
Message ing:
Begin_msg_map (cplayer)
Message_handler (wm_create, oncreate)
Command_handler (idc_btn_play, bn_clicked, onplay)
....
End_msg_map ()
Event functions:
Lresult onplay (word wnotifycode, word WID, hwnd hwndctl, bool & bhandled)
{
: MessageBox (m_hwnd, _ T ("Yes, play! "), _ T (" OK "), 0 );
Return 0;
}

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.