You can load a bit map from a file if the format of the file corresponds to the standard IBM OS/2 bit-map file format. (Any bit map that you create with the Icon Editor is automatically stored in this format.) To load a bit map:

You can actually include your bit map in the application's .EXE file or in a separate resource file. If the bit map is included in a separate resource file, you must specify both the resource ID and the ID of the bit map within the resource file on GpiLoadBitmap. If bit map is to be included in the application's .EXE file, the resource ID is specified as NULL and only the ID of the bit map is required by GpiLoadBitmap.

Following is an example of code from an application's resource file that assigns the integer value 200 to a bit-map file called CUSTOM.BMP.

    BITMAP  200 CUSTOM.BMP

The following figure is an example of code from the application that shows how to retrieve a bit-map handle by calling GpiLoadBitmap, use the handle to tag the bit map by calling GpiSetBitmapId, and then use the local identifier supplied by GpiSetBitmapId to set the bit map as the current fill pattern, using GpiSetPatternSet.

    HPS hps;
    HBITMAP hbm;
    LONG lcidCustom = 1;
    POINTL ptl;

    hbm = GpiLoadBitmap(hps,  /* Presentation-space handle        */
        NULLHANDLE,           /* Resource in application's module */
        IDB_PATTERN,          /* Bit-map ID                       */
        16,                   /* Bit-map width                    */
        16);                  /* Bit-map height                   */

    /* Assign a local identifier to the bit map.                  */
    GpiSetBitmapId(hps, hbm, lcidCustom);

    /* Set the pattern-set attribute in the AREABUNDLE structure. */
    GpiSetPatternSet(hps, lcidCustom);

    ptl.x = 100;
    ptl.y = 100;
    GpiMove(hps, &ptl);
    ptl.x = 200;
    ptl.y = 200;
    GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);


[Back] [Next]