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 AS STRING, _
hwndParent AS HWND, _
hCtlID AS INTEGER, _
Xpos AS INTEGER, _
Ypos AS INTEGER _
[, Width AS INTEGER] _
[, Height AS INTEGER] _
[, Res AS INTEGER] _
[, WinStyle AS INTEGER] _
[, ExWinStyle AS INTEGER])
Parameters:
- Data type: STRING
BitmapFile File containing icon file(.ico)
to be loaded on button.
👉 This parameter is set as "" if the icon
is loaded from a resource in the Res
parameter.
- Data type: HWND
hwndParent The handle of the window that the
icon will be placed on
- Data type: INTEGER
hCtlID Specifies the child-window identifier
used to notify its parent about events.
- Data type: INTEGER
Xpos Horizontal placement of upper left
corner of icon
- Data type: INTEGER
Ypos Vertical placement of upper left corner
of icon
- Data type: INTEGER
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.
- Data type: INTEGER
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.
- Data type: INTEGER
Res [OPTIONAL]
parameter containing an integer value to an icon resource.
Res is used if the icon is to be retrieved
from a resource instead of the BitmapFile
parameter.
👉 The resource type must be ANICURSOR.
- Data type: INTEGER
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. For more information,
visit the Microsoft Static Control Styles webpage and the
Microsoft Window Styles webpage.
- Data type: INTEGER
ExWinStyle [OPTIONAL] The default window Extended Window Style for
a BCX_ICON control is 0. For more information, visit
the Microsoft Extended Window Styles webpage.
Return Value:
- Data type: HWND
hCtl The handle of the control containing
the icon. If the function fails, the return value is NULL.
👉 The returned handle is to the control
containing the icon bitmap; it is not a handle of the icon
bitmap.
|
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:
Here is an example program showing how to load, as a resource,
an animated icon.
Save the example code below as animicon.bas.
This example uses a copy of the Compass.Ani file from the
BCX\Gui_Demo\Ani-Icon directory.
Click here to download a .zip
containing compass.ani.
Extract it to the same directory as animicon.bas.
Save the following batch file, as Build.bat, into the same
directory as animicon.bas and run Build.bat to compile and run.
Build.bat Compilation Batch file:
CALL povars64.bat
bc animicon
animicon.bas
GUI "AnimIcon"
$IPRINT_OFF
$RESOURCE "$PELLES$\bin\porc.exe"
BCX_RESOURCE 1234 ANICURSOR "compass.ani"
$COMPILER "$PELLES$\Bin\pocc -W1 _
-Gd _
-Go _
-Ze _
-Zx _
-Tx64-coff _
$FILE$.c"
$LINKER "$PELLES$\Bin\polink _
-release _
-machine:X64 _
-subsystem:windows _
-OUT:$FILE$.exe _
$FILE$.obj _
$FILE$__.res"
DIM Form1 AS CONTROL
DIM Icons[25] AS CONTROL
SUB FORMLOAD
LOCAL x, y, i
Form1 = BCX_FORM("Animated Icons!", 0, 0, 158, 169)
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