Annotation of os232sdk/toolkt20/c/samples/image/img_help.c, revision 1.1

1.1     ! root        1: /*==============================================================*\
        !             2:  *  img_help.c - routines for the help manager interface
        !             3:  *      Created 1989, 1990 IBM, Microsoft Corp.
        !             4:  *--------------------------------------------------------------
        !             5:  *
        !             6:  *  This module contains all the routines for interfacing with
        !             7:  *  the IPF help manager.
        !             8:  *
        !             9:  *--------------------------------------------------------------
        !            10:  *
        !            11:  *  This source file contains the following functions:
        !            12:  *
        !            13:  *      HelpInit()
        !            14:  *      HelpHelpForHelp(mp2)
        !            15:  *      HelpExtended(mp2)
        !            16:  *      HelpIndex(mp2)
        !            17:  *      HelpAbout(mp2)
        !            18:  *      HelpDestroyInstance()
        !            19:  *
        !            20: \*==============================================================*/
        !            21: 
        !            22: /*--------------------------------------------------------------*\
        !            23:  *  Include files, macros, defined constants, and externs
        !            24: \*--------------------------------------------------------------*/
        !            25: 
        !            26: #define INCL_WINHELP
        !            27: #define INCL_WINDIALOGS
        !            28: 
        !            29: #include <os2.h>
        !            30: #include <string.h>
        !            31: #include "img_main.h"
        !            32: #include "img_xtrn.h"
        !            33: #include "img_dlg.h"
        !            34: #include "img_help.h"
        !            35: 
        !            36: #define HELPLIBRARYNAMELEN  20
        !            37: 
        !            38: /*--------------------------------------------------------------*\
        !            39:  *  Global variables
        !            40: \*--------------------------------------------------------------*/
        !            41: static HWND hwndHelpInstance;
        !            42: 
        !            43: #ifdef HELP_MANAGER_ENABLED
        !            44: 
        !            45: /****************************************************************\
        !            46:  *  Routine for initializing the help manager
        !            47:  *--------------------------------------------------------------
        !            48:  *
        !            49:  *  Name:   HelpInit()
        !            50:  *
        !            51:  *  Purpose: Initializes the IPF help facility
        !            52:  *
        !            53:  *  Usage:  Called once during initialization of the program
        !            54:  *
        !            55:  *  Method: Initializes the HELPINIT structure and creates the
        !            56:  *          help instance.  If successful, the help instance
        !            57:  *          is associated with the main window
        !            58:  *
        !            59:  *  Returns:
        !            60:  *
        !            61: \****************************************************************/
        !            62: VOID HelpInit(VOID)
        !            63: {
        !            64:     HELPINIT hini;
        !            65:     CHAR szLibName[HELPLIBRARYNAMELEN];
        !            66:     CHAR szWindowTitle[HELPLIBRARYNAMELEN];
        !            67: 
        !            68:     /* inititalize help init structure */
        !            69:     hini.cb = sizeof(HELPINIT);
        !            70:     hini.ulReturnCode = NULL;
        !            71: 
        !            72:     hini.pszTutorialName = (PSZ)NULL;   /* if tutorial added, add name here */
        !            73: 
        !            74:     hini.phtHelpTable = (PHELPTABLE)(0xFFFF0000 | IMAGE_HELP_TABLE);
        !            75:     hini.hmodHelpTableModule = NULL;
        !            76:     hini.hmodAccelActionBarModule = NULL;
        !            77:     hini.idAccelTable = NULL;
        !            78:     hini.idActionBar = NULL;
        !            79: #ifdef DEBUG
        !            80:     hini.usShowPanelId = CMIC_SHOW_PANEL_ID;
        !            81: #else
        !            82:     hini.usShowPanelId = CMIC_HIDE_PANEL_ID;
        !            83: #endif
        !            84: 
        !            85:     if (!WinLoadString(vhab,
        !            86:                        NULL,
        !            87:                        IDS_HELPWINDOWTITLE,
        !            88:                        HELPLIBRARYNAMELEN,
        !            89:                        (PSZ)szWindowTitle))  {
        !            90: 
        !            91:         MessageBox(vhwndFrame, IDMSG_CANNOTLOADSTRING, 0,
        !            92:                    MB_OK | MB_ERROR, FALSE);
        !            93:         return;
        !            94:     }
        !            95:     hini.pszHelpWindowTitle = (PSZ)szWindowTitle;
        !            96: 
        !            97:     if (!WinLoadString(vhab,
        !            98:                        NULL,
        !            99:                        IDS_HELPLIBRARYNAME,
        !           100:                        HELPLIBRARYNAMELEN,
        !           101:                        (PSZ)szLibName))  {
        !           102: 
        !           103:         MessageBox(vhwndFrame, IDMSG_CANNOTLOADSTRING, 0,
        !           104:                    MB_OK | MB_ERROR, FALSE);
        !           105:         return;
        !           106:     }
        !           107:     hini.pszHelpLibraryName = (PSZ)szLibName;
        !           108: 
        !           109: 
        !           110:     /* creating help instance */
        !           111:     hwndHelpInstance = WinCreateHelpInstance(vhab, &hini);
        !           112: 
        !           113:     if (!hwndHelpInstance || hini.ulReturnCode)  {
        !           114:         MessageBox(vhwndFrame, IDMSG_HELPLOADERROR, 0,
        !           115:                    MB_OK | MB_ERROR, FALSE);
        !           116:         return;
        !           117:     }
        !           118: 
        !           119:     /* associate help instance with main frame */
        !           120:     if (!WinAssociateHelpInstance(hwndHelpInstance, vhwndFrame)) {
        !           121:         MessageBox(vhwndFrame, IDMSG_HELPLOADERROR, 0,
        !           122:                    MB_OK | MB_ERROR, FALSE);
        !           123:         return;
        !           124:     }
        !           125: 
        !           126:     /* set flag to enable Help menu items */
        !           127:     vfHelpEnabled = TRUE;
        !           128: 
        !           129: }   /* HelpInit() */
        !           130: 
        !           131: 
        !           132: /****************************************************************\
        !           133:  *  Processes the Help for Help command from the menu bar
        !           134:  *--------------------------------------------------------------
        !           135:  *
        !           136:  *  Name:   HelpHelpForHelp(mp2)
        !           137:  *
        !           138:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           139:  *            Help for Help item of the Help menu
        !           140:  *
        !           141:  *  Usage:  Called from MainCommand when the Help for Help
        !           142:  *          menu item is selected
        !           143:  *
        !           144:  *  Method: Sends an HM_DISPLAY_HELP message to the help
        !           145:  *          instance so that the default Help For Help is
        !           146:  *          displayed.
        !           147:  *
        !           148:  *  Returns:
        !           149:  *
        !           150: \****************************************************************/
        !           151: VOID  HelpHelpForHelp(mp2)
        !           152: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           153: {
        !           154: 
        !           155:     /* this just displays the system help for help panel */
        !           156:     if (WinSendMsg(hwndHelpInstance, HM_DISPLAY_HELP, NULL, NULL))
        !           157:         MessageBox(vhwndFrame, IDMSG_HELPDISPLAYERROR, 0,
        !           158:                    MB_OK | MB_ERROR, FALSE);
        !           159: 
        !           160:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           161:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           162:     \*  warning at compile time.                                      */
        !           163:     mp2;
        !           164: 
        !           165: }   /* HelpHelpForHelp() */
        !           166: 
        !           167: 
        !           168: /****************************************************************\
        !           169:  *  Processes the Extended Help command from the menu bar
        !           170:  *--------------------------------------------------------------
        !           171:  *
        !           172:  *  Name:   HelpExtended(mp2)
        !           173:  *
        !           174:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           175:  *            Extended Help item of the Help menu
        !           176:  *
        !           177:  *  Usage:  Called from MainCommand when the Extended Help
        !           178:  *          menu item is selected
        !           179:  *
        !           180:  *  Method: Sends an HM_EXT_HELP message to the help
        !           181:  *          instance so that the default Extended Help is
        !           182:  *          displayed.
        !           183:  *
        !           184:  *  Returns:
        !           185:  *
        !           186: \****************************************************************/
        !           187: VOID  HelpExtended(mp2)
        !           188: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           189: {
        !           190: 
        !           191:     /* this just displays the system extended help panel */
        !           192:     if (WinSendMsg(hwndHelpInstance, HM_EXT_HELP, NULL, NULL))
        !           193:         MessageBox(vhwndFrame, IDMSG_HELPDISPLAYERROR, 0,
        !           194:                    MB_OK | MB_ERROR, FALSE);
        !           195: 
        !           196:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           197:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           198:     \*  warning at compile time.                                      */
        !           199:     mp2;
        !           200: 
        !           201: }   /* HelpExtended() */
        !           202: 
        !           203: /****************************************************************\
        !           204:  *  Processes the Index Help command from the menu bar
        !           205:  *--------------------------------------------------------------
        !           206:  *
        !           207:  *  Name:   HelpIndex(mp2)
        !           208:  *
        !           209:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           210:  *            Index Help item of the Help menu
        !           211:  *
        !           212:  *  Usage:  Called from MainCommand when the Index Help
        !           213:  *          menu item is selected
        !           214:  *
        !           215:  *  Method: Sends an HM_INDEX_HELP message to the help
        !           216:  *          instance so that the default Index Help is
        !           217:  *          displayed.
        !           218:  *
        !           219:  *  Returns:
        !           220:  *
        !           221: \****************************************************************/
        !           222: VOID  HelpIndex(mp2)
        !           223: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           224: {
        !           225: 
        !           226:     /* this just displays the system help index panel */
        !           227:     if (WinSendMsg(hwndHelpInstance, HM_HELP_INDEX, NULL, NULL))
        !           228:         MessageBox(vhwndFrame, IDMSG_HELPDISPLAYERROR, 0,
        !           229:                    MB_OK | MB_ERROR, FALSE);
        !           230: 
        !           231:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           232:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           233:     \*  warning at compile time.                                      */
        !           234:     mp2;
        !           235: 
        !           236: }   /* HelpIndex() */
        !           237: 
        !           238: /****************************************************************\
        !           239:  *  Destroys the help instance
        !           240:  *--------------------------------------------------------------
        !           241:  *
        !           242:  *  Name:   HelpDestroyInstance(VOID)
        !           243:  *
        !           244:  *  Purpose: Destroys the help instance for the application
        !           245:  *
        !           246:  *  Usage:  Called during Exit List processing
        !           247:  *
        !           248:  *  Method: Calls WinDestroyHelpInstance() to destroy the
        !           249:  *          help instance
        !           250:  *
        !           251:  *  Returns:
        !           252:  *
        !           253: \****************************************************************/
        !           254: VOID HelpDestroyInstance(VOID)
        !           255: {
        !           256: 
        !           257:     if(hwndHelpInstance)  {
        !           258:         WinDestroyHelpInstance(hwndHelpInstance);
        !           259:     }
        !           260:     vfHelpEnabled = FALSE;
        !           261: 
        !           262: }   /* HelpDestroyInstance() */
        !           263: 
        !           264: #endif
        !           265: 
        !           266: /****************************************************************\
        !           267:  *  Processes the About command from the Help menu              *
        !           268:  *--------------------------------------------------------------*
        !           269:  *                                                              *
        !           270:  *  Name:   HelpAbout()                                         *
        !           271:  *                                                              *
        !           272:  *  Purpose: Processes the WM_COMMAND message posted by the     *
        !           273:  *            About item of the Help menu                       *
        !           274:  *                                                              *
        !           275:  *  Usage:  Called from MainCommand when the About              *
        !           276:  *          menu item is selected                               *
        !           277:  *                                                              *
        !           278:  *  Method: Calls WinDlgBox to display the about box dialog.    *
        !           279:  *                                                              *
        !           280:  *  Returns:                                                    *
        !           281:  *                                                              *
        !           282: \****************************************************************/
        !           283: VOID  HelpAbout()
        !           284: {
        !           285: 
        !           286:     WinDlgBox(vhwndClient, vhwndClient, AboutBoxDlgProc, NULL,
        !           287:               IDD_ABOUTBOX, (PVOID)NULL);
        !           288: 
        !           289:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           290:      *  it is referenced here to prevent an 'Unreferenced Parameter'  *
        !           291:     \*  warning at compile time.                                      */
        !           292: 
        !           293: }   /* HelpAbout() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.