DdfBitmap
Appearance
This function places a reference to a bitmap in the DDF buffer.
Syntax
DdfBitmap(hddf, hbm, fAlign)
Parameters
- hddf (HDDF) - input
- Handle to DDF returned by DdfInitialize.
- hbm (HBITMAP) - input
- Standard Presentation Manager bitmap handle.
- fAlign (ULONG) - input
- Text justification flag.
- Any of the following values can be specified:
- ART_LEFT: Left-justify the bitmap.
- ART_RIGHT: Right-justify the bitmap.
- ART_CENTER: Center the bitmap.
- ART_RUNIN: Allow the bitmap to be reflowed with text.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE indicates successful completion.
- FALSE indicates an error occurred.
Remarks
The handle to the presentation space in which the bitmap was created cannot be freed by the application while the panel is displayed.
Note: There is a (3-byte + size of HBITMAP structure) ESC code overhead in the DDF internal buffer for this function. There is a 1-byte ESC code overhead required for the fAlign flag.
Errors
Possible returns from WinGetLastError:
- HMERR_DDF_MEMORY (0x3001): Not enough memory is available.
- HMERR_DDF_ALIGN_TYPE (0x3002): The alignment type is not valid.
Example Code
Declare:
#define INCL_DDF #include <os2.h> HDDF hddf; /* Handle to DDF returned by DdfInitialize. */ HBITMAP hbm; /* Standard Presentation Manager bitmap handle. */ ULONG fAlign; /* Text justification flag. */ BOOL rc; /* Success indicator. */ rc = DdfBitmap(hddf, hbm, fAlign);
This example uses DdfBitmap to place a reference to a bitmap in the DDF buffer after initializing a DDF buffer with DdfInitialize.
#define INCL_WINWINDOWMGR /* General window management */ #define INCL_WINMESSAGEMGR /* Message management */ #define INCL_GPICONTROL /* Basic PS control */ #define INCL_GPIBITMAPS /* Bitmaps and Pel Operations */ #define INCL_GPIPRIMITIVES /* Drawing Primitives/Attributes */ #define INCL_DDF /* Dynamic Data Facility */ #include <os2.h> #include <pmhelp.h> #define ACVP_HAB 12 #define BM_HPS 16 #define BM_HDC 20 #define BM_HWND 24 #define ID_LEFT 255 MRESULT WindowProc( HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2 ) { HWND hwndParent; /* parent window */ HWND hwndInstance; /* help instance window */ HDDF hDdf; /* DDF handle */ HDC hdc; /* device context handle */ HPS hps; /* presentation space handle */ HAB hab; /* anchor block handle */ SIZEL sizel = {0L,0L};/* size of new PS */ HBITMAP hBitmap; /* bitmap handle */ HMODULE hModule; /* module handle */ switch( ulMsg ) { case HM_QUERY_DDF_DATA: hwndParent = WinQueryWindow( hwnd, QW_PARENT ); hwndParent = WinQueryWindow( hwndParent, QW_PARENT ); hwndInstance = (HWND)WinSendMsg( hwndParent, HM_QUERY, MPFROMSHORT( HMQW_INSTANCE ), NULL ); /* Allocate 1K Buffer (default) */ hDdf = DdfInitialize( hwndInstance, /* Handle of help instance */ 0L, /* Default buffer size */ 0L /* Default increment */ ); if (hDdf == NULLHANDLE) /* Check return code */ { return (MRESULT)FALSE; } /* get module handle for bitmap */ DosQueryModuleHandle("bitmap", &hModule); if (hModule == NULLHANDLE) { return (MRESULT)FALSE; } /* get hab for this window */ if ((hab = (HAB)WinQueryWindowULong(hwnd, ACVP_HAB)) == NULLHANDLE) { return (MRESULT)FALSE; } /* create a device context */ if ((hdc = DevOpenDC(hab, OD_MEMORY, "*", 0L, (PDEVOPENDATA)NULL, (HDC)NULL)) == NULLHANDLE) { return (MRESULT)FALSE; } /* save hdc in reserved word */ WinSetWindowULong(hwnd, BM_HDC, (ULONG)hdc); /* create a noncached micro presentation space */ /* and associate it with the window */ if ((hps = GpiCreatePS(hab, hdc, &sizel, PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC)) == NULLHANDLE) { return (MRESULT)FALSE; } /* save hps in reserved word */ WinSetWindowULong(hwnd, BM_HPS, (ULONG)hps); /* Load the Bitmap to display */ if ((hBitmap = GpiLoadBitmap(hps, hModule, ID_LEFT, 300L, 300L)) == NULLHANDLE) { return (MRESULT)FALSE; } /* save bitmap hwnd in reserved word */ WinSetWindowULong(hwnd, BM_HWND, (ULONG)hBitmap); /* Display the bitmap align left */ if (!DdfBitmap(hDdf, hBitmap, ART_LEFT)) { return (MRESULT)FALSE; } return (MRESULT)hDdf; case WM_CLOSE: /* release PS, DC, and bitmap */ GpiDestroyPS((HPS)WinQueryWindowULong(hwnd, BM_HPS)); DevCloseDC((HDC)WinQueryWindowULong(hwnd, BM_HDC)); GpiDeleteBitmap((HBITMAP)WinQueryWindowULong(hwnd, BM_HWND)); WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); return (MRESULT)TRUE; } }