Поделиться через


CButton::SetIcon

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

HICON SetIcon(
   HICON hIcon 
);

Параметры

  • hIcon
    The handle of an icon.

Возвращаемое значение

The handle of an icon previously associated 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:

  • BS_TOP

  • BS_LEFT

  • BS_RIGHT

  • BS_CENTER

  • BS_BOTTOM

  • BS_VCENTER

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.

Пример

CButton myIconButton2;

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

// If no icon is defined for the button, define the icon to the
// system error icon.
if (myIconButton2.GetIcon() == NULL)
   myIconButton2.SetIcon(::LoadIcon(NULL, IDI_ERROR));

Требования

Header: afxwin.h

См. также

Основные понятия

CButton Class

CButton Members

Hierarchy Chart

CButton::GetIcon

CBitmapButton::LoadBitmaps

Bitmaps