CButton::SetIcon

HICON SetIcon( HICON hIcon );

Return Value

The handle of an icon previously associated with the button.

Parameters

hIcon

The handle of an icon.

Remarks

Call this member function to associate a new icon with the button.

The icon will be automatically placed on the face of the button, centered by default.  If the icon is too large for the button, it will be clipped on either side. You can choose other alignment options, including the following:

Unlike CBitmapButton, which uses four bitmaps per button, SetIcon uses only one icon per the button. When the button is pressed, the icon appears to shift down and to the right.

Example

CButton myButton;

// Create an icon button.
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON, 
   CRect(10,10,60,50), pParentWnd, 1);

// Set the icon of the button to be the system question mark icon.
myButton.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) ); 

CButton OverviewClass MembersHierarchy Chart

See Also   CButton::GetIcon, CBitmapButton::LoadBitmaps, Bitmaps