home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pc3270sa.zip / spl2file / spprsub.c < prev    next >
Text File  |  2002-02-28  |  8KB  |  198 lines

  1. //******************************************************************************
  2. //
  3. //  File name   : SPPRSUB.C
  4. //
  5. //  Description : Common sub functions for the Spl2File
  6. //
  7. //  FUNCTIONS:
  8. //
  9. //  COMMENTS:
  10. //
  11. //  Copyright  (C) 1993, 1996 IBM Corporation
  12. //                        All rights reserved.
  13. //
  14. //******************************************************************************
  15.  
  16. #include <windows.h>                // required for all Windows applications
  17. #include <windowsx.h>               // Windows Macro APIs, window message crackers
  18. #include <string.h>                 // C string functions
  19. #include <stdio.h>                  // C functions
  20.  
  21. #include "spl2file.h"               // specific to this program
  22. #include "spdata.h"                 // Global Data
  23.                                     //
  24. //******************************************************************************
  25. //
  26. // Local Data
  27. //
  28. //******************************************************************************
  29.                                            //
  30. static FARPROC lpAbortDialogProc;          //
  31.                                            //
  32. //******************************************************************************
  33. //
  34. //  DisplayAbortDialog - Display an abort dialog box
  35. //
  36. //  PURPOSE:
  37. //
  38. //  Put a modeless dialog box
  39. //
  40. //  COMMENTS:
  41. //
  42. //******************************************************************************
  43. //BOOL DisplayAbortDialog( HWND hOwnerWnd )
  44. HWND DisplayAbortDialog( HWND hOwnerWnd )
  45. {                                          //
  46.   HWND hDlg;                               //
  47.   lpAbortDialogProc = MakeProcInstance( AbortDialogProc, hGlobalInst );
  48.                                            //
  49.   hDlg = CreateDialog(hGlobalInst, MAKEINTRESOURCE(ABORTBOX),
  50.                       hOwnerWnd, lpAbortDialogProc );
  51.                                            //
  52.   EnableWindow( hOwnerWnd, FALSE );        // Disable the parent
  53.  
  54. //return( (BOOL) hDlg );                   //
  55.   return( hDlg );                          //
  56. }                                          //
  57.  
  58. //******************************************************************************
  59. //
  60. //  DestroyAbortDialog - Destroy the abort dialog box
  61. //
  62. //  PURPOSE:
  63. //
  64. //  Gets rid of the abort dialog and re enables the parent.
  65. //
  66. //  COMMENTS:
  67. //
  68. //******************************************************************************
  69. BOOL DestroyAbortDialog( HWND hAbortDlg, HWND hOwnerWnd )
  70. {                                         //
  71.   DestroyWindow( hAbortDlg );             // Get rid of Window
  72.   FreeProcInstance( lpAbortDialogProc );  // Get rid of proc instance
  73.   EnableWindow( hOwnerWnd, TRUE );        // Enable the parent
  74.  
  75.   return( (BOOL) TRUE );                  //
  76. }                                         //
  77.  
  78. //******************************************************************************
  79. //
  80. //  AbortDialogProc - Abort box dialog procedure
  81. //
  82. //  PURPOSE:
  83. //
  84. //  Process the abort dialog
  85. //
  86. //  COMMENTS:
  87. //
  88. //******************************************************************************
  89. BOOL FAR PASCAL AbortDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  90. {                                        //
  91.   switch (message)                       //
  92.   {                                      //
  93.     case WM_INITDIALOG:                  // message: initialize dialog box
  94.       bUserAbort = FALSE;                //
  95.       CenterDialogOnScreen( hDlg );      // Center it
  96.       SetWindowText(hDlg, zAbortTitle);  // Set the title
  97.       SetFocus( hDlg );                  // Give the dialog focus.
  98.       return(TRUE);                      //
  99.       break;                             //
  100.  
  101.     case WM_COMMAND:                     //
  102.       switch (GET_WM_COMMAND_ID(wParam,lParam))
  103.       {                                  //
  104.         case IDCANCEL:                   // cancel button
  105.           bUserAbort = TRUE;             //
  106.           PostMessage(hMainWnd,          //
  107.                       WM_USER_ABORT,     //
  108.                       (WPARAM)hMainWnd,  //
  109.                       0L );              //
  110.           return(TRUE);                  //
  111.           break;                         //
  112.  
  113.         default:                         //
  114.           break;                         //
  115.       }                                  //
  116.       break;                             //
  117.   }                                      //
  118.   return( FALSE );                       //
  119. }                                        //
  120.  
  121. //******************************************************************************
  122. //
  123. //  InitSession - Initiate session DDE conversation
  124. //
  125. //  PURPOSE:
  126. //
  127. //
  128. //  COMMENTS:
  129. //
  130. //******************************************************************************
  131. BOOL InitSession( void )
  132. {                                          //
  133.   uchar    zTmpSess[10];                   //
  134.  
  135.   lstrcpy ( zTmpSess, zSESSION );          //
  136.   lstrcat ( zTmpSess, zSessionID );        //
  137.   aIBM5250 = GlobalAddAtom ( zIBM5250 );   // Application name
  138.   aSession = GlobalAddAtom ( zTmpSess );   // Topic name
  139.  
  140.   SendMessage ( (HWND)-1,                  // Send Initiate messgae
  141.                 WM_DDE_INITIATE,           //
  142.                 (WPARAM)hMainWnd,          //
  143.                 MAKELONG ( aIBM5250, aSession ) );
  144.                                            //
  145.   GlobalDeleteAtom ( aSession );           //
  146.   GlobalDeleteAtom ( aIBM5250 );           //
  147.  
  148.   return ( ( BOOL ) hSessWnd );            //
  149. }                                          //
  150.  
  151. //******************************************************************************
  152. //
  153. //  TerminateSession - Terminate session DDE conversation
  154. //
  155. //  PURPOSE:
  156. //
  157. //
  158. //  COMMENTS:
  159. //
  160. //******************************************************************************
  161. void TerminateSession ( void )
  162. {                                          //
  163.   if ( hSessWnd )                          //
  164.   {                                        //
  165.     PostMessage ( hSessWnd,                // Post Terminate message
  166.                   WM_DDE_TERMINATE,        //
  167.                   (WPARAM)hMainWnd,        //
  168.                   MAKELONG ( NULL, NULL ) );  //
  169.   }                                        //
  170. }                                          //
  171.  
  172. //******************************************************************************
  173. //
  174. //  FSM_Event - Select Finite State Machine
  175. //
  176. //  PURPOSE:
  177. //
  178. //
  179. //  COMMENTS:
  180. //
  181. //******************************************************************************
  182. BOOL FSM_Event( BYTE Event, ATOM aItem, HANDLE hData )
  183. {
  184.   BOOL  bRC = FALSE;                                 //
  185.                                                      //
  186.   switch (wOperation)                                //
  187.   {                                                  //
  188.     case SPOOL_TO_FILE:                              // Spool to File
  189.       FSM_SpoolToFile( Event, aItem, hData );        //
  190.       bRC = TRUE;                                    //
  191.       break;                                         //
  192.                                                      //
  193.     default:                                         //
  194.       break;                                         //
  195.   }                                                  //
  196.   return (bRC);                                      //
  197. }                                                    //
  198.