If a communication object that was added to the chain before your communication object removes itself from the chain, your communication object must respond to keep the chain intact.
This involves several steps:
a.
However, if these handles are identical, your communication object has a new "neighbor" in the chain, and should begin passing all HM_ help manager messages to the object identified by the handle returned as the first parameter of HM_UPDATE_OBJCOM_WINDOW_CHAIN.
The following code fragment illustrates this process.
#define INCL_WIN#define INCL_WINHELP #include <os2.h> #define HM_MSG_MAX (HM_MSG_BASE+0x0024) USHORT IPFClassRegistered = 0; /* IPF class registered flag */ /* Window procedure */ MRESULT EXPENTRY IPFWinProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2); MRESULT EXPENTRY IPFWinProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) /* The window procedure will handle deleting ourselves from the chain as well as forwarding all standard IPF message on the the next window in the chain */ { HWND hwndPrevious, hwndLatest; /* Get previous comm obj */ hwndPrevious = (HWND) WinQueryWindowULong (hwnd, QWL_USER); /* Handle the messages you want here, but do not return unless you now the message will not need to be handled by another comm obj. Let the the message be forwarded on to the next comm obj. The only exception to this is if you change the cover page size. You need to return TRUE to prevent the coverpage from being resized. */ switch (msg) { case HM_UPDATE_OBJCOM_WINDOW_CHAIN: /* If another window is being inserted, replace previous with it */ if (hwndPrevious == (HWND)mp1) { hwndPrevious = (HWND)mp2; if (!WinSetWindowULong (hwnd, QWL_USER, (ULONG) hwndPrevious)) { /* Put up error message */ WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, (PCH)"Can not save handle into reserved memory", (PCH)"IPF Sample Error Message", 1, MB_OK | MB_APPLMODAL | MB_MOVEABLE | MB_ICONASTERISK); break; } } else { /* Otherwise simply forward the message on */ if (hwndPrevious != 0L) { WinSendMsg (hwndPrevious, HM_UPDATE_BJCOM_WINDOW_CHAIN, (MPARAM) mp1, (MPARAM) mp2); } } return (MPARAM) NULL; break; case WM_CLOSE: WinDestroyWindow (WinQueryWindow (hwnd, QW_PARENT)); return (MPARAM) NULL; break; case WM_DESTROY: /* Take ourselves out of the chain */ hwndLatest = (HWND)WinSendMsg (hwnd, HM_QUERY, MPFROM2SHORT (0, HMQW_OBJCOM_WINDOW), (MPARAM)NULL); WinSendMsg (hwndLatest, HM_UPDATE_OBJCOM_WINDOW_CHAIN, (MPARAM) WinQueryWindow (hwnd, QW_PARENT), (MPARAM) hwndPrevious ); return (MPARAM) NULL; break; } if ((msg > HM_MSG_BASE) && (msg <= HM_MSG_MAX)) { return WinSendMsg( hwndPrevious, msg, mp1, mp2); } else { return WinDefWindowProc (hwnd, msg, mp1, mp2); } /* endif */ }