home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a530 / 1.ddi / OVSMP.PAK / CHOICE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-30  |  4.9 KB  |  167 lines

  1. // Borland ObjectVision -- (C) Copyright 1991 by Borland International
  2.  
  3. #include <windows.h>
  4. #include "choice.h"
  5.  
  6. // ------------------------------------------------------------------- //
  7. //                                                                     //
  8. //   Every DLL has an entry point LibMain and an exit point WEP        //
  9. //                                                                     //
  10. // ------------------------------------------------------------------- //
  11.  
  12. // Turn off "Parameter never used" warning
  13. #pragma argsused
  14.  
  15. int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
  16.                         WORD wHeapSize, LPSTR lpszCmdLine )
  17. {
  18.     // The startup code for the DLL initializes the local heap (if
  19.     // there is one) with a call to LocalInit which locks the data
  20.     // segment.
  21.     if ( wHeapSize != 0 )
  22.         UnlockData( 0 );
  23.     return 1;   // Indicate that the DLL was initialized successfully.
  24. }
  25.  
  26. // Turn off "Parameter never used" warning
  27. #pragma argsused
  28.  
  29. int FAR PASCAL WEP ( int bSystemExit )
  30. {
  31.     return 1;
  32. }
  33.  
  34. // ------------------------------------------------------------------- //
  35. //                                                                     //
  36. //   This sample function is registered and called by the sample OV    //
  37. //   application CHOICE.OVD.                                           //
  38. //                                                                     //
  39. // ------------------------------------------------------------------- //
  40.  
  41. // Argument template = "FACCF"
  42. LPSTR FAR PASCAL _export ChooseString( BOOL bChoice, LPSTR szTrueString,
  43.                                        LPSTR szFalseString, LPSTR sOvBuffer )
  44. {
  45.     if ( bChoice )
  46.     {
  47.         // ObjectVision strings can be up to 4096 characters long
  48.         if ( lstrlen( szTrueString ) <= 4096 )
  49.         {
  50.             lstrcpy( sOvBuffer, szTrueString );
  51.         }
  52.         else
  53.         {
  54.             *sOvBuffer = '\0';
  55.         }
  56.     }
  57.     else
  58.     {
  59.         if ( lstrlen( szFalseString ) <= 4096 )
  60.         {
  61.             lstrcpy( sOvBuffer, szFalseString );
  62.         }
  63.         else
  64.         {
  65.             *sOvBuffer = '\0';
  66.         }
  67.     }
  68.     return sOvBuffer;
  69. }
  70.  
  71. // ------------------------------------------------------------------- //
  72. //                                                                     //
  73. //   These simple, sample functions illustrate how to call and         //
  74. //   return other data types.                                          //
  75. //                                                                     //
  76. // ------------------------------------------------------------------- //
  77.  
  78. // Argument template = "III"
  79. int FAR PASCAL _export iSum( int iInteger1, int iInteger2 )
  80. {
  81.     return( iInteger1 + iInteger2 );
  82. }
  83.  
  84. // Argument template = "HHH"
  85. unsigned FAR PASCAL _export uSum( unsigned uInteger1, unsigned uInteger2 )
  86. {
  87.     return( uInteger1 + uInteger2 );
  88. }
  89.  
  90. // Argument template = "JJJ"
  91. unsigned long FAR PASCAL _export ulSum( unsigned long ulInteger1,
  92.                                         unsigned long ulInteger2 )
  93. {
  94.     return( ulInteger1 + ulInteger2 );
  95. }
  96.  
  97. // Argument template = "IAA"
  98. int FAR PASCAL _export bSum( int iBool1, int iBool2 )
  99. {
  100.     return( iBool1 + iBool2 );
  101. }
  102.  
  103. // Argument template = "IAII"
  104. int FAR PASCAL _export iIfInt( int iCond, int iTrue, int iFalse )
  105. {
  106.     return iCond ? iTrue : iFalse;
  107. }
  108.  
  109. // Argument template = "I"
  110. int FAR PASCAL _export NoArgs( void  )
  111. {
  112.     return 42;
  113. }
  114.  
  115. // Argument template = "BBB"
  116. typedef double far * LPDOUBLE;
  117. LPDOUBLE FAR PASCAL _export fSum( double fArg1, double fArg2 )
  118. {
  119.     static double temp;
  120.     temp = fArg1 + fArg2;
  121.     return (LPDOUBLE)&temp;
  122. }
  123.  
  124. // Argument template = "CCC"
  125. LPSTR FAR PASCAL _export sSum( LPSTR lpszArg1, LPSTR lpszArg2 )
  126. {
  127.     static char sBuf[200];
  128.     // You are responsible for making sure the buffer doesn't overflow.
  129.     // ObjectVision 2.0 strings can be up to 4096 characters long.
  130.     lstrcpy( sBuf, lpszArg1 ); // Warning: could overflow the buffer
  131.     lstrcat( sBuf, lpszArg2 ); // Warning: could overflow the buffer
  132.     return (LPSTR)sBuf;
  133. }
  134.  
  135. // Argument template = "CxC"
  136. LPSTR FAR PASCAL _export GetFieldValue( OVCALLBACK_GET lpfnCallBack, LPSTR lpField )
  137. {
  138.     static char sBuf[257];
  139.     char far * lpResult;
  140.  
  141.     lpResult = (*lpfnCallBack)( lpField );
  142.     if ( lpResult && lstrlen(lpResult) < sizeof(sBuf) )
  143.     {
  144.         lstrcpy( sBuf, lpResult );
  145.     }
  146.     else
  147.     {
  148.         lstrcpy( sBuf, "<Field doesn't exist or result is too long>" );
  149.     }
  150.     return (LPSTR)sBuf;
  151. }
  152.  
  153. // Argument template = "HwCC"
  154. unsigned FAR PASCAL _export PutFieldValue( OVCALLBACK_PUT lpfnCallBack, LPSTR lpField, LPSTR lpValue )
  155. {
  156.     (*lpfnCallBack)( lpField, lpValue );
  157.     return 0;
  158. }
  159.  
  160. // Argument template = "HuC" or "HvC"
  161. unsigned FAR PASCAL _export ResetStatus( OVCALLBACK_RESET lpfnCallBack, LPSTR lpField )
  162. {
  163.     (*lpfnCallBack)( lpField );
  164.     return 0;
  165. }
  166.  
  167.