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$, _
                         hWndParent, _
                             CtlID%, _
                              Xpos%, _
                              Ypos%, _
                             Width%, _
                            Height%, _
                             [,Res%] _
                        [,WinStyle%] _
                      [,ExWinStyle%])

 Parameters:

  • hCtl If the control was created, the return value is the handle to the control containing the image. Note well, that the returned handle is to the control containing the image, and not a handle to the image. If the function fails, the return value is NULL.
  • 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("").
  • hWndParent Handle to the window that the button will be placed on
  • CtlID% Reference integer corresponding to hCtl
  • Xpos% Horizontal placement of upper left corner of button
  • Ypos% Vertical placement of upper left corner of button
  • Width% Currently not used.
  • Height% Currently not used.
  • 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.
  • 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%. 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_OLEPICTURE control is 0. See your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles.

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 as the resource file 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, 110, 110)
    BCX_SET_FORM_COLOR(Form1,QBCOLOR(15))
    CENTER(Form1)
    SHOW(Form1)
    Bmp1 = BCX_OLEPICTURE("", Form1, 115, 2, 35, 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

Save the following image as BCX_OLEPICTURE.jpg by

  1. right clicking on the image
  2. click copy in the menu
  3. paste the image from the clipboard into Paint or any other graphics program which will allow pasting from the clipboard
  4. save as BCX_OLEPICTURE.jpg in the same folder as BCX_OLEPICTURE.rc

Save the following and run as build BCX_OLEPICTURE.bat.


 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

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

GUI_Demo.bas