Annotation of os232sdk/toolkt20/c/samples/style/sty_help.c, revision 1.1

1.1     ! root        1: /*==============================================================*\
        !             2:  *  Help.c - routines for the help manager interface
        !             3:  *      Created 1990, Microsoft, IBM  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:  *          InitHelp()
        !            14:  *          HelpHelpForHelp(mp2)
        !            15:  *          HelpExtended(mp2)
        !            16:  *          HelpKeys(mp2)
        !            17:  *          HelpIndex(mp2)
        !            18:  *          HelpTutorial(mp2)
        !            19:  *          HelpAbout(mp2)
        !            20:  *          DisplayHelpPanel(idPanel)
        !            21:  *          DestroyHelpInstance()
        !            22:  *
        !            23: \*==============================================================*/
        !            24: 
        !            25: /*--------------------------------------------------------------*\
        !            26:  *  Include files, macros, defined constants, and externs
        !            27: \*--------------------------------------------------------------*/
        !            28: 
        !            29: 
        !            30: /* If DEBUG is defined, then the help panels will display their
        !            31:  *  id values on their title bar.  This is useful for determining
        !            32:  *  which help panels are being shown for each dialog item.  When
        !            33:  *  the DEBUG directive is not defined, then the panel ids are not
        !            34:  *  displayed.
        !            35:  */
        !            36: 
        !            37: /*
        !            38: #define  DEBUG
        !            39: */
        !            40: 
        !            41: #define  INCL_WINHELP
        !            42: 
        !            43: #include <os2.h>
        !            44: #include <string.h>
        !            45: #include "sty_main.h"
        !            46: #include "sty_xtrn.h"
        !            47: #include "sty_dlg.h"
        !            48: #include "sty_help.h"
        !            49: 
        !            50: #define HELPLIBRARYNAMELEN  20
        !            51: 
        !            52: /*--------------------------------------------------------------*\
        !            53:  *  Global variables
        !            54: \*--------------------------------------------------------------*/
        !            55: static HWND hwndHelpInstance;
        !            56: static CHAR szLibName[HELPLIBRARYNAMELEN];
        !            57: static CHAR szWindowTitle[HELPLIBRARYNAMELEN];
        !            58: 
        !            59: 
        !            60: /*--------------------------------------------------------------*\
        !            61:  *  Entry point declarations
        !            62: \*--------------------------------------------------------------*/
        !            63: MRESULT EXPENTRY AboutBoxDlgProc(HWND hwnd, USHORT msg,
        !            64:                                  MPARAM mp1, MPARAM mp2);
        !            65: 
        !            66: 
        !            67: /****************************************************************\
        !            68:  *  Routine for initializing the help manager
        !            69:  *--------------------------------------------------------------
        !            70:  *
        !            71:  *  Name:   InitHelp()
        !            72:  *
        !            73:  *  Purpose: Initializes the IPF help facility
        !            74:  *
        !            75:  *  Usage:  Called once during initialization of the program
        !            76:  *
        !            77:  *  Method: Initializes the HELPINIT structure and creates the
        !            78:  *          help instance.  If successful, the help instance
        !            79:  *          is associated with the main window
        !            80:  *
        !            81:  *  Returns:
        !            82:  *
        !            83: \****************************************************************/
        !            84: VOID InitHelp(VOID)
        !            85: {
        !            86:     HELPINIT hini;
        !            87: 
        !            88:     /* if we return because of an error, Help will be disabled */
        !            89:     fHelpEnabled = FALSE;
        !            90: 
        !            91:     /* inititalize help init structure */
        !            92:     hini.cb = sizeof(HELPINIT);
        !            93:     hini.ulReturnCode = NULL;
        !            94: 
        !            95:     hini.pszTutorialName = (PSZ)NULL;   /* if tutorial added, add name here */
        !            96: 
        !            97:     hini.phtHelpTable = (PHELPTABLE)MAKELONG(STYLE_HELP_TABLE, 0xFFFF);
        !            98:     hini.hmodHelpTableModule = NULL;
        !            99:     hini.hmodAccelActionBarModule = NULL;
        !           100:     hini.idAccelTable = NULL;
        !           101:     hini.idActionBar = NULL;
        !           102: 
        !           103:     if(!WinLoadString(hab,
        !           104:                       NULL,
        !           105:                       IDS_HELPWINDOWTITLE,
        !           106:                       HELPLIBRARYNAMELEN,
        !           107:                       (PSZ)szWindowTitle))  {
        !           108: 
        !           109:         MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
        !           110:         return;
        !           111:     }
        !           112: 
        !           113:     hini.pszHelpWindowTitle = (PSZ)szWindowTitle;
        !           114: 
        !           115:     /* if debugging, show panel ids, else don't */
        !           116: #ifdef DEBUG
        !           117:     hini.usShowPanelId = CMIC_SHOW_PANEL_ID;
        !           118: #else
        !           119:     hini.usShowPanelId = CMIC_HIDE_PANEL_ID;
        !           120: #endif
        !           121: 
        !           122:     if(!WinLoadString(hab,
        !           123:                       NULL,
        !           124:                       IDS_HELPLIBRARYNAME,
        !           125:                       HELPLIBRARYNAMELEN,
        !           126:                       (PSZ)szLibName))  {
        !           127: 
        !           128:         MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
        !           129:         return;
        !           130:     }
        !           131: 
        !           132:     hini.pszHelpLibraryName = (PSZ)szLibName;
        !           133: 
        !           134:     /* creating help instance */
        !           135:     hwndHelpInstance = WinCreateHelpInstance(hab, &hini);
        !           136: 
        !           137:     if(!hwndHelpInstance || hini.ulReturnCode)  {
        !           138:         MessageBox(hwndMainFrame,
        !           139:                    IDMSG_HELPLOADERROR,
        !           140:                    MB_OK | MB_ERROR,
        !           141:                    TRUE);
        !           142:         return;
        !           143:     }
        !           144: 
        !           145:     /* associate help instance with main frame */
        !           146:     if(!WinAssociateHelpInstance(hwndHelpInstance, hwndMainFrame)) {
        !           147:         MessageBox(hwndMainFrame,
        !           148:                    IDMSG_HELPLOADERROR,
        !           149:                    MB_OK | MB_ERROR,
        !           150:                    TRUE);
        !           151:         return;
        !           152:     }
        !           153: 
        !           154:     /* help manager is successfully initialized so set flag to TRUE */
        !           155:     fHelpEnabled = TRUE;
        !           156: 
        !           157: }   /* InitHelp() */
        !           158: 
        !           159: 
        !           160: /****************************************************************\
        !           161:  *  Processes the Help for Help command from the menu bar
        !           162:  *--------------------------------------------------------------
        !           163:  *
        !           164:  *  Name:   HelpHelpForHelp(mp2)
        !           165:  *
        !           166:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           167:  *            Help for Help item of the Help menu
        !           168:  *
        !           169:  *  Usage:  Called from MainCommand when the Help for Help
        !           170:  *          menu item is selected
        !           171:  *
        !           172:  *  Method: Sends an HM_DISPLAY_HELP message to the help
        !           173:  *          instance so that the default Help For Help is
        !           174:  *          displayed.
        !           175:  *
        !           176:  *  Returns:
        !           177:  *
        !           178: \****************************************************************/
        !           179: VOID  HelpHelpForHelp(mp2)
        !           180: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           181: {
        !           182: 
        !           183:     /* this just displays the system help for help panel */
        !           184:     if(fHelpEnabled)
        !           185:         if(WinSendMsg(hwndHelpInstance, HM_DISPLAY_HELP, NULL, NULL))
        !           186:             MessageBox(hwndMain,
        !           187:                        IDMSG_HELPDISPLAYERROR,
        !           188:                        MB_OK | MB_ERROR,
        !           189:                        FALSE);
        !           190: 
        !           191:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           192:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           193:     \*  warning at compile time.                                      */
        !           194:     mp2;
        !           195: 
        !           196: }   /* HelpHelpForHelp() */
        !           197: 
        !           198: 
        !           199: /****************************************************************\
        !           200:  *  Processes the Extended Help command from the menu bar
        !           201:  *--------------------------------------------------------------
        !           202:  *
        !           203:  *  Name:   HelpExtended(mp2)
        !           204:  *
        !           205:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           206:  *            Extended Help item of the Help menu
        !           207:  *
        !           208:  *  Usage:  Called from MainCommand when the Extended Help
        !           209:  *          menu item is selected
        !           210:  *
        !           211:  *  Method: Sends an HM_EXT_HELP message to the help
        !           212:  *          instance so that the default Extended Help is
        !           213:  *          displayed.
        !           214:  *
        !           215:  *  Returns:
        !           216:  *
        !           217: \****************************************************************/
        !           218: VOID  HelpExtended(mp2)
        !           219: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           220: {
        !           221: 
        !           222:     /* this just displays the system extended help panel */
        !           223:     if(fHelpEnabled)
        !           224:         if(WinSendMsg(hwndHelpInstance, HM_EXT_HELP, NULL, NULL))
        !           225:             MessageBox(hwndMain,
        !           226:                        IDMSG_HELPDISPLAYERROR,
        !           227:                        MB_OK | MB_ERROR,
        !           228:                        FALSE);
        !           229: 
        !           230:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           231:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           232:     \*  warning at compile time.                                      */
        !           233:     mp2;
        !           234: 
        !           235: }   /* HelpExtended() */
        !           236: 
        !           237: 
        !           238: /****************************************************************\
        !           239:  *  Processes the Keys Help command from the menu bar
        !           240:  *--------------------------------------------------------------
        !           241:  *
        !           242:  *  Name:   HelpKeys(mp2)
        !           243:  *
        !           244:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           245:  *            Keys Help item of the Help menu
        !           246:  *
        !           247:  *  Usage:  Called from MainCommand when the Keys Help
        !           248:  *          menu item is selected
        !           249:  *
        !           250:  *  Method: Sends an HM_KEYS_HELP message to the help
        !           251:  *          instance so that the default Keys Help is
        !           252:  *          displayed.
        !           253:  *
        !           254:  *  Returns:
        !           255:  *
        !           256: \****************************************************************/
        !           257: VOID  HelpKeys(mp2)
        !           258: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           259: {
        !           260: 
        !           261:     /* this just displays the system keys help panel */
        !           262:     if(fHelpEnabled)
        !           263:         if(WinSendMsg(hwndHelpInstance, HM_KEYS_HELP, NULL, NULL))
        !           264:             MessageBox(hwndMain,
        !           265:                        IDMSG_HELPDISPLAYERROR,
        !           266:                        MB_OK | MB_ERROR,
        !           267:                        FALSE);
        !           268: 
        !           269: 
        !           270:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           271:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           272:     \*  warning at compile time.                                      */
        !           273:     mp2;
        !           274: 
        !           275: }   /* HelpKeys() */
        !           276: 
        !           277: 
        !           278: /****************************************************************\
        !           279:  *  Processes the Index Help command from the menu bar
        !           280:  *--------------------------------------------------------------
        !           281:  *
        !           282:  *  Name:   HelpIndex(mp2)
        !           283:  *
        !           284:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           285:  *            Index Help item of the Help menu
        !           286:  *
        !           287:  *  Usage:  Called from MainCommand when the Index Help
        !           288:  *          menu item is selected
        !           289:  *
        !           290:  *  Method: Sends an HM_INDEX_HELP message to the help
        !           291:  *          instance so that the default Index Help is
        !           292:  *          displayed.
        !           293:  *
        !           294:  *  Returns:
        !           295:  *
        !           296: \****************************************************************/
        !           297: VOID  HelpIndex(mp2)
        !           298: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           299: {
        !           300: 
        !           301:     /* this just displays the system help index panel */
        !           302:     if(fHelpEnabled)
        !           303:         if(WinSendMsg(hwndHelpInstance, HM_HELP_INDEX, NULL, NULL))
        !           304:             MessageBox(hwndMain,
        !           305:                        IDMSG_HELPDISPLAYERROR,
        !           306:                        MB_OK | MB_ERROR,
        !           307:                        FALSE);
        !           308: 
        !           309: 
        !           310:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           311:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           312:     \*  warning at compile time.                                      */
        !           313:     mp2;
        !           314: 
        !           315: }   /* HelpIndex() */
        !           316: 
        !           317: 
        !           318: /****************************************************************\
        !           319:  *  Processes the Tutorial Help command from the menu bar
        !           320:  *--------------------------------------------------------------
        !           321:  *
        !           322:  *  Name:   HelpTutorial(mp2)
        !           323:  *
        !           324:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           325:  *            Tutorial Help item of the Help menu.  While the
        !           326:  *            standard template application does not include a
        !           327:  *            Tutorial menu item, you can add one if your
        !           328:  *            application has a tutorial.
        !           329:  *
        !           330:  *  Usage:  Called from MainCommand when the Tutorial Help
        !           331:  *          menu item is selected
        !           332:  *
        !           333:  *  Method:
        !           334:  *
        !           335:  *  Returns:
        !           336:  *
        !           337: \****************************************************************/
        !           338: VOID  HelpTutorial(mp2)
        !           339: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           340: {
        !           341: 
        !           342:    /*--------------------------------------------------------------*\
        !           343:     *  Insert code for any tutorial here
        !           344:    \*--------------------------------------------------------------*/
        !           345: 
        !           346: 
        !           347:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           348:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           349:     \*  warning at compile time.                                      */
        !           350:     mp2;
        !           351: 
        !           352: }   /* HelpTutorial() */
        !           353: 
        !           354: /****************************************************************\
        !           355:  *  Processes the About command from the Help menu
        !           356:  *--------------------------------------------------------------
        !           357:  *
        !           358:  *  Name:   HelpAbout(mp2)
        !           359:  *
        !           360:  *  Purpose: Processes the WM_COMMAND message posted by the
        !           361:  *            About item of the Help menu
        !           362:  *
        !           363:  *  Usage:  Called from MainCommand when the About
        !           364:  *          menu item is selected
        !           365:  *
        !           366:  *  Method: Calls WinDlgBox to display the about box dialog.
        !           367:  *
        !           368:  *  Returns:
        !           369:  *
        !           370: \****************************************************************/
        !           371: VOID  HelpAbout(mp2)
        !           372: MPARAM mp2;     /* second parameter of WM_COMMAND message */
        !           373: {
        !           374:     /* display the AboutBox dialog */
        !           375:     WinDlgBox(hwndMain,
        !           376:               hwndMain,
        !           377:               (PFNWP)AboutBoxDlgProc,
        !           378:               NULL,
        !           379:               IDD_ABOUTBOX,
        !           380:               (PVOID)NULL);
        !           381: 
        !           382:     /* This routine currently doesn't use the mp2 parameter but       *\
        !           383:      *  it is referenced here to prevent an 'Unreferenced Parameter'
        !           384:     \*  warning at compile time.                                      */
        !           385:     mp2;
        !           386: 
        !           387: }   /* HelpAbout() */
        !           388: 
        !           389: 
        !           390: /****************************************************************\
        !           391:  *  Displays the help panel indicated
        !           392:  *--------------------------------------------------------------
        !           393:  *
        !           394:  *  Name:   DisplayHelpPanel(idPanel)
        !           395:  *
        !           396:  *  Purpose: Displays the help panel whose id is given
        !           397:  *
        !           398:  *  Usage:  Called whenever a help panel is desired to be
        !           399:  *          displayed, usually from the WM_HELP processing
        !           400:  *          of the dialog boxes
        !           401:  *
        !           402:  *  Method: Sends HM_DISPLAY_HELP message to the help instance
        !           403:  *
        !           404:  *  Returns:
        !           405:  *
        !           406: \****************************************************************/
        !           407: VOID DisplayHelpPanel(idPanel)
        !           408: SHORT idPanel;      /* ID of the help panel to be displayed */
        !           409: {
        !           410: 
        !           411:     if(fHelpEnabled)
        !           412:         if(WinSendMsg(hwndHelpInstance,
        !           413:                       HM_DISPLAY_HELP,
        !           414:                       MPFROM2SHORT(idPanel, NULL),
        !           415:                       MPFROMSHORT(HM_RESOURCEID)))
        !           416: 
        !           417:             MessageBox(hwndMainFrame,
        !           418:                        IDMSG_HELPDISPLAYERROR,
        !           419:                        MB_OK | MB_ERROR,
        !           420:                        TRUE);
        !           421: 
        !           422: 
        !           423: }   /* DisplayHelpPanel() */
        !           424: 
        !           425: 
        !           426: 
        !           427: /****************************************************************\
        !           428:  *  Destroys the help instance
        !           429:  *--------------------------------------------------------------
        !           430:  *
        !           431:  *  Name:   DestroyHelpInstance(VOID)
        !           432:  *
        !           433:  *  Purpose: Destroys the help instance for the application
        !           434:  *
        !           435:  *  Usage:  Called after exit from message loop
        !           436:  *
        !           437:  *  Method: Calls WinDestroyHelpInstance() to destroy the
        !           438:  *          help instance
        !           439:  *
        !           440:  *  Returns:
        !           441:  *
        !           442: \****************************************************************/
        !           443: VOID DestroyHelpInstance(VOID)
        !           444: {
        !           445:     if(hwndHelpInstance)  {
        !           446:         WinDestroyHelpInstance(hwndHelpInstance);
        !           447:     }
        !           448: 
        !           449: }   /* DestroyHelpInstance() */

unix.superglobalmegacorp.com

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