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

  1. //******************************************************************************
  2. //
  3. //  File name   : SPSUB1.C
  4. //
  5. //  Description :Misc functions, etc for the MyPrint DDE application
  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 <string.h>                 // C string functions
  18. #include <stdio.h>                  // C functions
  19.  
  20. #include "spl2file.h"               // specific to this program
  21. #include "spdata.h"                 // Global Data
  22.  
  23. //******************************************************************************
  24. //
  25. // TerminateConversation - Terminate the DDE Conversation
  26. //
  27. //  Abstract:
  28. //
  29. //  This function checks for existence of the target window and if it exists
  30. //  Post's the message to the window. if the Window does not exist return
  31. //  FALSE;
  32. //
  33. //******************************************************************************
  34. BOOL TerminateConversation( void )
  35. {                                                //
  36.   DDEPostMessage(hDDEClientWnd, WM_DDE_TERMINATE, (WPARAM)hMainWnd, 0L );
  37.                                                  //
  38.   hDDEClientWnd = NULL;                          // Ensure conversation severed.
  39.  
  40.   return( TRUE );                                //
  41. }                                                //
  42.  
  43. //******************************************************************************
  44. //
  45. // DDEPostMessage - Post a PC/5250 Client DDE message
  46. //
  47. //  Abstract:
  48. //
  49. //  This function checks for existence of the target window and if it exists
  50. //  Post's the message to the window. if the Window does not exist return
  51. //  FALSE;
  52. //
  53. //******************************************************************************
  54. BOOL DDEPostMessage( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
  55. {
  56.   if( IsWindow(hWnd) )                            // Does Window exist?
  57.   {                                               // Yes, post the message
  58.     return( PostMessage( hWnd, message, wParam, lParam ) );
  59.   }                                               //
  60.  
  61.   return(FALSE);                                  //
  62. }                                                 //
  63.  
  64. //******************************************************************************
  65. //
  66. //  FUNCTION: CenterDialogOnScreen
  67. //
  68. //  PURPOSE: Centers the dialog on the display screen
  69. //
  70. //******************************************************************************
  71. void CenterDialogOnScreen( HWND hWnd )
  72. {
  73.   RECT r;
  74.  
  75.   GetWindowRect(hWnd, &r);
  76.  
  77.   r.left = (GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) / 2;
  78.   r.top  = (GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) / 2;
  79.  
  80.   SetWindowPos(hWnd, NULL, r.left, r.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
  81.   SetForegroundWindow(hWnd);
  82. }
  83.  
  84. //******************************************************************************
  85. //
  86. //  FUNCTION: OffsetInPs( int nRow, int nCol )
  87. //
  88. //  PURPOSE: Get the offset in Ps.
  89. //
  90. //******************************************************************************
  91. int OffsetInPs( int nRow, int nCol )
  92. {                                                //
  93.   return ( (nRow - 1) * MAX_COL + nCol - 1 );    //
  94. }                                                //
  95.  
  96. //******************************************************************************
  97. //
  98. //  FUNCTION: GetStartEndCol( LPSTR lpData, LPINT lpnStartCol, LPINT lpnEndCol )
  99. //
  100. //  PURPOSE: Get the Start and End column position from the screen data
  101. //
  102. //******************************************************************************
  103. void GetStartEndCol( LPSTR lpData, LPINT lpnStartCol, LPINT lpnEndCol )
  104. {
  105.   int    i=0;                                         //
  106.  
  107.   *lpnStartCol = 0;                                   //
  108.   *lpnEndCol = 0;                                     //
  109.   while ( (lpData[i] >= '0') && (lpData[i] <= '9') )  // numeric character?
  110.   {                                                   //
  111.     *lpnStartCol *= 10;                               // convert ascii to number
  112.     *lpnStartCol += (int)(lpData[i] - '0');           //
  113.     i++;                                              //
  114.   }                                                   //
  115.   i += 3;                                             //
  116.   while ( (lpData[i] >= '0') && (lpData[i] <= '9') )  // numeric character?
  117.   {                                                   //
  118.     *lpnEndCol *= 10;                                 // convert ascii to number
  119.     *lpnEndCol += (int)(lpData[i] - '0');             //
  120.     i++;                                              //
  121.   }                                                   //
  122. }                                                     //
  123.  
  124. //******************************************************************************
  125. //
  126. //  FUNCTION: IsDbcsHiByte( BYTE byValue )
  127. //
  128. //  PURPOSE: Checks if the specified value is a DBCS Hi-Byte in PC code page.
  129. //
  130. //******************************************************************************
  131. BOOL IsDbcsHiByte( BYTE byValue )
  132. {                                                     //
  133.   if (((byValue >= 0x81) && (byValue <= 0x9f)) ||     //
  134.       ((byValue >= 0xe0) && (byValue <= 0xfc)))       //
  135.   {                                                   //
  136.     return (TRUE);                                    //
  137.   }                                                   //
  138.   else                                                //
  139.   {                                                   //
  140.     return (FALSE);                                   //
  141.   }                                                   //
  142. }                                                     //
  143.  
  144. //******************************************************************************
  145. //
  146. //  FUNCTION: IsSoSi( BYTE byValue )
  147. //
  148. //  PURPOSE: Checks if the specified value is SO (0x0e) or SI (0x0f).
  149. //
  150. //******************************************************************************
  151. BOOL IsSoSi( BYTE byValue )
  152. {                                                     //
  153.   if ((byValue == 0x0e) || (byValue == 0x0f))         //
  154.   {                                                   //
  155.     return (TRUE);                                    //
  156.   }                                                   //
  157.   else                                                //
  158.   {                                                   //
  159.     return (FALSE);                                   //
  160.   }                                                   //
  161. }                                                     //
  162.