This operation accepts a filename and returns a handle to an IPictureDisp object. This is similar to the Visual Basic LoadPicture function. You must use the acuclass.def file to obtain the definition of the IPictureDisp object.
An IPictureDisp object uses the IPictureDisp interface to expose its properties through Automation. It provides a subset of the functionality available through IPicture methods. For more information, go to: msdn.microsoft.com/library and search for IPictureDisp and/or IPicture.
The following image formats are supported:
Bitmaps & device independent bitmaps (DIB) | .bmp |
Graphics Interchange Format | .gif |
Icons | .ico |
Joint Photographic Experts Group (JPEG) | .jpg |
Portable Network Graphic (PNG) | .png |
Tagged Image File Format (TIFF) | .tif, .tff, or .tiff |
Windows MetaFile | .wmf |
This operation takes one parameter:
name | This required alphanumeric literal is the name of the file you want to load. The filename must include an absolute path. The length of name (including path) should not exceed 90 characters. |
The IPictureDisp handle will not accept negative values. If an error (a negative value) is returned, you must use a REDEFINES, or move the value to a signed numeric variable, in order to read the error code. See Example 3 below.
If the value of BITMAP-HANDLE is 0 or negative, an error has occurred. These errors are defined in acugui.def.
The following example shows the first two op-codes in use. After the example, the parameters are described. For an example of the WBITMAP-LOAD operation, see Example 3.
Notice the two calls to W$BITMAP in the sample code. First, W$BITMAP displays a logo, then uses the DISPLAY verb to place two lines of text on the screen. The second call to W$BITMAP removes the logo from the screen and releases the memory it occupies.
* Displays the logo for 2 seconds. display window, line 7, column 26, lines 9, size 30, color black + bckgrnd-white, erase, shadow, no scroll, pop-up area is window-1. * Now give the name of the bitmap file and * the row and column of the upper left corner: call "w$bitmap" using wbitmap-display, "sample/acucob85.bmp", 2, 5. * Save the handle so it is available when needed * to remove the image: move return-code to bitmap-handle. * Check to make sure the logo file was found and * that no error occurred: if bitmap-handle <= zero close window window-1 else display "Copyright (c) 1985 - 2000", line 7, size 30, centered display "Acucorp, Inc.", line 8, size 30, centered accept single-char, auto, before time 200 end-if close window window-1 * Remove the bitmapped image and release the * memory it uses: call "w$bitmap" using wbitmap-destroy, bitmap-handle.
Following are several examples of different W$BITMAP calls to capture screen shots and desktop images:
* This call captures the standard active window as a file * named "myfile.bmp" call "W$BITMAP" using WBITMAP-CAPTURE-IMAGE "myfile.bmp". * This call captures the standard active window onto * the Windows clipboard call "W$BITMAP" using WBITMAP-CAPTURE-IMAGE " ". * This call captures the client area of the active * window as a file named "myfile.bmp" using 8-bit color call "W$BITMAP" using WBITMAP-CAPTURE-IMAGE "myfile.bmp" 0 1 8. * This call captures the indicated window handle using 16-bit * color and saves it as a file named "myfile.bmp" inquire mycontrol system handle in hWND call "W$BITMAP" using WBITMAP-CAPTURE-IMAGE "myfile.bmp" hWND 0 16. * This call captures the entire desktop as a file named * "myfile.bmp" using 32-bit color call "W$BITMAP" using WBITMAP-CAPTURE-DESKTOP "myfile.bmp" 32. * This call captures the current bitmap content of the Windows * clipboard as a file named "myfile.bmp" call "W$BITMAP" using WBITMAP-CAPTURE-CLIPBOARD "myfile.bmp".
The following sample program calls W$BITMAP to load an IPicture object.
... SPECIAL-NAMES. COPY "acuclass.def". . WORKING-STORAGE SECTION. COPY "acugui.def". 77 myIPictureDisp HANDLE OF IPictureDisp. 77 myErrorTest REDEFINES myIPictureDisp PIC S9(9) COMP-5. ... PROCEDURE DIVISION. MAIN-001. CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE "C:\MyDir\MyBitmaps.bmp" GIVING myIPictureDisp. EVALUATE myErrorTest WHEN WBERR-FILE-ERROR DISPLAY MESSAGE BOX "File not found" TITLE "Error" INITIALIZE myIPictureDisp WHEN WBERR-FORMAT-UNSUPPORTED DISPLAY MESSAGE BOX "Format not supported" TITLE "Error" INITIALIZE myIPictureDisp WHEN OTHER DISPLAY MESSAGE BOX "File successfully loaded" TITLE "Success" END-EVALUATE. DESTROY myIPictureDisp. GOBACK.