BCX_OLEPICTURE function

Purpose: BCX_OLEPICTURE loads and displays a BMP, GIF, JPG, WMF, EMF, or ICO image from a file or resource.


Syntax:

 hCtl = BCX_OLEPICTURE(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 control containing the image if the control was created. If the function fails, the return value is NULL.
    The returned handle is to the control containing the image; it is not a handle of the image.

Parameters:

  • Data type: STRING
    BitmapFile File containing image to be loaded on button. If the image is to be loaded from a resource then this parameter must be empty("").
  • Data type: HWND
    hwndParent The handle of the window that the button will be placed on
  • 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 button
  • Data type: INTEGER
    Ypos Vertical placement of upper left corner of button
  • Data type: INTEGER
    Width Currently not used.
  • Data type: INTEGER
    Height Currently not used.
  • Data type: INTEGER
    Res [OPTIONAL] parameter containing the integer value of an image resource. The Res% parameter is used if the image file 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_OLEPICTURE control, WS_CHILD | WS_VISIBLE | SS_BITMAP | 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_OLEPICTURE control is 0. For more information, visit the Microsoft Extended Window Styles webpage.

Remarks: When BCX_OLEPICTURE is invoked, the BCX_OLE_WIDTH and BCX_OLE_HEIGHT macros are defined. These macros allow the retrieval of the width and the height of the control containing the image loaded by the BCX_OLEPICTURE function.


 ImageWidth% = BCX_OLE_WIDTH(hCtl)

 ImageHeight% = BCX_OLE_HEIGHT(hCtl)

Example: The example below loads an image from a resource file.

Save the following resource file as BCX_OLEPICTURE.rc


 500 RCDATA "BCX_OLEPICTURE.jpg"

Save the following as BCX_OLEPICTURE.bas.


 GUI "BCX_OLEPICTURE"
 
 SUB FORMLOAD
   GLOBAL Form1 AS HWND
   GLOBAL Bmp1  AS CONTROL
   Form1 = BCX_FORM("BCX_OLEPICTURE", 0, 0, 140, 115)
   BCX_SET_FORM_COLOR(Form1,QBCOLOR(15))
   CENTER(Form1)
   SHOW(Form1)
   Bmp1 = BCX_OLEPICTURE("", Form1, 115, 15, 10, 0, 0, 500)
 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

Click here to download a .zip containing BCX_OLEPICTURE.jpg.

Extract it to the same directory as BCX_OLEPICTURE.bas.

Save the following snippet as build.bat, modifying the path as needed


 C:\dev\BCX\bin\bc.exe BCX_OLEPICTURE
 C:\dev\PellesC\bin\porc BCX_OLEPICTURE.rc
 C:\dev\PellesC\bin\pocc -W1 -Gd -Go -Ze -Zx -Tx86-coff BCX_OLEPICTURE.c
 C:\dev\PellesC\bin\polink -release -machine:ix86 -subsystem:windows -OUT:BCX_OLEPICTURE.exe BCX_OLEPICTURE.obj BCX_OLEPICTURE.res

Then run build.bat to build the BCX_OLEPICTURE.exe.

Remarks:

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

GUI_Demo.bas