MFC buttons Control (button)

Source: Internet
Author: User

Key methods and events for button controls see mfc++ Program Development Reference (P186-P188)
Here is an example of using buttons to display bitmaps, display icons, display mouse images, and select buttons in the following steps:
1. Create a dialog-based application
2. Add a Check button to the dialog box, a radio button control, and 5 button controls to add variables for the button control, M_button1, M_button2, M_button3, respectively.
3. Import an ICO icon into the factory. A BMP bitmap and a cur mouse image.
4. Implement button display bitmap function
void Cbuttondlg::onbutton1 ()
{
M_button1.modifystyle (0,BS_BITMAP); Setting the Bitmap property
M_button1.setbitmap (LoadBitmap (AfxGetInstanceHandle (),
Makeintresource (IDB_BITMAP1)); Set bitmap
}
5. Implement button Display icon function
void Cbuttondlg::onbutton2 ()
{
M_button2.modifystyle (0,bs_icon); Set the Icon property
M_button2.seticon (AfxGetApp ()->loadicon (Idi_icon1)); Set icon
}
6. Implement button display mouse function
void Cbuttondlg::onbutton3 ()
{
M_button3.modifystyle (0,bs_icon); Set the Icon property
M_button3.setcursor (AfxGetApp ()->loadcursor (Idc_cursor1)); Set Mouse image
}
7. Implement the Check button function
void Cbuttondlg::onbutton4 ()
{
cbutton* M_button = (cbutton*) GetDlgItem (IDC_CHECK1); To point the button pointer to a check button
M_button->setcheck (TRUE);//Make the Check button selected
M_button = (cbutton*) GetDlgItem (IDC_RADIO1);//Make button pointer point to radio button
M_button->setcheck (TRUE);//Make radio button selected
}
8. Uncheck Button function
void Cbuttondlg::onbutton5 ()
{
cbutton* M_button = (cbutton*) GetDlgItem (IDC_CHECK1);
M_button->setcheck (FALSE);
M_button = (cbutton*) GetDlgItem (IDC_RADIO1);
M_button->setcheck (FALSE);

}





MFC buttons Control (button)

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.