DdfInitialize
This function initializes the IPF internal structures for dynamic data formatting and returns a DDF handle. The application uses this handle to refer to a particular DDF panel.
Syntax
DdfInitialize(hwndHelpInstance, cbBuffer, ulIncrement)
Parameters
- hwndHelpInstance (HWND) - input
- Handle of a help instance.
- cbBuffer (ULONG) - input
- Initial length of internal buffer where DDF information is to be stored. If this field is 0L, a default value of 1K is defined. The maximum value is 61,440 bytes (60KB).
- ulIncrement (ULONG) - input
- Amount by which to increment the buffer size, if necessary. If this field is NULL, a default value of 256 bytes is defined. The maximum value is 60KB.
Returns
- hddf (HDDF) - returns
- Handle to DDF.
- A handle to DDF is returned if initialization was successful. Otherwise, the value returned is NULL, indicating that an error has occurred because of insufficient memory or incorrect instance.
Remarks
At initialization, the default for dynamic data display is that text aligned on the left, and formatting is turned on.
Example Code
Declare:
#define INCL_DDF #include <os2.h> HWND hwndHelpInstance; /* Handle of a help instance. */ ULONG cbBuffer; /* Initial length of internal buffer. */ ULONG ulIncrement; /* Amount by which to increment the buffer size, if necessary. */ HDDF hddf; /* Handle to DDF. */ hddf = DdfInitialize(hwndHelpInstance, cbBuffer, ulIncrement);
This example shows how to initialize and use the Dynamic Data Facility for displaying an online document. Two functions are defined: the first, SampleObj, creates a window that will display the online information and specifies the second function, SampleWindowProc, as the corresponding window procedure. These two functions are compiled into a DLL and exported, so that IPF can invoke them when it encounters the :ddf and :acviewport tags during execution. The :acviewport tag will specify the DLL name and the SampleObj function; when IPF calls SampleObj, it initializes an application-controlled window with SampleWindowProc as the window procedure and returns the window handle. Later, when IPF encounters the :ddf tag, it will send SampleWindowProc an HM_QUERY_DDF_DATA message. At this point, before calling any of the DDF API, DdfInitialize must first be called to initiate a DDF buffer, after which the other DDF API can be called to display the online information.
#define INCL_WINWINDOWMGR /* General window management */ #define INCL_WINMESSAGEMGR /* Message management */ #define INCL_WINDIALOGS /* Dialog boxes */ #define INCL_DDF /* Dynamic Data Facility */ #define INCL_32 #include <os2.h> #include <pmhelp.h> #define COM_HWND 4 /* window word offsets */ #define PAGE_HWND 8 #define ACVP_HAB 12 USHORT DdfClass = FALSE; MRESULT EXPENTRY SampleWindowProc(HWND hWnd, ULONG Message, MPARAM lParam1, MPARAM lParam2); USHORT APIENTRY SampleObj(PACVP pACVP, PCH Parameter) { HWND DdfHwnd; /* Client window handle */ HWND DdfCHwnd; /* Child window handle */ HWND PreviousHwnd; /* Handle for setting comm window active */ /* register DDF Base class if not registered already */ if (!DdfClass) { if (!WinRegisterClass( pACVP->hAB, /* Anchor block handle */ "CLASS_Ddf", /* Application window class name */ SampleWindowProc,/* Address of window procedure */ CS_SYNCPAINT | /* Window class style */ CS_SIZEREDRAW | CS_MOVENOTIFY, 20)) /* Extra storage */ { return TRUE; } DdfClass = TRUE; } /* create standard window */ if (!(DdfHwnd = WinCreateStdWindow( pACVP->hWndParent, /* ACVP is parent */ 0L, /* No class style */ NULL, /* Frame control flag */ "CLASS_Ddf", /* Window class name */ NULL, /* No title bar */ 0L, /* No special style */ 0L, /* Resource in .EXE */ 0, /* No window identifier */ &DdfCHwnd ))) /* Client window handle */ { return FALSE; } /* store the frame window handle in ACVP data structure */ pACVP->hWndACVP = DdfHwnd; /* set this window as active communication window */ PreviousHwnd = (HWND)WinSendMsg(pACVP->hWndParent, HM_SET_OBJCOM_WINDOW, MPFROMHWND(DdfHwnd), NULL); /* save returned communication hwnd in reserved word */ WinSetWindowULong(DdfCHwnd, COM_HWND, (ULONG)PreviousHwnd); /* save anchor block handle in reserved word */ WinSetWindowULong (DdfCHwnd, ACVP_HAB, (ULONG)pACVP->hAB); return FALSE; } /* SampleObj */ MRESULT EXPENTRY SampleWindowProc(HWND hWnd, ULONG Message, MPARAM lParam1, MPARAM lParam2) { HWND hwndParent; /* parent window */ HWND hwndHelpInstance; /* help instance window */ HDDF hDdf; /* DDF handle */ ULONG DdfID; /* DDF resource id */ switch (Message) { case HM_QUERY_DDF_DATA: WinSetWindowULong(hWnd, PAGE_HWND, LONGFROMMP(lParam1)); DdfID = LONGFROMMP(lParam2); hwndParent = WinQueryWindow(hWnd, QW_PARENT); hwndParent = WinQueryWindow(hwndParent, QW_PARENT); hwndHelpInstance = (HWND)WinSendMsg(hwndParent, HM_QUERY, MPFROMSHORT(HMQW_INSTANCE), NULL); /* Allocate 1K Buffer (default) */ hDdf = DdfInitialize( hwndHelpInstance, /* Handle of help instance */ 0L, /* Default buffer size */ 0L /* Default increment */ ); if (hDdf == NULLHANDLE) /* Check return code */ { return (MRESULT)FALSE; } return (MRESULT)hDdf; default: return (WinDefWindowProc(hWnd, Message, lParam1, lParam2)); } } /* SampleWindowProc */