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 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:
Parameters:
|
An image can be set into such a control at runtime using the SET_BCX_BITMAP2 function.
Save the example code below as bcx_bitmap.bas. The example will load, into a window, from a resource file, this bitmap:
Click here to download a .zip containing the bcx_bitmap.bmp resource.
Extract it to the same directory as bcx_bitmap.bas.
Save the following batch file, as Build.bat, into the same directory as bcx_bitmap.bas and run Build.bat to compile and run the example.
Build.bat Compilation Batch file:
CALL povars64.bat bc bcx_bitmap
bcx_bitmap.bas
GUI "BCX_BITMAP" $IPRINT_OFF $RESOURCE "$PELLES$\bin\porc.exe" $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" $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, 130, 115) BCX_SET_FORM_COLOR(Form1,QBCOLOR(15)) Bmp1 = BCX_BITMAP("", Form1, 115, 10, 10, 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
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.
SET_BCX_BITMAP complements the BCX_BITMAP function by allowing the bitmap image of a BCX_BITMAP control to be changed after the control has been created.
Syntax:SET_BCX_BITMAP(hBitmapDest AS HWND, _ BitmapFile AS STRING _ [, Res AS INTEGER] _ [, Width AS INTEGER] _ [, Height AS INTEGER]) Parameters:
|
The SET_BCX_BITMAP statement has been written so that either a file based bitmap or a resource based bitmap can be passed to the procedure. 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 bitmap resource handle is passed in Res and 0 is used as a parameter value for BitmapFile.
An example demonstrating the use of the SET_BCX_BITMAP is available in the Setbmp directory of the GUI_Demo.zip, downloadable from the BCX BASIC Forum post GUI Demos 2020 at https://bcxbasiccoders.com/smf/index.php?topic=390.0
SET_BCX_BITMAP2 complements the BCX_BITMAP function by allowing the image in a BCX_BITMAP control to be changed after the control has been created.
Syntax:SET_BCX_BITMAP2(hBitmapDest AS HWND, _ hBitmap AS HBITMAP _ Delete AS INTEGER]) Parameters:
|
BCX_LOADBMP function returns a handle to a bitmap (.bmp) image loaded from a file or loaded as a resource.
Syntax 1:MyhBmp = BCX_LOADBMP(FileName AS STRING _ 0 [, Transparent AS INTEGER]) Return Value:
Parameters: |
Syntax 2:MyhBmp = BCX_LOADBMP("", _ Resource AS INTEGER [, Transparent AS INTEGER]) Return Value:
Parameters: |
BCX_BMPHEIGHT function returns the height of a bitmap(.bmp) image.
Syntax:RetVal = BCX_BMPHEIGHT(hBmp AS HBITMAP) Return Value:
Parameters:
|
BCX_BMPWIDTH function returns the width of a bitmap (.bmp) image.
Syntax:RetVal = BCX_BMPWIDTH(hBmp AS HBITMAP) Return Value:
Parameters:
|
BCX_PUT puts a bitmap on a window.
Syntax:BCX_PUT(hwndDest AS HWND, _ hBmp AS HBITMAP, _ LeftDest AS INTEGER, _ TopDest AS INTEGER, _ WidthDest AS INTEGER, _ HeightDest AS INTEGER _ [, RopCode AS INTEGER] _ [, DrawHDC AS HDC]) Parameters:
|