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

typedef struct
{
   WORD wLeft, wTop, wWidth, wHeight;
   WORD wId;
   LONG lStyle;
} CONTROL;

HGLOBAL fwGlobalAlloc( WORD wType, LONG lBytes );

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

CLIPPER cCtrl2Chr()  // ( nTop, nLeft, nBottom, nRight, nId, nStyle,
                     //   cClassName, cCaption )  --> cControlString
{
   HGLOBAL hMem;
   LPBYTE pBuffer;
   LPSTR szText;
   WORD wLen = 14;

   hMem = fwGlobalAlloc( GPTR, sizeof( CONTROL ) + _parclen( 7 ) + _parclen( 8 ) + 3 );

   if( hMem )
   {
       pBuffer = GlobalLock( hMem );

       ( ( CONTROL * ) pBuffer )->wLeft   = _parni( 2 );
       ( ( CONTROL * ) pBuffer )->wTop    = _parni( 1 );
       ( ( CONTROL * ) pBuffer )->wWidth  = _parni( 4 ) - _parni( 2 ) + 1;
       ( ( CONTROL * ) pBuffer )->wHeight = _parni( 3 ) - _parni( 1 ) + 1;
       ( ( CONTROL * ) pBuffer )->wId     = _parni( 5 );
       ( ( CONTROL * ) pBuffer )->lStyle  = _parnl( 6 );

       szText = _parc( 7 );
       while( * szText )
          pBuffer[ wLen++ ] = * szText++;
       pBuffer[ wLen++ ] = 0;

       szText = _parc( 8 );
       while( * szText )
          pBuffer[ wLen++ ] = * szText++;
       pBuffer[ wLen++ ]= 0;
       pBuffer[ wLen++ ]= 0;

       _retclen( pBuffer, wLen );

       GlobalUnlock( hMem );
       GlobalFree( hMem );
   }
   else
      _retc("");
}

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

CLIPPER GETDIALOGB() // ASEUNITS()    no params  -->  { nWidth, nHeight }
{
   DWORD dw = GetDialogBaseUnits();

   _reta( 2 );
   _storni( LOWORD( dw ) / 4, -1, 1 );
   _storni( HIWORD( dw ) / 8, -1, 2 );
}

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