home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv4_6 / newwave / nwfig21.c next >
Encoding:
Text File  |  1989-11-07  |  4.8 KB  |  107 lines

  1. /********************************************************************/
  2. /*                          ShapeWndProc                            */
  3. /*                                                                  */
  4. /*       Main procedure to handle all messages sent to HPSHAPE.     */
  5. /*                                                                  */
  6. /*          COPYRIGHT HEWLETT-PACKARD COMPANY 1987, 1988            */
  7. /********************************************************************/
  8.  
  9. long FAR PASCAL ShapeWndProc( hWnd, message, wParam, lParam )
  10.     HWND            hWnd;
  11.     unsigned        message;         
  12.     WORD            wParam;
  13.     LONG            lParam;
  14. {
  15.     APIRTNTYPE      applRtn;  /* used as a return value */
  16.     APICMDSTRUCT    extCmd;   /* the external command struc for apl */
  17.     INTCMDSTRUCT    intCmd;   /* the internal command struc for apl */
  18.  
  19.  
  20.     /* function called for windows that are created with            */
  21.     /* NW_CreateWindow to specially handle some messages            */
  22.  
  23.     if( NW_MessageFilter(hWnd, message, wParam, lParam,
  24.                                                (LONG FAR *) &applRtn))
  25.         {
  26.         return (applRtn);
  27.         }
  28.  
  29.     /* is API to intercept messages or has an API menu item been    */
  30.     /* seleceted such as the help or the task                       */
  31.  
  32.     if( APIInterceptOn(gAPIModeFlags) || APIHaveMenu (message, wParam))
  33.         {
  34.         /* is this a message for the API - may set certain flags    */
  35.         APIUserActionInterface(ghAPI, hWnd, (LPAPIUNSIGNED)&message,
  36.                                  wParam, lParam, API_NO_MODE);
  37.         }
  38.  
  39.     applRtn = (APIERRTYPE)0L;        
  40.     /* Still a command to be handled? or did APIUserAct.. take it?  */
  41.     if( APIHaveMessage (message) )
  42.         {
  43.         intCmd.wCmd = API_NO_CMD;           
  44.          
  45.         /* are we currently playing back a message or recorded task */
  46.         if (APIPlaybackMsg(message))                                 
  47.             /* translate to the internal format of the application  */
  48.             TranslateToInternalProcessor(message, wParam, lParam,
  49.                                                             &intCmd);
  50.         else                                                          
  51.             /* you are in record mode or a user interactive command */
  52.             ActionProcessor(hWnd, message, wParam, lParam, &intCmd,     
  53.                             &applRtn);
  54.                                                                       
  55.         /* Is there a command created in the action processor?      */
  56.         /* that need to be executed */
  57.         if( APIHaveCommand(intCmd.wCmd) )
  58.             {
  59.             gapplErr = API_NO_ERR;      
  60.                        
  61.             /* are we in  a CBT */
  62.             if( APIMonitorOn(gAPIModeFlags) )
  63.                {   
  64.                 /* set to external language and pass the external   */
  65.                 /* form of the command to the Agent                 */
  66.  
  67.                 TranslateToExternalProcessor(&intCmd,&extCmd);
  68.                 APICommandInterface(ghAPI, (LPAPICMDSTRUCT)&extCmd,
  69.                                     API_NO_MODE);
  70.                 /* the internal command must be cancelled if the    */
  71.                 /*  APICommandInterface or APIClgCommandInterface   */
  72.                 /*  has nullified the command */
  73.                 if (extCmd.wCmd == API_NO_CMD)
  74.                    intCmd.wCmd = API_NO_CMD;
  75.                }
  76.  
  77.             /* has  the command been formed  and has to be executed */
  78.             if( APIHaveCommand(intCmd.wCmd) )
  79.                 /* perform the command */
  80.                 CommandProcessor(hWnd, message, wParam, lParam, &intCmd,
  81.                                  &applRtn);
  82.                          
  83.             /* is a command being played back or being recorded     */
  84.             if( APIPlaybackOn(gAPIModeFlags) ||
  85.                                     APIRecordOn (gAPIModeFlags))
  86.                 {
  87.                 if( APIRecordOn(gAPIModeFlags) )
  88.                     {
  89.                     /* translate to ext lang and tell Agent that    */
  90.                     /* command is complete and ready for next       */
  91.                     /* command                                      */
  92.                     TranslateToExternalProcessor(&intCmd,&extCmd);
  93.                     APIRecordInterface(ghAPI,(LPAPICMDSTRUCT)&extCmd,
  94.                                        API_NO_MODE);            
  95.                     }                                           
  96.                 /* return control back to the user */
  97.                 APIReturnInterface( ghAPI, gapplErr, API_NO_MODE );
  98.                 }
  99.  
  100.             } /* EndIf of APIHaveCommand */
  101.  
  102.         }  /* EndIf of APIHaveMessage */
  103.  
  104.     return(applRtn);    
  105.  
  106. } /* End of ShapeWndProc */
  107.