home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
print
/
pmenv
/
help.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-03
|
2KB
|
87 lines
#include <stdio.h>
#include <string.h>
#define INCL_WINDIALOGS
#define INCL_WINHELP
#include <os2.h>
#include "help.h"
/* ----------------------------------------------------------------- */
HWND InitializeHelp (HAB hab, HWND hwndFrame, USHORT idWnd,
PSZ pszHelpFilename, PSZ pszHelpTitle)
{
HELPINIT hmiHelpData; /* Help initialization structure */
HWND hwndHelpInstance;
CHAR szMsg[100];
memset (&hmiHelpData, 0, sizeof (HELPINIT));
hmiHelpData.cb = sizeof (HELPINIT);
hmiHelpData.phtHelpTable = (PVOID) (0xffff0000 | idWnd);
hmiHelpData.pszHelpWindowTitle = pszHelpTitle;
hmiHelpData.pszHelpLibraryName = pszHelpFilename;
hwndHelpInstance = WinCreateHelpInstance (hab, &hmiHelpData);
if (hwndHelpInstance && hmiHelpData.ulReturnCode)
{
WinDestroyHelpInstance (hwndHelpInstance);
hwndHelpInstance = 0;
}
if (!hwndHelpInstance)
{
sprintf (szMsg, "WinCreateHelpInstance failed, rc = %lx. "
"Program will continue without help.",
hmiHelpData.ulReturnCode);
WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, szMsg,
(PSZ) "Help Creation Error", 1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
}
else
WinAssociateHelpInstance (hwndHelpInstance, hwndFrame);
return hwndHelpInstance;
}
/* ----------------------------------------------------------------- */
MRESULT ProcessHmMessages (HWND hwndHelpInstance,
USHORT msg, MPARAM mp1, MPARAM mp2)
{
switch (msg)
{
case HM_ERROR:
if (hwndHelpInstance && LONGFROMMP(mp1) == HMERR_NO_MEMORY)
{
WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
(PSZ) "Help Terminated Due to Error",
(PSZ) "Help Error",
1,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
WinDestroyHelpInstance (hwndHelpInstance);
}
else
{
CHAR szMsg[ 50 ];
sprintf (szMsg, "Help Error %lx Occurred",
LONGFROMMP (mp1));
WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
szMsg, "Help Error", 0,
MB_OK | MB_APPLMODAL | MB_MOVEABLE);
}
return (MRESULT) 0;
}
return (MRESULT) 0;
}