home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipfe10.zip / IPFEDEMO.C < prev    next >
Text File  |  1993-05-29  |  6KB  |  246 lines

  1. /* File: IPFEDEMO.C
  2.    Author: Bill Perez
  3.    Date: 5/26/1993
  4.    Purpose: Simple demo program to show adding help using IPF Editor's
  5.         help generation routines.
  6.  
  7.    Operating System: OS/2 2.x PM
  8.  
  9.    Revision: 0.1
  10.  
  11.    Revision History:
  12.  
  13.         0.1 - 5/26/1993 - Initial Coding, Bill Perez.
  14.  
  15.    Notes: 
  16.  
  17.         Link with IPF Editor generated C source IFPEDHLP.C.  Include
  18.         IPF Editor generated C and RC files IPFEDHLP.H and IPFEDHLP.RC
  19.         into this file and resource file, respectively.
  20.  
  21.  
  22.         (C) 1993 Bill Perez.
  23.  
  24. */
  25.  
  26. // Includes
  27. #define INCL_PM
  28. #include <os2.h>
  29. #include "ipfedhlp.h"               // IPF Editor generated include file for help
  30.  
  31. // Definitions
  32.  
  33. // Structures
  34.  
  35. // Typedefs
  36.  
  37. // Global variables
  38. HWND
  39.     hwndFrame,
  40.     hwndClient;
  41.  
  42. // Prototypes
  43. int main(int argc, char *argv[], char *envp[]);
  44. #pragma linkage( IPFEDemoWndProc, system )
  45. MRESULT EXPENTRY IPFEDemoWndProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 );
  46. #pragma linkage( IPFEDemoDlgProc, system )
  47. MRESULT EXPENTRY IPFEDemoDlgProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 );
  48.  
  49.  
  50. int main(int argc, char *argv[], char *envp[])
  51. {
  52.     HAB
  53.         hab;                            // Anchor block
  54.     HMQ
  55.         hmq;                            // Message Queue handle
  56.     PCHAR
  57.         pszClass = "IPFEDEMO";          // Class name
  58.     ULONG
  59.         flFrameFlags =                  // Frame definition
  60.                 FCF_SIZEBORDER | FCF_MENU | FCF_ICON |
  61.                 FCF_TITLEBAR | FCF_SHELLPOSITION | FCF_TASKLIST | 
  62.                 FCF_MINMAX;
  63.     QMSG
  64.         qmsg;                           // Message queue contents
  65.  
  66.     hab = WinInitialize( 0 );
  67.     hmq = WinCreateMsgQueue( hab, 0 );
  68.  
  69.     // Register our window class
  70.     WinRegisterClass(
  71.         hab,
  72.         pszClass,
  73.         (PFNWP) IPFEDemoWndProc,
  74.         CS_SIZEREDRAW,
  75.         0 );
  76.  
  77.     // Create standard window
  78.     hwndFrame =
  79.         WinCreateStdWindow(
  80.             HWND_DESKTOP,
  81.             WS_VISIBLE,
  82.             &flFrameFlags,
  83.             pszClass,
  84.             "IPF Editor Demo C Program",
  85.             WS_VISIBLE,
  86.             0L,
  87.             IDD_IPFEDEMO,
  88.             &hwndClient );
  89.  
  90.     // Initialize help system
  91.     HelpInit( hwndFrame );
  92.  
  93.     // Loop until terminated
  94.     while( WinGetMsg( hab, &qmsg, 0L, 0, 0 )  )
  95.         WinDispatchMsg( hab, &qmsg );
  96.  
  97.     // Terminate help system
  98.     HelpDestroyInstance();
  99.  
  100.     // Kill window
  101.     WinDestroyWindow( hwndFrame );
  102.  
  103.     // Destroy message queue
  104.     WinDestroyMsgQueue( hmq );
  105.  
  106.     // Kill handle to anchor block
  107.     WinTerminate( hab );
  108.  
  109.     // Exit with error code of zero
  110.     exit( 0 );
  111. }
  112.  
  113. /*****************************************************************
  114.    Function: IPFEDemoWndProc()
  115.    Author: Bill Perez
  116.    Date: 5/26/1993
  117.    Purpose: Main window procedure for IPF Editor demo.  Handles all
  118.         messages for IPF Editor Demo program.
  119.  
  120.    Revision: 1.0
  121.  
  122.    Revision History:
  123.  
  124.         1.0 - Initial Coding, Bill Perez.
  125.  
  126.  
  127. */
  128. MRESULT EXPENTRY IPFEDemoWndProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  129. {
  130.     HPS 
  131.         hps;                                // PS access
  132.  
  133.     switch( msg )
  134.     {
  135.         case WM_CREATE:
  136.             return (MRESULT) 0L;
  137.  
  138.         // Process messages help needs to be aware of
  139.         case WM_ACTIVATE:
  140.         case WM_INITMENU:
  141.             return HelpProcessMessages( hwnd, msg, mp1, mp2 );
  142.  
  143.         case HM_ERROR: 
  144.             DosBeep( 500, 250 );
  145.             DosBeep( 500, 250 );
  146.             return HelpProcessMessages( hwnd, msg, mp1, mp2 );
  147.  
  148.         case HM_HELPSUBITEM_NOT_FOUND:
  149.             DosBeep( 1000, 100 );
  150.             return HelpProcessMessages( hwnd, msg, mp1, mp2 );
  151.  
  152.         case WM_HELP:
  153.             DosBeep( 100, 100 );
  154.             return HelpProcessMessages( hwnd, msg, mp1, mp2 );
  155.  
  156.  
  157.         // Process command messages
  158.         case WM_COMMAND:
  159.             // Make sure help get's chance to see WM_COMMAND message
  160.             HelpProcessMessages( hwnd, msg, mp1, mp2 );
  161.  
  162.             // Process menu commands, now
  163.             switch( SHORT1FROMMP( mp1 ) )
  164.             {
  165.                 // Exit program
  166.                 case IDM_QUIT:
  167.                     WinPostMsg( hwnd, WM_QUIT, 0L, 0L );
  168.                     return (MRESULT) 0L;
  169.  
  170.                 // Display a message box
  171.                 case IDM_MESSAGE_BOX:
  172.                     WinMessageBox(
  173.                         HWND_DESKTOP,
  174.                         hwnd,
  175.                         "Select the Help Button to see sample help for message boxes.",
  176.                         "IPF Editor Sample Program",
  177.                         IDMB_SAMPLE,
  178.                         MB_OK | MB_HELP | MB_ICONEXCLAMATION );
  179.                     return (MRESULT) 0L;
  180.  
  181.                 // Display a dialog box
  182.                 case IDM_SAMPLE_DIALOG:
  183.                     WinDlgBox(
  184.                         HWND_DESKTOP,
  185.                         hwnd,
  186.                         (PFNWP) IPFEDemoDlgProc,
  187.                         0L,
  188.                         IDD_SAMPLE_DLG,
  189.                         (PVOID) NULL );
  190.                     return (MRESULT) 0L;
  191.             }
  192.             break;
  193.  
  194.         // Erase window
  195.         case WM_PAINT:
  196.             hps = WinBeginPaint( hwnd, 0L, NULL );
  197.             GpiErase( hps );
  198.             WinEndPaint( hps );
  199.             return (MRESULT) 0L;
  200.  
  201.     }
  202.  
  203.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  204. }
  205.  
  206.  
  207. /*****************************************************************
  208.    Function: IPFEDemoDlgProc()
  209.    Author: Bill Perez
  210.    Date: 5/26/1993
  211.    Purpose: Sample dialog box procedure for dialog sample.
  212.  
  213.  
  214.    Revision: 1.0
  215.  
  216.    Revision History:
  217.  
  218.         1.0 - Initial Coding, Bill Perez.
  219.  
  220.  
  221. */
  222. MRESULT EXPENTRY IPFEDemoDlgProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
  223. {
  224.     switch( msg )
  225.     {
  226.         case WM_INITDLG:
  227.             return (MRESULT) 0L;
  228.  
  229.         case WM_COMMAND:
  230.             switch( SHORT1FROMMP( mp1 ) )
  231.             {
  232.                 case IDPB_DONE:
  233.                     WinDismissDlg( hwnd, TRUE );
  234.                     return (MRESULT) 0L;
  235.             }
  236.             return (MRESULT) 0L;
  237.     }
  238.     return WinDefDlgProc( hwnd, msg, mp1, mp2 );
  239. }
  240.  
  241. InstallHelpHook( HAB hab, HMQ hmq )
  242. {
  243.  
  244. }
  245.  
  246.