Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
A button is an object that the user clicks to initiate an action. Button control is represented by CButton class.
Sr.No.
Name & Description
1
Create
Creates the Windows button control and attaches it to the CButton object.
2
DrawItem
Override to draw an owner-drawn CButton object.
3
GetBitmap
Retrieves the handle of the bitmap previously set with SetBitmap.
4
GetButtonStyle
Retrieves information about the button control style.
5
GetCheck
Retrieves the check state of a button control.
6
GetCursor
Retrieves the handle of the cursor image previously set with SetCursor.
7
GetIcon
Retrieves the handle of the icon previously set with SetIcon.
8
GetIdealSize
Retrieves the ideal size of the button control.
9
GetImageList
Retrieves the image list of the button control.
10
GetNote
Retrieves the note component of the current command link control.
11
GetNoteLength
Retrieves the length of the note text for the current command link control.
12
GetSplitGlyph
Retrieves the glyph associated with the current split button control.
13
GetSplitImageList
Retrieves the image list for the current split button control.
14
GetSplitInfo
Retrieves information that defines the current split button control.
15
GetSplitSize
Retrieves the bounding rectangle of the drop-down component of the current split button control.
16
GetSplitStyle
Retrieves the split button styles that define the current split button control.
17
GetState
Retrieves the check state, highlight state, and focus state of a button control.
18
GetTextMargin
Retrieves the text margin of the button control.
19
SetBitmap
Specifies a bitmap to be displayed on the button.
20
SetButtonStyle
Changes the style of a button.
21
SetCheck
Sets the check state of a button control.
22
SetCursor
Specifies a cursor image to be displayed on the button.
23
SetDropDownState
Sets the drop-down state of the current split button control.
24
SetIcon
Specifies an icon to be displayed on the button.
25
SetImageList
Sets the image list of the button control.
26
SetNote
Sets the note on the current command link control.
27
SetSplitGlyph
Associates a specified glyph with the current split button control.
28
SetSplitImageList
Associates an image list with the current split button control.
29
SetSplitInfo
Specifies information that defines the current split button control.
30
SetSplitSize
Sets the bounding rectangle of the drop-down component of the current split button control.
31
SetSplitStyle
Sets the style of the current split button control.
32
SetState
Sets the highlighting state of a button control.
33
SetTextMargin
Sets the text margin of the button control.
Here is the list of messages mapping for Button control −
Message
Map entry
Description
BN_CLICKED
ON_BN_CLICKED( <id>, <memberFxn> )
The framework calls this member function when the button is clicked.
BN_DISABLE
ON_BN_DISABLE( <id>, <memberFxn> )
The framework calls this member function when the button is disabled.
BN_DOUBLECLICKED
ON_BN_DOUBLECLICKED( <id>, <memberFxn> )
The framework calls this member function when the button is double clicked.
BN_PAINT
ON_BN_PAINT( <id>, <memberFxn> )
The framework calls this member function when an application makes a request to repaint a button.
Let us look into a simple example by dragging two buttons from the Toolbox.
Step 1 − Change the Caption from Start, Stop and ID to IDC_BUTTON_START, IDC_BUTTON_STOP for both buttons.
Step 2 − Let us add event handler for both buttons.
Step 3 − Here is an implementation of both events in which we will start and stop animation.
void CMFCAnimationDemoDlg::OnBnClickedButtonStart() {
// TODO: Add your control notification handler code here
m_animationCtrl.Open(L"res\\copyfile.avi");
}
void CMFCAnimationDemoDlg::OnBnClickedButtonStop() {
// TODO: Add your control notification handler code here
m_animationCtrl.Stop();
}
Step 4 − When the above code is compiled and executed, you will see the following output.
Step 5 − When you click the Stop button, the animation stops and when you press the Start button, it starts again.