CButton::SetCursor

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

HCURSOR SetCursor(
   HCURSOR hCursor 
);

Parameters

  • hCursor
    The handle of a cursor.

Return Value

The handle of a cursor previously associated with the button.

Remarks

The cursor will be automatically placed on the face of the button, centered by default. If the cursor 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, SetCursor uses only one cursor per the button. When the button is pressed, the cursor appears to shift down and to the right.

Example

CButton myIconButton;

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

// If no image is defined for the button, define the image to the
// system arrow and question mark cursor.
if (myIconButton.GetCursor() == NULL)
   myIconButton.SetCursor(::LoadCursor(NULL, IDC_HELP));

Requirements

Header: afxwin.h

See Also

Reference

CButton Class

Hierarchy Chart

CButton::GetCursor

CBitmapButton::LoadBitmaps

Bitmaps

Other Resources

CButton Members