BCX_BMPBUTTON function

Purpose:

BCX_BMPBUTTON creates a push button displaying a file based bitmap or, optionally, a resource based bitmap. Clicking on the button with a mouse will post a WM_COMMAND message to the owner window.

Syntax:

hCtl = BCX_BMPBUTTON(BitmapFile AS STRING, _
                       hwndParent AS HWND, _
                         CtlID AS INTEGER, _
                          Xpos AS INTEGER, _
                          Ypos AS INTEGER, _
                         Width AS INTEGER, _
                        Height AS INTEGER  _
                        [, Res AS INTEGER] _
                   [, WinStyle AS INTEGER] _
                 [, ExWinStyle AS INTEGER])

Return Value:

  • Data type: HWND
    hCtl The handle of the push button, if the function succeeds. If the function fails, the return value is NULL.

Parameters:

  • Data type: STRING
    BitmapFile File containing bitmap to be loaded on pushbutton if the bitmap is to be retrieved from a file. If the bitmap is to be retrieved from a resource then this parameter is NULL("").
  • Data type: HWND
    hwndParent The handle of the window on which the button will be placed
  • Data type: INTEGER
    CtlID Specifies the child-window identifier used to notify its parent about events.
  • Data type: INTEGER
    Xpos Horizontal placement of upper left corner of pushbutton
  • Data type: INTEGER
    Ypos Vertical placement of upper left corner of pushbutton
  • Data type: INTEGER
    Width Width of pushbutton.
  • Data type: INTEGER
    Height Height of pushbutton.
  • Data type: INTEGER
    Res [OPTIONAL] The resource identifier of a bitmap, used if the bitmap is to be retrieved from a resource.
  • Data type: INTEGER
    WinStyle [OPTIONAL] If the WinStyle parameter is used, the default Window Style for a BCX_BMPBUTTON control, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_BITMAP, is replaced with the value in WinStyle. For more information, visit the Microsoft Button Control Styles webpage and the Microsoft Window Styles webpage.
  • Data type: INTEGER
    ExWinStyle [OPTIONAL] The default window Extended Window Style for a BCX_BMPBUTTON control is 0. For more information, visit the Microsoft Extended Window Styles webpage.

Remarks:

👉 BCX_BMPBUTTON will autosize to the size of the bitmap if the Width and Height parameters are both set to zero.

The default window Style for a BCX_BMPBUTTON control also can be changed by using the MODSTYLE function.


SET_BCX_BMPBUTTON statement

Purpose:

SET_BCX_BMPBUTTON complements the BCX_BMPBUTTON function by allowing a change to be made to the bitmap image of a BCX_BMPBUTTON after the button has been created.

Syntax:

SET_BCX_BMPBUTTON(hwnd AS HWND, _
          BitmapFile AS STRING _
             [, Res AS INTEGER])

Parameters:

  • Data type: HWND
    The handle of the button created with BCX_BMPBUTTON.
  • Data type: STRING
    BitmapFile The file from which the bitmap will be retrieved. BitmapFile is set to 0 if the bitmap image is to be retrieved as a resource.
  • Data type: INTEGER
    Res [OPTIONAL] The resource identifier of a bitmap, used if the bitmap image is to be retrieved as a resource.

Remarks:

The subroutine has been written so that either a file based bitmap or a resource based bitmap can be passed to the subroutine. The default setting for the optional parameter Res is 0 which means that the bitmap will be retrieved from the file specified in BitmapFile. If the bitmap is to be retrieved from a resource then the integer value of the resource handle is passed in Res and 0 is used as a parameter value for BitmapFile.

To load a resource based bitmap

SET_BCX_BMPBUTTON(ButtonHandle, 0, Res)

To load a file based bitmap

SET_BCX_BMPBUTTON(ButtonHandle, BitmapFile)