Learn MFC process by writing Serial port Helper Tool--(v) Add checkbox check box

Source: Internet
Author: User
Tags local time

learn the MFC process by writing a Serial port helper tool

Because it has been done several times MFC programming, each time the project is completed, MFC basic operation is clear, but too long time no longer contact with MFC project, again do MFC project, but also from the beginning familiar. This time by doing a serial assistant once again familiar with MFC, and made a record, in order to facilitate later access. The process of doing more is encountered problems directly Baidu and Google search, so many are superficial understanding, know it does not know why. In addition to do this tool just to get familiar with, many features are not perfect! (development tool VS2008)

(v) Add checkbox check box

Properties: Caption is used to display text content.

To add a control, modify the property ID, and add the variable part slightly, see Press the button section.

1,the basic function of checkbox:

Check1. Getcheck ();

The most function of check box is to determine if the status is selected. When you select with the mouse, the box will tick.

Cbutton::getcheck
int Getcheck () const;
return value:
For buttons built with Bs_autocheckbox, Bs_autoradiobutton, Bs_auto3state, Bs_checkbox, Bs_radiobutton, or bs_3state styles, the return value is one of the following:

Value

Meaning

0

button is unchecked

1

Button is selected

2

The button state is variable (only if the button style is bs_3state or bs_auto3state) if the button is in a different style, it returns 0.

Description: This function is used to detect the selected state of a radio button or check box.

Cbutton::setcheck
void SetCheck (int ncheck);
Parameters:

Ncheck

Specifies the selected state of the button control. The possible values are as follows:

Value

Meaning

0

Set the button to unchecked

1

Set the button to the selected state

2

Set the button to an indeterminate state. Valid only if the style of the button is Bs_3state or bs_auto3state

Description
This function is used to set or reset the state of the radio button and check boxes. It has no effect on the normal buttons.

As can be seen from the above two functions, radio button and checkboxes are also considered as one of the buttons.

(2) implement special functions: check box to achieve similar radio function (can not choose or only one of them)

Implementation method: When a check box is selected, the other check boxes are set to the unchecked state.

In the resource view, double-click the check box in the dialog box to create the click Message Type onbnclicked, and create these two message types and response event functions for the two check boxes that will implement this function

Time stamp check box action when local time check box is not available

void Cserialtestdlg::onbnclickedchecktimestamp ()

{

TODO: Add control notification Handler code here

if (M_combotimestamp.getcheck ())//Determine if the current state is selected

{

M_combolocaltime.enablewindow (FALSE); To make the control fail

M_combolocaltime.setcheck (0); Indicates that the setting check box is "unchecked";

}

Else

{

M_combolocaltime.enablewindow (TRUE);

}

}

Local check box operation time stamp check box is not available

void Cserialtestdlg::onbnclickedchecklocaltime ()

{

TODO: Add control notification Handler code here

if (M_combolocaltime.getcheck ())

{

M_combotimestamp.enablewindow (FALSE); To make the control fail

M_combotimestamp.setcheck (0); Indicates that the setting check box is "unchecked";

}

Else

{

M_combotimestamp.enablewindow (TRUE);

}

}

The implementation method mainly uses Getcheck () and SetCheck () to get the check box state and set the check box state function two functions.

Learn MFC process by writing Serial port Helper Tool--(v) Add checkbox check 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.