home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ipfe10.zip
/
IPFEDHLP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-14
|
8KB
|
238 lines
/* File: E:\PMSOURCE\IPFEDIT\IPFEDEMO\IPFEDHLP.C
(Created by IPF Editor (C) 1992-1993 Bill Perez.)
Date: Sat Aug 14 16:51:27 1993
Purpose: This file is created automatically when the Create C Source menu
option is selected. If you edit this file and then rerun the C Source
command your changes will be lost.
*/
/* Include Files */
#define INCL_PM
#include <os2.h>
#include "IPFEDHLP.H" /* Help panel definitions */
/* Global Variables */
BOOL fHelpEnabled = FALSE;
HWND hwndHelpInstance = 0L;
/******************************************************
Function: HelpInit()
Author: IPF Editor (C) 1992-1993 Bill Perez.
Date: Sat Aug 14 16:51:27 1993
Purpose: Initialize help system
Arguments:
HWND hwndFrame Frame of window to associate
help instance with.
Returns:
ULONG ulReturnCode - Result of initialize attempt.
0 = OK, !0 is OS/2 PM Error Code
******************************************************/
ULONG HelpInit( HWND hwndFrame )
{
HELPINIT hini;
/* Reset help enabled in case there is an error so help will be disabled */
fHelpEnabled = FALSE;
/* Initialize help init structures */
hini.cb = sizeof( HELPINIT );
hini.ulReturnCode = 0L;
hini.pszTutorialName = (PSZ) NULL;
hini.phtHelpTable = (PHELPTABLE) MAKELONG( IDD_IPFEDEMO_HELP_TABLE, 0xFFFF );
hini.hmodHelpTableModule = (HMODULE) 0L;
hini.hmodAccelActionBarModule = (HMODULE) 0L;
hini.idAccelTable = 0;
hini.idActionBar = 0;
hini.pszHelpWindowTitle = (PSZ) "IPF Editor Demo Program";
/* If debugging help text, show panel ID's */
#ifdef DEBUG
hini.fShowPanelId = CMIC_SHOW_PANEL_ID;
#else
hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
#endif
hini.pszHelpLibraryName = (PSZ) "IPFEDEMO.HLP";
hwndHelpInstance =
WinCreateHelpInstance(
WinQueryAnchorBlock( hwndFrame ),
&hini );
/* Did help get initialized correctly? */
if( !hwndHelpInstance || hini.ulReturnCode )
return hini.ulReturnCode;
/* Associate help instance with window frame */
if( !WinAssociateHelpInstance( hwndHelpInstance, hwndFrame ) )
return ERRORIDERROR( WinGetLastError( WinQueryAnchorBlock( hwndFrame ) ) );
return 0;
}
/******************************************************
Function: HelpDestroyInstance()
Author: IPF Editor (C) 1992-1993 Bill Perez.
Date: Sat Aug 14 16:51:27 1993
Purpose: Destroy help instance
Arguments: none.
Returns: none.
******************************************************/
VOID HelpDestroyInstance( VOID )
{
if( hwndHelpInstance )
WinDestroyHelpInstance( hwndHelpInstance );
}
/******************************************************
Function: HelpProcessMessages()
Author: IPF Editor (C) 1992-1993 Bill Perez.
Date: Sat Aug 14 16:51:27 1993
Purpose: Processes help menu messages
Arguments: Standard PM Message format
Returns: Varies Based on Message
Call: Call this when processing WM_ACTIVATE, WM_COMMAND,
and WM_INITMENU messages.
******************************************************/
MRESULT HelpProcessMessages( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
switch( msg )
{
case WM_COMMAND:
switch( SHORT1FROMMP( mp1 ) )
{
case IDM_HELP_USING:
if( WinQueryHelpInstance( hwnd ) )
return WinSendMsg( WinQueryHelpInstance( hwnd ), HM_DISPLAY_HELP, 0L, 0L );
break;
case IDM_HELP_INDEX:
if( WinQueryHelpInstance( hwnd ) )
return WinSendMsg( WinQueryHelpInstance( hwnd ), HM_HELP_INDEX, 0L, 0L );
break;
case IDM_HELP_CONTENTS:
if( WinQueryHelpInstance( hwnd ) )
return WinSendMsg( WinQueryHelpInstance( hwnd ), HM_HELP_CONTENTS, 0L, 0L );
break;
case IDM_HELP_GENERAL:
if( WinQueryHelpInstance( hwnd ) )
return WinSendMsg( WinQueryHelpInstance( hwnd ), HM_GENERAL_HELP, 0L, 0L );
break;
}
return (MRESULT) 0L;
case WM_ACTIVATE:
if( SHORT1FROMMP( mp1 ) )
{
WinSendMsg(
WinQueryHelpInstance( hwnd ),
HM_SET_ACTIVE_WINDOW,
MPFROMLONG( WinQueryWindow( hwnd, QW_PARENT ) ),
MPFROMLONG( WinQueryWindow( hwnd, QW_PARENT ) ) );
}
else
{
WinSendMsg(
WinQueryHelpInstance( hwnd ),
HM_SET_ACTIVE_WINDOW,
0L,
0L );
}
return (MRESULT) 0L;
case WM_INITMENU:
WinSendMsg(
WinQueryHelpInstance( hwnd ),
HM_SET_ACTIVE_WINDOW,
MPFROMLONG( WinQueryWindow( hwnd, QW_PARENT ) ),
MPFROMLONG( WinQueryWindow( hwnd, QW_PARENT ) ) );
return (MRESULT) 0L;
case HM_ERROR:
{
CHAR szOut[ 128 ];
sprintf(
szOut,
"IPF Help error (HM_ERROR: %lx)",
LONGFROMMP( mp1 ) );
WinMessageBox(
HWND_DESKTOP,
hwnd,
szOut,
"IPF Editor Demo Program",
0,
MB_OK | MB_WARNING );
}
return (MRESULT) 0L;
case HM_GENERAL_HELP_UNDEFINED:
WinMessageBox(
HWND_DESKTOP,
hwnd,
"General help requested not defined. Sorry.",
"IPF Editor Demo Program",
0,
MB_OK | MB_WARNING );
return (MRESULT) 0L;
/* You may want to remove the following handling from your final
code when all help handling has been implemented. If this returns
FALSE the extended help page is displayed */
case HM_HELPSUBITEM_NOT_FOUND:
/* Don't intercept general help */
if( SHORT1FROMMP( mp1 ) != 1 && SHORT2FROMMP( mp2 ) != 2 )
{
CHAR szOut[ 128 ];
sprintf(
szOut,
"IPF Help error. Topic %lx (subtopic %lx) not found for %s.",
(ULONG) SHORT1FROMMP( mp2 ),
(ULONG) SHORT2FROMMP( mp2 ),
LONGFROMMP( mp1 ) == HLPM_WINDOW ? "application window" :
(LONGFROMMP( mp1 ) == HLPM_FRAME ? "frame window" : "menu window" ) );
WinMessageBox(
HWND_DESKTOP,
hwnd,
szOut,
"IPF Editor Demo Program",
0,
MB_OK | MB_WARNING );
return (MRESULT) TRUE;
}
/* For HLPM_WINDOW or HLPM_FRAME return FALSE
for no action or TRUE for extended help */
return (MRESULT) TRUE;
}
return (MRESULT) 0L;
}