home *** CD-ROM | disk | FTP | other *** search
- // Borland ObjectVision -- (C) Copyright 1991 by Borland International
-
- #include <windows.h>
- #include "choice.h"
-
- // ------------------------------------------------------------------- //
- // //
- // Every DLL has an entry point LibMain and an exit point WEP //
- // //
- // ------------------------------------------------------------------- //
-
- // Turn off "Parameter never used" warning
- #pragma argsused
-
- int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
- WORD wHeapSize, LPSTR lpszCmdLine )
- {
- // The startup code for the DLL initializes the local heap (if
- // there is one) with a call to LocalInit which locks the data
- // segment.
- if ( wHeapSize != 0 )
- UnlockData( 0 );
- return 1; // Indicate that the DLL was initialized successfully.
- }
-
- // Turn off "Parameter never used" warning
- #pragma argsused
-
- int FAR PASCAL WEP ( int bSystemExit )
- {
- return 1;
- }
-
- // ------------------------------------------------------------------- //
- // //
- // This sample function is registered and called by the sample OV //
- // application CHOICE.OVD. //
- // //
- // ------------------------------------------------------------------- //
-
- // Argument template = "FACCF"
- LPSTR FAR PASCAL _export ChooseString( BOOL bChoice, LPSTR szTrueString,
- LPSTR szFalseString, LPSTR sOvBuffer )
- {
- if ( bChoice )
- {
- // ObjectVision strings can be up to 4096 characters long
- if ( lstrlen( szTrueString ) <= 4096 )
- {
- lstrcpy( sOvBuffer, szTrueString );
- }
- else
- {
- *sOvBuffer = '\0';
- }
- }
- else
- {
- if ( lstrlen( szFalseString ) <= 4096 )
- {
- lstrcpy( sOvBuffer, szFalseString );
- }
- else
- {
- *sOvBuffer = '\0';
- }
- }
- return sOvBuffer;
- }
-
- // ------------------------------------------------------------------- //
- // //
- // These simple, sample functions illustrate how to call and //
- // return other data types. //
- // //
- // ------------------------------------------------------------------- //
-
- // Argument template = "III"
- int FAR PASCAL _export iSum( int iInteger1, int iInteger2 )
- {
- return( iInteger1 + iInteger2 );
- }
-
- // Argument template = "HHH"
- unsigned FAR PASCAL _export uSum( unsigned uInteger1, unsigned uInteger2 )
- {
- return( uInteger1 + uInteger2 );
- }
-
- // Argument template = "JJJ"
- unsigned long FAR PASCAL _export ulSum( unsigned long ulInteger1,
- unsigned long ulInteger2 )
- {
- return( ulInteger1 + ulInteger2 );
- }
-
- // Argument template = "IAA"
- int FAR PASCAL _export bSum( int iBool1, int iBool2 )
- {
- return( iBool1 + iBool2 );
- }
-
- // Argument template = "IAII"
- int FAR PASCAL _export iIfInt( int iCond, int iTrue, int iFalse )
- {
- return iCond ? iTrue : iFalse;
- }
-
- // Argument template = "I"
- int FAR PASCAL _export NoArgs( void )
- {
- return 42;
- }
-
- // Argument template = "BBB"
- typedef double far * LPDOUBLE;
- LPDOUBLE FAR PASCAL _export fSum( double fArg1, double fArg2 )
- {
- static double temp;
- temp = fArg1 + fArg2;
- return (LPDOUBLE)&temp;
- }
-
- // Argument template = "CCC"
- LPSTR FAR PASCAL _export sSum( LPSTR lpszArg1, LPSTR lpszArg2 )
- {
- static char sBuf[200];
- // You are responsible for making sure the buffer doesn't overflow.
- // ObjectVision 2.0 strings can be up to 4096 characters long.
- lstrcpy( sBuf, lpszArg1 ); // Warning: could overflow the buffer
- lstrcat( sBuf, lpszArg2 ); // Warning: could overflow the buffer
- return (LPSTR)sBuf;
- }
-
- // Argument template = "CxC"
- LPSTR FAR PASCAL _export GetFieldValue( OVCALLBACK_GET lpfnCallBack, LPSTR lpField )
- {
- static char sBuf[257];
- char far * lpResult;
-
- lpResult = (*lpfnCallBack)( lpField );
- if ( lpResult && lstrlen(lpResult) < sizeof(sBuf) )
- {
- lstrcpy( sBuf, lpResult );
- }
- else
- {
- lstrcpy( sBuf, "<Field doesn't exist or result is too long>" );
- }
- return (LPSTR)sBuf;
- }
-
- // Argument template = "HwCC"
- unsigned FAR PASCAL _export PutFieldValue( OVCALLBACK_PUT lpfnCallBack, LPSTR lpField, LPSTR lpValue )
- {
- (*lpfnCallBack)( lpField, lpValue );
- return 0;
- }
-
- // Argument template = "HuC" or "HvC"
- unsigned FAR PASCAL _export ResetStatus( OVCALLBACK_RESET lpfnCallBack, LPSTR lpField )
- {
- (*lpfnCallBack)( lpField );
- return 0;
- }
-