#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

extern BOOL bWRunning( void );

//----------------------------------------------------------------------------//

CLIPPER MESSAGEBOX()
{
   _retni( MessageBox( _parni( 1 ), _parc( 2 ), _parc( 3 ), _parni( 4 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER nMsgBox()
{
   char * cTitle = ( PCOUNT() > 1 ) ? _parc( 2 ): "Alert";
   char * cText;

   if( PCOUNT() > 0 )
   {
      if( ISCHAR( 1 ) )
         cText = _parc( 1 );
      else
         cText = "String expression required in nMsgBox()";
   }

   _retni( MessageBox( bWRunning() ? GetActiveWindow(): 0,
                       cText, cTitle, _parni( 3 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER MsgAlert()
{
   char * cTitle  = "Atention";
   char * cText;

   if( PCOUNT() > 0 )
   {
      if( ISCHAR( 1 ) )
         cText = _parc( 1 );
      else
         cText = "String expression required in MsgAlert()";
   }

   _retni( MessageBox( bWRunning() ? GetActiveWindow(): 0,
                       cText, ( PCOUNT() > 1 ) ? _parc( 2 ): cTitle,
                       MB_ICONEXCLAMATION ) );
}

//----------------------------------------------------------------------------//

CLIPPER MsgInfo()
{
   char * cTitle  = "Information";
   char * cText;

   if( PCOUNT() > 0 )
   {
      if( ISCHAR( 1 ) )
         cText = _parc( 1 );
      else
         cText = "String expression required in MsgInfo()";
   }

   _retni( MessageBox( bWRunning() ? GetActiveWindow(): 0,
                       cText, ( PCOUNT() > 1 ) ? _parc( 2 ): cTitle,
                       MB_ICONINFORMATION ) );
}

//----------------------------------------------------------------------------//

CLIPPER MsgStop()
{
   char * cTitle = ( PCOUNT() > 1 ) ? _parc( 2 ): "Stop!";
   char * cText;

   if( PCOUNT() > 0 )
   {
      if( ISCHAR( 1 ) )
         cText = _parc( 1 );
      else
         cText = "String expression required in MsgStop()";
   }

   _retni( MessageBox( bWRunning() ? GetActiveWindow(): 0,
                       cText, ( PCOUNT() > 1 ) ? _parc( 2 ): cTitle,
                       MB_ICONSTOP ) );
}

//----------------------------------------------------------------------------//

CLIPPER MsgYesNo()
{
   char * cTitle = ( PCOUNT() > 1 ) ? _parc( 2 ): "Please, select";
   char * cText;

   if( PCOUNT() > 0 )
   {
      if( ISCHAR( 1 ) )
         cText = _parc( 1 );
      else
         cText = "String expression required in MsgYesNo()";
   }

   _retl( MessageBox( bWRunning() ? GetActiveWindow(): 0,
                      cText, cTitle,
                      MB_YESNO | MB_ICONQUESTION ) == 6 );
}

//----------------------------------------------------------------------------//
