Help Center

CButton.SetImageListmethod

Assigns an image list to a button control.

WindowsmethodCButton.incdocumented

Syntax

FUNCTION SetImageList (BYVAL hButton AS HWND, BYVAL pbuttonImagelist AS BUTTON_IMAGELIST PTR) AS BOOLEAN
FUNCTION SetImageList (BYVAL hButton AS HWND, BYVAL himl AS HIMAGELIST, BYVAL nLeft AS LONG, BYVAL nTop AS LONG, BYVAL nRight AS LONG, BYVAL nBottom AS LONG, BYVAL uALign AS UINT = 0) AS BOOLEAN

Parameters

NameDescription
hButtonThe handle to the button control.
pbuttonImagelistA pointer to a BUTTON_IMAGELIST structure that contains image list information.
hButtonThe handle to the button control.
hImageListThe handle to the image list.
nLeftThe x-coordinate of the upper-left corner of the rectangle for the image.
nTopThe y-coordinate of the upper-left corner of the rectangle for the image.
nRightThe x-coordinate of the lower-right corner of the rectangle for the image.
nBottomThe y-coordinate of the lower-right corner of the rectangle for the image.
uAlignThe alignment to use. This parameter can be one of the following values:

Return value

If the message succeeds, it returns TRUE. Otherwise it returns FALSE.

Description

Assigns an image list to a button control.

The default value is BUTTON_IMAGELIST_ALIGN_LEFT.

Remarks

To use this message, you must provide a manifest specifying Comclt32.dll version 6.0.

The image list referred to in the himl member of the BUTTON_IMAGELIST structure should contain either a single image to be used for all states or individual images for each state. The following states are defined in vssym32.h. Note that PBS_STYLUSHOT is used only on tablet computers.

Each value is an index to the appropriate image in the image list. If only one image is present, it is used for all states. If the image list contains more than one image, each index corresponds to one state of the button. If an image is not provided for each state, nothing is drawn for those states without images.

Example

enum PUSHBUTTONSTATES {

PBS_NORMAL = 1,
PBS_HOT = 2,
PBS_PRESSED = 3,
PBS_DISABLED = 4,
PBS_DEFAULTED = 5,
PBS_STYLUSHOT = 6,

};

Reference

  • Include file CButton.inc
  • Defined in AfxNova/CButton.inc:207
  • Documented in Windows/WIndows Controls/CButton Class.md
  • Topic: CButton Class