BCX_BITMAP function
Purpose: BCX_BITMAP creates a static control then loads a
bitmap from a file and displays the bitmap on the static
control.
Syntax:
hCtl = BCX_BITMAP(BitmapFile$, _
hWndParent, _
CtlID%, _
Xpos%, _
Ypos%, _
Width%, _
Height%, _
[,Res%] _
[,WinStyle%] _
[,ExWinStyle%])
Parameters:
- BitmapFile$ File containing bitmap to be loaded. If the
bitmap is to be loaded from a resource then this parameter must be
empty (""). Also, if a NULL image pointer is specified without
specifying a value for the Res% parameter, a HWND control will be
returned from the function but with no immediate image being
displayed. An image can be set into such a control at runtime using
the new BCX SET_BCX_BITMAP2 function.
- hWndParent Handle to the window on which the
control-bitmap will be placed.
- CtlID% Reference integer corresponding to hCtl
- Xpos% Horizontal placement of upper left corner of the
control-bitmap
- Ypos% Vertical placement of upper left corner of the
control-bitmap
- Width% Width of displayed bitmap. BCX_BITMAP will
autosize the bitmap to the size of the control if the Width% and
Height% parameters are both zero.
- Height% Height of displayed bitmap. BCX_BITMAP will
autosize the bitmap to the size of the control if the Width% and
Height% parameters are both zero.
- Res% [OPTIONAL] parameter
containing an integer value to a bitmap resource. Res% is used if
the bitmap file is to be retrieved as a resource.
- WinStyle% [OPTIONAL] If the
WinStyle% parameter is used, the default Window Style for a
BCX_BITMAP control, WS_CHILD | WS_VISIBLE | SS_BITMAP | 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_BITMAP control is 0.
See your Win32 SDK or PSDK Reference help for more information
about valid Extended Window Styles.
Return Value:
- hCtl is a handle to the static control containing the
bitmap, if the control was created. If the function fails, the
return value is NULL. Note well, that the returned
handle is to the static control containing the bitmap, and is not a
handle to the bitmap.
|
Example: The example below loads a bitmap from a resource
file.
Save the following as bcx_bitmap.bas.
GUI "BCX_BITMAP"
$RESOURCE "$PELLES$\bin\porc.exe"
$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 "
$ONEXIT "$FILE$.exe"
BCX_RESOURCE 500 BITMAP "bcx_bitmap.bmp"
SUB FORMLOAD
GLOBAL Form1 AS HWND
GLOBAL Bmp1 AS CONTROL
Form1 = BCX_FORM("BCX_BITMAP", 0, 0, 110, 110)
BCX_SET_FORM_COLOR(Form1,QBCOLOR(15))
Bmp1 = BCX_BITMAP("", Form1, 115, 2, 35, 0, 0, 500)
CENTER(Form1)
SHOW(Form1)
END SUB
BEGIN EVENTS
SELECT CASE CBMSG
CASE WM_CLOSE
IF MSGBOX("Are you sure?", "Quit Program!", MB_YESNO) = IDYES THEN
DestroyWindow(Form1)
END IF
EXIT FUNCTION
END SELECT
END EVENTS
Save the following bitmap as bcx_bitmap.bmp by
- right clicking on the image
- click copy in the menu
- paste the image from the clipboard into Paint or any other
graphics program which will allow pasting from the clipboard
- save as bcx_bitmap.bmp in the same folder as
bcx_bitmap.bas
At the command prompt type
bc bcx_bitmap
and the example will be translated, compiled and run.
Remarks: The default window Style for a BCX_BITMAP
control also can be changed by using the MODSTYLE function.
For an example of the BCX_BITMAP function see Demo.bas in the BCX\Gui_Demo\EZ_Gui
folder.