BCX_ICON function

Purpose: BCX_ICON loads an icon from a file or resource and displays the image on a static control on the Parent window.


 Syntax:

 hCtl = BCX_ICON(BitmapFile$, _
                  Parent_hWnd, _
                          id%, _
                        Xpos%, _
                           Y%  _
                    [ ,Width%] _
                   [ ,Height%] _
                      [ ,Res%] _
                 [ ,WinStyle%] _
               [, ExWinStyle%])

 Parameters:

  • hCtlIf the icon static control was created, the return value is the handle to the control containing the icon. Note well, that the returned handle is to the control containing the bitmap, and not a handle to the icon. If the function fails, the return value is NULL.
  • BitmapFile$ File containing icon file(.ico) to be loaded on button
  • Parent_hWnd Handle to the window that the icon will be placed on
  • hCtlID% Reference integer corresponding to hCtl
  • Xpos% Horizontal placement of upper left corner of icon
  • Ypos% Vertical placement of upper left corner of icon
  • Width% Sets the width of the displayed icon. If Width% is not used, this parameter must be set to 0 if any of Res% or WinStyle% or ExWinStyle% is used.
  • Height% Sets the height of the displayed icon. If Height% is not used, this parameter must be set to 0 if any of Res% or WinStyle% or ExWinStyle% is used.
  • Res% [OPTIONAL] parameter containing an integer value to an icon resource. Res% is used if the icon is to be retrieved from a resource.
  • WinStyle% [OPTIONAL] If the WinStyle% parameter is used, the default Window Style for a BCX_ICON control, WS_CHILD | WS_VISIBLE | SS_ICON | WS_TABSTOP, is replaced with the value in WinStyle%. See your Win32 SDK or PSDK Reference help for more information about valid Window Styles.
  • ExWinStyle% [OPTIONAL] The default window Extended Window Style for a BCX_ICON control is 0. See your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles.

Result: If the control was created, the return value is the handle to the new control. If the function fails, the return value is NULL.

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

The syntax for animated cursors in the .rc file should be written as:


 1234 ANICURSOR "FileName.ani"

Example: Windows XP only! Windows 98 will not load an animated icon as a resource. Here is an example program showing how to load, as a resource, an animated icon. This example uses the Compass.ani file from the BCX\Gui_Demo\Ani-Icon folder. Note well that the resource type must be ANICURSOR.


 GUI  "AnimIcon"
 
 $RESOURCE "$PELLES$\bin\porc.exe"

 BCX_RESOURCE 1234 ANICURSOR "Compass.ani" 

 $COMPILER "$PELLES$\Bin\pocc -W1 _
                               -Gd _
                               -Go _
                               -Ze _
                               -Zx _
                        -Tx86-coff _
                          $FILE$.c"

 $LINKER "$PELLES$\Bin\polink _
                     -release _
                -machine:ix86 _
           -subsystem:windows _
              -OUT:$FILE$.exe _
                   $FILE$.obj "
  
 DIM  Form1     AS CONTROL
 DIM  Icons[25] AS CONTROL
  
 SUB FORMLOAD
 LOCAL x,y,i
 Form1 = BCX_FORM("Animated Icons!", 0, 0, 150, 150)
 FOR x = 0 TO 4
 FOR y = 0 TO 4
   Icons[i] = BCX_ICON("", _
                     Form1, _
                       100, _
                    x * 30, _
                    y * 30, _
                         0, _
                         0, _
                      1234)
    INCR i
 NEXT
 NEXT
 CENTER(Form1)
 SHOW  (Form1)
 END SUB
  
  
 BEGIN EVENTS
 END EVENTS