POINT * hbwapi_par_POINT( POINT * p, int iParam, HB_BOOL bMandatory ) { PHB_ITEM pStru = hb_param( iParam, HB_IT_ANY ); memset( p, 0, sizeof( POINT ) ); if( pStru && HB_IS_HASH( pStru ) ) { p->x = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "x" ) ); p->y = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "y" ) ); return p; } else if( pStru && HB_IS_ARRAY( pStru ) && hb_arrayLen( pStru ) >= 2 ) { p->x = ( LONG ) hb_arrayGetNL( pStru, 1 ); p->y = ( LONG ) hb_arrayGetNL( pStru, 2 ); return p; } else if( bMandatory ) return p; return NULL; }
static HB_BOOL s_fileTimeGet( PHB_FILE_FUNCS pFuncs, const char * pszFileName, long * plJulian, long * plMillisec ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_BOOL fResult; int iOffset; iOffset = ( int ) ( hb_stackTopOffset() - hb_stackBaseOffset() ); hb_vmPushNil(); hb_vmPushNil(); s_pushMethod( pIO, IOUSR_TIMEGET ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_xvmPushLocalByRef( ( HB_SHORT ) iOffset ); hb_xvmPushLocalByRef( ( HB_SHORT ) ( iOffset + 1 ) ); hb_vmDo( 3 ); fResult = hb_parl( -1 ); if( fResult ) { *plJulian = hb_itemGetNL( hb_stackItemFromBase( iOffset ) ); *plMillisec = hb_itemGetNL( hb_stackItemFromBase( iOffset + 1 ) ); } hb_stackPop(); hb_stackPop(); return fResult; }
RECT * hbwapi_par_RECT( RECT * p, int iParam, HB_BOOL bMandatory ) { PHB_ITEM pStru = hb_param( iParam, HB_IT_ANY ); memset( p, 0, sizeof( RECT ) ); if( pStru && HB_IS_HASH( pStru ) ) { p->left = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "left" ) ); p->top = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "top" ) ); p->right = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "right" ) ); p->bottom = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "bottom" ) ); return p; } else if( pStru && HB_IS_ARRAY( pStru ) && hb_arrayLen( pStru ) >= 4 ) { p->left = ( LONG ) hb_arrayGetNL( pStru, 1 ); p->top = ( LONG ) hb_arrayGetNL( pStru, 2 ); p->right = ( LONG ) hb_arrayGetNL( pStru, 3 ); p->bottom = ( LONG ) hb_arrayGetNL( pStru, 4 ); return p; } else if( bMandatory ) return p; return NULL; }
DOCINFO * hbwapi_par_DOCINFO( DOCINFO * p, int iParam, HB_BOOL bMandatory, void *** ph ) { PHB_ITEM pStru = hb_param( iParam, HB_IT_ANY ); void ** h = ( void ** ) hb_xgrabz( 3 * sizeof( void * ) ); *ph = h; memset( p, 0, sizeof( DOCINFO ) ); p->cbSize = sizeof( DOCINFO ); if( pStru && HB_IS_HASH( pStru ) ) { p->lpszDocName = HB_ITEMGETSTR( hb_hashGetCItemPtr( pStru, "lpszDocName" ), &h[ 0 ], NULL ); p->lpszOutput = HB_ITEMGETSTR( hb_hashGetCItemPtr( pStru, "lpszOutput" ), &h[ 1 ], NULL ); p->lpszDatatype = HB_ITEMGETSTR( hb_hashGetCItemPtr( pStru, "lpszDatatype" ), &h[ 2 ], NULL ); p->fwType = ( DWORD ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "fwType" ) ); return p; } else if( bMandatory ) return p; hb_xfree( h ); *ph = NULL; return NULL; }
/* * Position the cursor to a specific, physical identity. */ static HB_ERRCODE hb_sdfGoToId( SDFAREAP pArea, PHB_ITEM pItem ) { HB_TRACE( HB_TR_DEBUG, ( "hb_sdfGoToId(%p, %p)", pArea, pItem ) ); #ifndef HB_CLP_STRICT if( HB_IS_NUMERIC( pItem ) ) return SELF_GOTO( &pArea->area, hb_itemGetNL( pItem ) ); #endif /* generate RTE */ return SUPER_GOTOID( &pArea->area, pItem ); }
static HB_ERRCODE sqlbaseGoToId( SQLBASEAREAP pArea, PHB_ITEM pItem ) { PHB_ITEM pError; if( HB_IS_NUMERIC( pItem ) ) return SELF_GOTO( ( AREAP ) pArea, hb_itemGetNL( pItem ) ); else { pError = hb_errNew(); hb_errPutGenCode( pError, EG_DATATYPE ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_DATATYPE ) ); hb_errPutSubCode( pError, EDBF_DATATYPE ); SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); return HB_FAILURE; } }
void hb_socekxParamsInit( PHB_SOCKEX pSock, PHB_ITEM pParams ) { if( pParams && HB_IS_HASH( pParams ) ) { PHB_ITEM pItem; if( ( pItem = hb_hashGetCItemPtr( pParams, "readahead" ) ) != NULL && HB_IS_NUMERIC( pItem ) ) { if( pSock->buffer == NULL ) pSock->readahead = hb_itemGetNL( pItem ); } if( ( pItem = hb_hashGetCItemPtr( pParams, "flush" ) ) != NULL && HB_IS_NUMERIC( pItem ) ) pSock->iAutoFlush = hb_itemGetNI( pItem ); if( ( pItem = hb_hashGetCItemPtr( pParams, "redir" ) ) != NULL && HB_IS_LOGICAL( pItem ) ) pSock->fRedirAll = hb_itemGetL( pItem ); } }
static HB_BOOL s_fileAttrGet( PHB_FILE_FUNCS pFuncs, const char * pszFileName, HB_FATTR * pnAttr ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_BOOL fResult; int iOffset; iOffset = ( int ) ( hb_stackTopOffset() - hb_stackBaseOffset() ); hb_vmPushNil(); s_pushMethod( pIO, IOUSR_ATTRGET ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_xvmPushLocalByRef( ( HB_SHORT ) iOffset ); hb_vmDo( 2 ); fResult = hb_parl( -1 ); if( fResult ) *pnAttr = ( HB_FATTR ) hb_itemGetNL( hb_stackItemFromBase( iOffset ) ); hb_stackPop(); return fResult; }
/* * Retorna o valor LONG de uma variavel numérica do xHarbour, criada via .PRG * 01/07/2008 - 08:40:47 */ LONG wxMemvarGetNL( char * szVarName ) { HB_THREAD_STUB HB_DYNS_PTR pDynVar; LONG result = 0; HB_TRACE(HB_TR_DEBUG, ("hb_memvarGetStrValuePtr(%s, %p)", szVarName, pulLen)); #ifdef HB_THREAD_SUPPORT pDynVar = s_memvarThFindName( szVarName, &HB_VM_STACK ); #else pDynVar = hb_dynsymFindName( szVarName ); #endif if( pDynVar ) { /* there is dynamic symbol with the requested name - check if it is * a memvar variable */ if( pDynVar->hMemvar ) { /* variable contains some data */ HB_ITEM_PTR pItem = hb_memvarGetValueByHandle( pDynVar->hMemvar ); if( HB_IS_BYREF( pItem ) ) { pItem = hb_itemUnRef( pItem ); /* it is a PARAMETER variable */ } if( HB_IS_NUMERIC( pItem ) ) { result = hb_itemGetNL( pItem ); } } } return result; }
HB_ERRCODE hb_dbTransStruct( AREAP lpaSource, AREAP lpaDest, LPDBTRANSINFO lpdbTransInfo, PHB_ITEM * pStruct, PHB_ITEM pFields ) { HB_USHORT uiFields, uiSize, uiCount, uiPosSrc, uiPosDst, uiSizeSrc, uiSizeDst; HB_ERRCODE errCode; const char * szField; HB_BOOL fAll; errCode = SELF_FIELDCOUNT( lpaSource, &uiSizeSrc ); if( errCode != HB_SUCCESS ) return errCode; if( lpaDest ) { errCode = SELF_FIELDCOUNT( lpaDest, &uiSizeDst ); if( errCode != HB_SUCCESS ) return errCode; uiSize = HB_MIN( uiSizeDst, uiSizeSrc ); } else { uiSize = uiSizeDst = uiSizeSrc; } if( ! uiSize ) return HB_FAILURE; if( hb_itemType( pFields ) & HB_IT_ARRAY ) { uiFields = ( HB_USHORT ) hb_arrayLen( pFields ); if( uiFields ) uiSize = uiFields; } else uiFields = 0; fAll = ( uiSizeDst == uiSizeSrc ); lpdbTransInfo->lpaSource = lpaSource; lpdbTransInfo->lpaDest = lpaDest; lpdbTransInfo->lpTransItems = ( LPDBTRANSITEM ) hb_xgrab( uiSize * sizeof( DBTRANSITEM ) ); if( ! lpaDest ) { *pStruct = hb_itemNew( NULL ); hb_arrayNew( *pStruct, 0 ); } if( uiFields == 0 ) { if( lpaDest ) { PHB_ITEM pItem = hb_itemNew( NULL ); uiSize = 0; for( uiCount = 1; uiCount <= uiSizeSrc; ++uiCount ) { if( SELF_FIELDINFO( lpaSource, uiCount, DBS_NAME, pItem ) != HB_SUCCESS ) { uiSize = 0; break; } szField = hb_itemGetCPtr( pItem ); uiPosDst = hb_rddFieldExpIndex( lpaDest, szField ); if( uiPosDst != uiCount ) fAll = HB_FALSE; if( uiPosDst ) { HB_USHORT ui; /* check for replicated field names in source area */ for( ui = 0; ui < uiSize; ++ui ) { if( lpdbTransInfo->lpTransItems[ ui ].uiDest == uiPosDst ) break; } if( ui == uiSize ) { lpdbTransInfo->lpTransItems[ uiSize ].uiSource = uiCount; lpdbTransInfo->lpTransItems[ uiSize++ ].uiDest = uiPosDst; } } } hb_itemRelease( pItem ); } else { hb_tblStructure( lpaSource, *pStruct, 0 ); uiSize = ( HB_USHORT ) hb_arrayLen( *pStruct ); for( uiCount = 0; uiCount < uiSize; ++uiCount ) { lpdbTransInfo->lpTransItems[ uiCount ].uiSource = lpdbTransInfo->lpTransItems[ uiCount ].uiDest = uiCount + 1; } } } else { uiSize = 0; for( uiCount = 1; uiCount <= uiFields; ++uiCount ) { szField = hb_dbTransFieldPos( pFields, uiCount ); if( szField ) { uiPosSrc = hb_rddFieldExpIndex( lpaSource, szField ); if( ! uiPosSrc ) continue; if( lpaDest ) uiPosDst = hb_rddFieldExpIndex( lpaDest, szField ); else uiPosDst = uiSize + 1; if( uiPosDst ) { if( uiPosSrc != uiPosDst ) fAll = HB_FALSE; lpdbTransInfo->lpTransItems[ uiSize ].uiSource = uiPosSrc; lpdbTransInfo->lpTransItems[ uiSize++ ].uiDest = uiPosDst; if( ! lpaDest ) { hb_arraySize( *pStruct, uiSize ); hb_fldStructure( lpaSource, uiPosSrc, 0, hb_arrayGetItemPtr( *pStruct, uiSize ) ); } } } } } if( uiSize != uiSizeSrc ) fAll = HB_FALSE; if( fAll && lpaDest ) { PHB_ITEM pSrcItm = hb_itemNew( NULL ), pDstItm = hb_itemNew( NULL ); /* * if fAll is HB_TRUE here then it means that all fields are included * and they are on the same positions in both tables, so now check * if their types and sizes are also equal */ for( uiCount = 1; uiCount <= uiSize; ++uiCount ) { if( SELF_FIELDINFO( lpaSource, uiCount, DBS_TYPE, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_TYPE, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_stricmp( hb_itemGetCPtr( pSrcItm ), hb_itemGetCPtr( pDstItm ) ) != 0 ) { fAll = HB_FALSE; break; } if( SELF_FIELDINFO( lpaSource, uiCount, DBS_LEN, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_LEN, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_itemGetNL( pSrcItm ) != hb_itemGetNL( pDstItm ) ) { fAll = HB_FALSE; break; } if( SELF_FIELDINFO( lpaSource, uiCount, DBS_DEC, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_DEC, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_itemGetNL( pSrcItm ) != hb_itemGetNL( pDstItm ) ) { fAll = HB_FALSE; break; } #ifdef DBS_FLAG if( SELF_FIELDINFO( lpaSource, uiCount, DBS_FLAG, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_FLAG, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_itemGetNL( pSrcItm ) != hb_itemGetNL( pDstItm ) ) { fAll = HB_FALSE; break; } #endif } hb_itemRelease( pSrcItm ); hb_itemRelease( pDstItm ); } lpdbTransInfo->uiFlags = fAll ? DBTF_MATCH : 0; lpdbTransInfo->uiItemCount = uiSize; return uiSize ? HB_SUCCESS : HB_FAILURE; }
// 26/07/2008 - 11:32:47 static void printf_add_conv( PPrintInfo pInfo, PHB_ITEM pItem ) { char flag = 0; int width = 0; int precision = 0; char specifier = '\0'; char m = '\0'; char c; char mask[20]; const char *t1; const char *t2; char * cValue; double dValue; ULONG Length; /* * Procura por uma string de conversao com o formato: * 0 1 2 3 4 * %[flags][width][.precision][length]specifier * */ t1 = pInfo->Mask; mask[0] = '\0'; pInfo->Mask ++; pInfo->msk_len--; /* * Se nao tem nenhum item de argumento, e o proximo caracter de escape nao for * o "%", entao temos que abortar a rotina... indicando erro de argumento! */ if (pInfo->msk_len && // pInfo->Mask[0] != '%' && !pItem) { pInfo->error = FAILURE; return; } /* processamos a string como um todo */ while (pInfo->error == NONE && pInfo->msk_len && pInfo->Mask[0] ) { c = pInfo->Mask[0]; // setou o flag? if (strchr( "-+ #0", c )) { flag = c; c = 'A'; } // setar o width? if (strchr( "1234567890", c )) { char *t = (char *) hb_xgrab(15); char *s = t; do { *t = c; t++; pInfo->Mask ++; pInfo->msk_len--; c = pInfo->Mask[0]; } while (pInfo->msk_len && strchr( "1234567890", c )); *t = '\0'; width = atoi( s ); hb_xfree(s); } // setar precision? if (c == '.') { char *t = (char *) hb_xgrab(15); char *s = t; pInfo->Mask ++; pInfo->msk_len--; c = pInfo->Mask[0]; while (pInfo->msk_len && strchr( "1234567890", c )) { *t = c; t++; pInfo->Mask ++; pInfo->msk_len--; c = pInfo->Mask[0]; } *t = '\0'; precision = atoi( s ); hb_xfree(s); c = pInfo->Mask[0]; } if (c == 'l' && strchr( "idouxX", pInfo->Mask[1] )) m = c; if (c == 'h' && strchr( "idouxX", pInfo->Mask[1] )) m = c; if (c == 'L' && strchr( "eEfgG", pInfo->Mask[1] )) m = c; // Chegou no tipo? if (strchr( "cdieEfgGosuxXpn%", c )) { specifier = c; pInfo->Mask ++; pInfo->msk_len--; t2 = pInfo->Mask; switch( specifier ) { case '%': { printf_add_str( pInfo, "%", 1L ); break; } case 'c': // O argumento é tratado como um inteiro, e mostrado como o caractere ASCII correspondente. { char s[2]; memset( s, 0, 2 ); if (HB_IS_STRING( pItem )) { const char *t = hb_itemGetCPtr( pItem ); s[0] = ((t) ? t[0] : 0); } else if( HB_IS_NUMERIC( pItem ) ) { s[0] = (char) hb_itemGetNI( pItem ); } printf_add_str( pInfo, s, 1L ); break; } case 's': { Length = t2-t1; width = max( hb_itemGetCLen( pItem ), (ULONG) width ); cValue = (char *) hb_xgrab( width + 1 ); memmove( mask, t1, Length ); mask[Length] = '\0'; cValue[0] = '\0'; Length = sprintf( cValue, mask, hb_itemGetCPtr( pItem ) ); printf_add_str( pInfo, cValue, Length ); hb_xfree( cValue ); break; } case 'p': { char s[9]; s[0] = '\0'; sprintf( s, "%p", hb_itemGetPtr( pItem ) ); printf_add_str( pInfo, s, 8); break; } /* * Separamos aqui as operações sobre inteiros */ case 'i': case 'd': // O argumento é tratado como um INTEIRO, e mostrado como um número decimal com sinal. case 'o': // O argumento é tratado com um INTEIRO, e mostrado como un número octal. case 'u': // O argumento é tratado com um INTEIRO, e mostrado como um número decimal sem sinal. case 'x': // O argumento é tratado como um INTEIRO, e mostrado como um número hexadecimal (com as letras minúsculas). case 'X': // O argumento é tratado como um INTEIRO, e mostrado como um número hexadecimal (com as letras maiúsculas). { Length = t2-t1; width = ((width) ? width : 32 ); cValue = (char *) hb_xgrab( width + 1 ); memmove( mask, t1, Length ); mask[Length] = '\0'; cValue[0] = '\0'; if (m == '\0') Length = sprintf( cValue, mask, (int) hb_itemGetNI( pItem )); if (m == 'l') Length = sprintf( cValue, mask, (LONG) hb_itemGetNL( pItem )); // como LONG ??? if (m == 'h') Length = sprintf( cValue, mask, (LONG) hb_itemGetNL( pItem )); // como LONG ??? printf_add_str( pInfo, cValue, Length ); hb_xfree( cValue ); break; } /* * Separamos aqui as operações com numeros flutuantes */ case 'e' : // O argumento é tratado como notação científica (e.g. 1.2e+2). case 'E' : // O argumento é tratado como notação científica (e.g. 1.2e+2). case 'f' : // O argumento é tratado como um float, e mostrado como um número de ponto flutuante. case 'F' : // O argumento é tratado como um float, e mostrado como um número de ponto flutuante. { Length = t2-t1; width = ((width) ? width : 64 ); dValue = (double) hb_itemGetND( pItem ); // converting double --> float ??? cValue = (char *) hb_xgrab( width + 1 ); memmove( mask, t1, Length ); mask[Length] = '\0'; sprintf( cValue, mask, dValue ); printf_add_str( pInfo, cValue, strlen( cValue ) ); hb_xfree( cValue ); break; } default: break; } break; } else { pInfo->Mask ++; pInfo->msk_len--; } } }
//------------------------------------------------------------------------------ // IEventHandler's Invoke() // self is where the action happens // self function receives events (by their ID number) and distributes the processing // or them or ignores them static ULONG STDMETHODCALLTYPE Invoke( IEventHandler *self, DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *pexcepinfo, UINT *puArgErr ) { PHB_ITEM pItem; int iArg, i; PHB_ITEM pItemArray[32]; // max 32 parameters? PHB_ITEM *pItems; ULONG ulRefMask = 0; ULONG ulPos; PHB_ITEM Key; Key = hb_itemNew( NULL ); // We implement only a "default" interface if ( !IsEqualIID( riid, &IID_NULL ) ) return( DISP_E_UNKNOWNINTERFACE ); HB_SYMBOL_UNUSED(lcid); HB_SYMBOL_UNUSED(wFlags); HB_SYMBOL_UNUSED(result); HB_SYMBOL_UNUSED(pexcepinfo); HB_SYMBOL_UNUSED(puArgErr); // delegate work to somewhere else in PRG //*************************************** #ifdef __USEHASHEVENTS if ( hb_hashScan( ((MyRealIEventHandler* ) self)->pEvents, hb_itemPutNL( Key, dispid ), &ulPos ) ) { PHB_ITEM pArray = hb_hashGetValueAt( ((MyRealIEventHandler* ) self)->pEvents, ulPos ); #else ulPos = hb_arrayScan( ((MyRealIEventHandler* ) self)->pEvents, hb_itemPutNL( Key, dispid ), NULL, NULL, 0 #ifdef __XHARBOUR__ , 0 #endif ); if ( ulPos ) { PHB_ITEM pArray = hb_arrayGetItemPtr( ((MyRealIEventHandler* ) self)->pEventsExec, ulPos ); #endif PHB_ITEM pExec = hb_arrayGetItemPtr( pArray, 01 ); if ( pExec ) { hb_vmRequestReenter(); switch ( hb_itemType( pExec ) ) { case HB_IT_BLOCK: { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pExec ); break; } case HB_IT_STRING: { PHB_ITEM pObject = hb_arrayGetItemPtr( pArray, 2 ); hb_vmPushSymbol( hb_dynsymSymbol( hb_dynsymFindName( hb_itemGetCPtr( pExec ) ) ) ); if ( HB_IS_OBJECT( pObject ) ) hb_vmPush( pObject ); else hb_vmPushNil(); break; } case HB_IT_POINTER: { hb_vmPushSymbol( hb_dynsymSymbol( ( (PHB_SYMB) pExec ) -> pDynSym ) ); hb_vmPushNil(); break; } } iArg = params->cArgs; for( i = 1; i<= iArg; i++ ) { pItem = hb_itemNew(NULL); hb_oleVariantToItem( pItem, &(params->rgvarg[iArg-i]) ); pItemArray[i-1] = pItem; // set bit i ulRefMask |= ( 1L << (i-1) ); } if( iArg ) { pItems = pItemArray; hb_itemPushList( ulRefMask, iArg, &pItems ); } // execute hb_vmDo( (USHORT) iArg ); // En caso de que los parametros sean pasados por referencia for( i=iArg; i > 0; i-- ) { if( ( (&(params->rgvarg[iArg-i]))->n1.n2.vt & VT_BYREF ) == VT_BYREF ) { switch( (&(params->rgvarg[iArg-i]))->n1.n2.vt ) { //case VT_UI1|VT_BYREF: // *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pbVal) = va_arg(argList,unsigned char*); //pItemArray[i-1] // break; case VT_I2|VT_BYREF: *((&(params->rgvarg[iArg-i]))->n1.n2.n3.piVal) = (short) hb_itemGetNI(pItemArray[i-1]); break; case VT_I4|VT_BYREF: *((&(params->rgvarg[iArg-i]))->n1.n2.n3.plVal) = (long) hb_itemGetNL(pItemArray[i-1]); break; case VT_R4|VT_BYREF: *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pfltVal) = (float) hb_itemGetND(pItemArray[i-1]); break; case VT_R8|VT_BYREF: *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pdblVal) = (double) hb_itemGetND(pItemArray[i-1]); break; case VT_BOOL|VT_BYREF: *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pboolVal) = (VARIANT_BOOL) ( hb_itemGetL( pItemArray[i-1] ) ? 0xFFFF : 0 ); break; //case VT_ERROR|VT_BYREF: // *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pscode) = va_arg(argList, SCODE*); // break; case VT_DATE|VT_BYREF: *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pdate) = (DATE) (double) (hb_itemGetDL(pItemArray[i-1])-2415019 ); break; //case VT_CY|VT_BYREF: // *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pcyVal) = va_arg(argList, CY*); // break; //case VT_BSTR|VT_BYREF: // *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pbstrVal = va_arg(argList, BSTR*); // break; //case VT_UNKNOWN|VT_BYREF: // pArg->ppunkVal = va_arg(argList, LPUNKNOWN*); // break; //case VT_DISPATCH|VT_BYREF: // pArg->ppdispVal = va_arg(argList, LPDISPATCH*); // break; } // EOF switch( (&(params->rgvarg[iArg-i]))->n1.n2.vt ) } // EOF if( (&(params->rgvarg[iArg-i]))->n1.n2.vt & VT_BYREF == VT_BYREF ) } // EOF for( i=iArg; i > 0; i-- ) hb_vmRequestRestore(); } // EOF if ( pExec ) } // EOF If Scan hb_itemRelease( Key ); return S_OK; } // EOF invoke //------------------------------------------------------------------------------ // Here's IEventHandler's VTable. It never changes so we can declare it static static const IEventHandlerVtbl IEventHandler_Vtbl = { QueryInterface, AddRef, Release, GetTypeInfoCount, GetTypeInfo, GetIDsOfNames, Invoke }; //------------------------------------------------------------------------------ // constructor // params: // device_interface - refers to the interface type of the COM object (whose event we are trying to receive). // device_event_interface - indicates the interface type of the outgoing interface supported by the COM object. // This will be the interface that must be implemented by the Sink object. // is essentially derived from IDispatch, our Sink object (self IEventHandler) // is also derived from IDispatch. typedef IEventHandler device_interface; // Hash // SetupConnectionPoint( oOle:hObj, @hSink, hEvents ) -> nError // Array // SetupConnectionPoint( oOle:hObj, @hSink, aEvents, aExecEvent ) -> nError HB_FUNC( SETUPCONNECTIONPOINT ) { IConnectionPointContainer* pIConnectionPointContainerTemp = NULL; IUnknown* pIUnknown = NULL; IConnectionPoint* m_pIConnectionPoint; IEnumConnectionPoints* m_pIEnumConnectionPoints; HRESULT hr; //,r; IID rriid; register IEventHandler * selfobj; DWORD dwCookie = 0; device_interface* pdevice_interface = (device_interface*) HB_PARNL( 1 ); MyRealIEventHandler* pThis; // Allocate our IEventHandler object (actually a MyRealIEventHandler) // intentional misrepresentation of size selfobj = ( IEventHandler *) GlobalAlloc( GMEM_FIXED, sizeof( MyRealIEventHandler ) ); if ( ! selfobj ) { hr = E_OUTOFMEMORY; } else { // Store IEventHandler's VTable in the object selfobj->lpVtbl = (IEventHandlerVtbl *) &IEventHandler_Vtbl; // Increment the reference count so we can call Release() below and // it will deallocate only if there is an error with QueryInterface() ((MyRealIEventHandler *) selfobj)->count = 0; //((MyRealIEventHandler *) selfobj)->device_event_interface_iid = &riid; ((MyRealIEventHandler *) selfobj)->device_event_interface_iid = IID_IDispatch; // Query self object itself for its IUnknown pointer which will be used // later to connect to the Connection Point of the device_interface object. hr = selfobj->lpVtbl->QueryInterface( selfobj, &IID_IUnknown, (void**) (void *) &pIUnknown ); if ( hr == S_OK && pIUnknown ) { // Query the pdevice_interface for its connection point. hr = pdevice_interface->lpVtbl->QueryInterface( pdevice_interface, &IID_IConnectionPointContainer, (void**) (void *) &pIConnectionPointContainerTemp ); if ( hr == S_OK && pIConnectionPointContainerTemp ) { // start uncomment hr = pIConnectionPointContainerTemp->lpVtbl->EnumConnectionPoints( pIConnectionPointContainerTemp, &m_pIEnumConnectionPoints ); if ( hr == S_OK && m_pIEnumConnectionPoints ) { do { hr = m_pIEnumConnectionPoints->lpVtbl->Next( m_pIEnumConnectionPoints, 1, &m_pIConnectionPoint , NULL); if( hr == S_OK ) { if ( m_pIConnectionPoint->lpVtbl->GetConnectionInterface( m_pIConnectionPoint, &rriid ) == S_OK ) { break; } } } while( hr == S_OK ); m_pIEnumConnectionPoints->lpVtbl->Release(m_pIEnumConnectionPoints); } // end uncomment //hr = pIConnectionPointContainerTemp ->lpVtbl->FindConnectionPoint(pIConnectionPointContainerTemp , &IID_IDispatch, &m_pIConnectionPoint); pIConnectionPointContainerTemp->lpVtbl->Release( pIConnectionPointContainerTemp ); pIConnectionPointContainerTemp = NULL; } if ( hr == S_OK && m_pIConnectionPoint ) { //OutputDebugString("getting iid"); //Returns the IID of the outgoing interface managed by self connection point. //hr = m_pIConnectionPoint->lpVtbl->GetConnectionInterface(m_pIConnectionPoint, &rriid ); //OutputDebugString("called"); if( hr == S_OK ) { ((MyRealIEventHandler *) selfobj)->device_event_interface_iid = rriid; } else OutputDebugString("error getting iid"); //OutputDebugString("calling advise"); hr = m_pIConnectionPoint->lpVtbl->Advise( m_pIConnectionPoint, pIUnknown, &dwCookie ); ((MyRealIEventHandler *) selfobj)->pIConnectionPoint = m_pIConnectionPoint; ((MyRealIEventHandler *) selfobj)->dwEventCookie = dwCookie; } pIUnknown->lpVtbl->Release(pIUnknown); pIUnknown = NULL; } } if( selfobj ) { pThis = (MyRealIEventHandler *) selfobj; #ifndef __USEHASHEVENTS pThis->pEventsExec = hb_itemNew( hb_param( 4, HB_IT_ANY ) ); #endif pThis->pEvents = hb_itemNew( hb_param( 3, HB_IT_ANY ) ); HB_STORNL2( (LONG_PTR) pThis, 2 ); } HWNDret( hr ); } //------------------------------------------------------------------------------ HB_FUNC( SHUTDOWNCONNECTIONPOINT ) { MyRealIEventHandler *self = ( MyRealIEventHandler * ) HB_PARNL( 1 ); if( self->pIConnectionPoint ) { self->pIConnectionPoint->lpVtbl->Unadvise( self->pIConnectionPoint, self->dwEventCookie ); self->dwEventCookie = 0; self->pIConnectionPoint->lpVtbl->Release( self->pIConnectionPoint ); self->pIConnectionPoint = NULL; } } //------------------------------------------------------------------------------ HB_FUNC( RELEASEDISPATCH ) { IDispatch * pObj; pObj = ( IDispatch * ) HWNDparam( 1 ); pObj->lpVtbl->Release( pObj ); }
//-----------------------------------------------------------------------= // ÚÄ1ra Col.a Pintar // ³ static void near PaintTheLine( HDC hDC, RECT * rct, WORD wIndex, PCLIPVAR pAtext, PCLIPVAR pAsizes, HPEN hWhitePen, HPEN hGrayPen, BOOL bTree, PCLIPVAR pAJustify, WORD wPressed, BOOL bHeader, WORD nStyle, WORD wFocus, BOOL bFocused, PCLIPVAR pTextColor, PCLIPVAR pBkColor, WORD wRowPos, WORD nHeightCtrl, LONG nClrLine, BOOL bFooter, BOOL bSelect, PCLIPVAR pFont, BOOL bDrawFocusRect ) { RECT box, wholebox, rctadj; int iMaxRight = rct->right; WORD wLenJust = 0 ; #ifndef __HARBOUR__ WORD wLen = _VARRAYLEN( pAtext ); CLV_WORD lJustify; #else WORD wLen = hb_arrayLen( pAtext ); PHB_ITEM uElem = hb_itemNew( NULL ); #endif WORD wType, wcLen; LONG lValue; char * cValue; HPEN hOldPen, hPen; BITMAP bmp; WORD wRow, wCol; LONG lColor ; HBRUSH hBrush; LONG lTextColorOld = -1 ; // CeSoTech LONG lBkColorOld = -1 ; // CeSoTech PCLIPVAR pEvalOld ; HFONT hFont ; // CeSoTech WORD wAlign ; // CeSoTech // CeSoTech LONG nClrLineC = ( nStyle == 2 || nStyle == 6 || nStyle == 8 || nStyle == 10 ) ? GetSysColor( COLOR_BTNSHADOW ) : 0 ; // CeSoTech if ( nClrLine >= 0 ) // Desde Clipper manda color especifico linea nClrLineC = nClrLine ; if ( ! bDrawHeaders ) bHeader = FALSE ; if ( bFooter ) bHeader = TRUE ; //-> Para que lo pinte con similar aspecto //CeSoTech // Si es un estilo sin separadores horizontales, pintar uno mas arriba //CeSoTech para que que bien completa el area !!! if ( ! (bHeader) && (nStyle == 0 || nStyle == 5 || nStyle == 6 || nStyle == 9 || nStyle == 10) ) rct->top-- ; wholebox.top = rct->top+1; wholebox.left = rct->left; wholebox.bottom = rct->bottom; wholebox.right = rct->right; rct->right = 0; box.top = rct->top ; box.bottom = rct->bottom - 1; if( !wIndex | wIndex > wLen ) wIndex = 1; if ( pAJustify ) #ifndef __HARBOUR__ wLenJust = _VARRAYLEN( pAJustify ); #else wLenJust = hb_arrayLen( pAJustify ); #endif while( wIndex <= wLen ) { rct->left = rct->right; rct->right = ( wIndex == wLen ? iMaxRight : rct->left + GetInt( pAsizes, wIndex ) ); // CeSoTech // Cuando estoy estoy en la ultima celda, NO pintar hasta // el final si no existe ajuste de ultima columna. if ( ( wIndex == wLen ) && ( ! bAdjLastCol ) ) { rct->right = rct->left + GetInt( pAsizes, wIndex ) +(bHeader ? 1: 0) ; if ( !bAdjBrowse ) wholebox.right = rct->right ; // Tambien ajusto el borde focus } // CeSoTech // wAlign = HA_LEFT | VA_CENTER ; // Alineacion por defecto wcLen = 0; ///////// INICIO Toma de datos celda !!! #ifndef __HARBOUR__ if ( wIndex <= wLenJust ) { _cAt( pAJustify, wIndex, 0xFFFF, ( PCLIPVAR ) &lJustify ); wAlign = lJustify.wWord ; } _cAt( pAtext, wIndex, 0xFFFF, ++_tos ); wType = _tos->wType; if ( wType & NUMERIC ) lValue = (LONG) _tos->pPointer1; if ( wType & CHARACTER ) { cValue = _VSTR( _tos ); wcLen = _tos->w2; } #else if ( wIndex <= wLenJust ) { hb_arrayGet( pAJustify, wIndex, uElem ); if ( ( hb_itemType( uElem ) & LOGICAL ) && hb_itemGetL( uElem ) ) wAlign = HA_RIGHT | VA_CENTER ; else wAlign = hb_itemGetNL( uElem ); hb_itemClear( uElem ); } // uElem.type = HB_IT_NIL; hb_arrayGet( pAtext, wIndex, uElem ); wType = hb_itemType( uElem ); if ( wType & NUMERIC ) lValue = hb_itemGetNL( uElem ); if ( wType & CHARACTER ) { // cValue = hb_itemGetC( uElem ); cValue = hb_itemGetCPtr( uElem ); wcLen = strlen( cValue ); } #endif ///////// FIN Toma de datos celda !!! if( wFocus > 0 && wIndex != wFocus ) { #ifndef __HARBOUR__ _tos--; #endif if( rct->right >= iMaxRight ) { wIndex = wLen + 1; // ya no pintamos m s } else ++wIndex; continue; } if( bTree || (GetInt( pAsizes, wIndex ) > 0) ) //Si NO es columna oculta (x Freeze) { //(Es lo mismo no hacer esto, // pero es para evitar hacer trabajar // al codigo sin sentido !!! ) if( (wType & NUMERIC) && bTree ) { if( lValue ) { FillRect( hDC, rct, hBrush = CreateSolidBrush( GetPixel( hDC, rct->left, rct->top ) ) ); DrawMasked( hDC, (HBITMAP) lValue, rct->top, rct->left ); DeleteObject( hBrush ); } } else // Si es Numerico Bmp no Tree, o , es Character !!!! { if ( pBkColor ) // Bloque de Color Fondo Celda { _PutSym( _SymEval ); _xPushM( pBkColor ); _PutLN( wRowPos ); _PutLN( wIndex ); _PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) ); _xEval( 3 ) ; if ( _parinfo( -1 ) & NUMERIC ) lBkColorOld = SetBkColor( hDC, _parnl( - 1 ) ) ; } if( pTextColor ) // Bloque de Color Texto Celda { _PutSym( _SymEval ); _xPushM( pTextColor ); _PutLN( wRowPos ); _PutLN( wIndex ); _PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) ); _xEval( 3 ) ; if ( _parinfo( -1 ) & NUMERIC ) lTextColorOld = SetTextColor( hDC, _parnl( - 1 ) ) ; } hFont = 0 ; if( pFont ) // Bloque de Font Celda { _PutSym( _SymEval ); _xPushM( pFont ); _PutLN( wRowPos ); _PutLN( wIndex ); _PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) ); _xEval( 3 ) ; if ( _parinfo( -1 ) & NUMERIC ) hFont = (HFONT) _parnl( - 1 ) ; } /////// CeSoTech /////// if (!bHeader) rct->top ++; if( wType & NUMERIC ) // Es un BitMap { FW_DrawBitmapCenter( hDC, (HBITMAP) lValue, rct, nStyle, bSelect ); } else // Es una Cadena { FW_DrawText( hDC, rct, ( wType & CHARACTER ) ? cValue : "", wAlign, wcLen, hFont, bHeader ) ; } /////// CeSoTech restauracion de colores ////// if ( lTextColorOld >= 0 ) { SetTextColor( hDC, lTextColorOld ) ; lTextColorOld = -1 ; } if ( lBkColorOld >= 0 ) { SetBkColor( hDC, lBkColorOld ) ; lBkColorOld = -1 ; } /// CeSoTech /// // Si hay modalidad ajustar el Browse y no hay ajuste de ultima // columna, deber‚ pintar hasta el final hasta cubrir toda // el area, hasta llegar a la derecha del control. (Col.Ficticia) if ( bAdjBrowse && wIndex == wLen && !bAdjLastCol && rct->right <= iMaxRight ) { rctadj.top = rct->top; rctadj.left = rct->right ; rctadj.bottom = rct->bottom; rctadj.right = wholebox.right ; if ( nStyle == 3 ) rctadj.top--; if ( wFocus == 0 ) // Si No es CellStyle (Pinto hasta final) ExtTextOut( hDC, 0, rct->top, ETO_OPAQUE, &rctadj, "", 0, 0 ); if ( bHeader && nStyle==3 ) // Pinto Bordes Header Falso { rctadj.right = wholebox.right - 2 ; rctadj.bottom = rctadj.bottom - 2 ; WndDrawBox( hDC, &rctadj, hWhitePen, hGrayPen ); rctadj.bottom++ ; rctadj.right++ ; WndDrawBox( hDC, &rctadj, hWhitePen, GetStockObject( BLACK_PEN ) ); if ( bFooter ) // Si es Footer (Linea Negra de Arriba Foot) { hPen = GetStockObject( BLACK_PEN ); hOldPen = SelectObject( hDC, hPen ); MoveTo( hDC, rctadj.left-1, rctadj.top-1 ); LineTo( hDC, rctadj.right+1, rctadj.top-1 ); SelectObject( hDC, hOldPen ); } } } /// CeSoTech Fin /// if (!bHeader) rct->top --; } box.left = rct->left; box.right = ( wIndex < wLen && rct->right <= iMaxRight ? rct->right - 1 : iMaxRight - 1 ); // CeSoTech // El Borde derecho de Box de la ultima columna, // no estirarlo cuando no exista ajuste de ultima columna // PERO cuando nLineStyle (nStyle) es 7/8 (Lineas Horiz) // queda anti-estetico cortar los renglones, cuando no hay // ajuste ult.col. y hay ajuste de browse. Por ello // se verificara que para cortar el borde no se de esta // condicion. if ( ( wIndex == wLen ) && ( ! bAdjLastCol ) ) { if (! (!bHeader && (nStyle==7 || nStyle==8) && !bAdjLastCol && bAdjBrowse) ) box.right = rct->left + GetInt( pAsizes, wIndex ) - 1 ; } // CeSoTech // if( ! bTree ) { if( wPressed && ( wIndex == wPressed ) ) { WndDrawBox( hDC, &box, hGrayPen, hWhitePen ); } else ///////////// if(!bHeader) if(!bHeader || (bHeader && nStyle!=3) ) { switch( nStyle ) { case 0: break; case 1: // hOldPen = SelectObject( hDC, GetStockObject( BLACK_PEN ) ); hPen = CreatePen(PS_SOLID, 0, nClrLineC ); hOldPen = SelectObject( hDC, hPen); MoveTo( hDC, box.left, box.bottom+1 ); LineTo( hDC, box.left, box.top ); LineTo( hDC, box.right+1, box.top ); LineTo( hDC, box.right+1, box.bottom+1 ); LineTo( hDC, box.left, box.bottom+1 ); SelectObject( hDC, hOldPen ); DeleteObject( hPen); break; case 2: hPen = CreatePen(PS_SOLID, 0, nClrLineC ); hOldPen = SelectObject( hDC, hPen); MoveTo( hDC, box.left, box.bottom+1 ); LineTo( hDC, box.left, box.top ); LineTo( hDC, box.right+1, box.top ); LineTo( hDC, box.right+1, box.bottom+1 ); LineTo( hDC, box.left, box.bottom+1 ); SelectObject( hDC, hOldPen ); DeleteObject( hPen); break; case 3: WndDrawBox( hDC, &box, hWhitePen, hGrayPen ); break; case 4: box.bottom ++; box.right ++; FrameDot( hDC, &box ); box.bottom --; box.right --; break; case 7: case 8: hPen = CreatePen(PS_SOLID, 0, nClrLineC ); hOldPen = SelectObject( hDC, hPen); MoveTo( hDC, box.left, box.top ); LineTo( hDC, box.right+1, box.top ); MoveTo( hDC, box.right+1, box.bottom+1 ); LineTo( hDC, box.left, box.bottom+1 ); SelectObject( hDC, hOldPen ); DeleteObject( hPen); break; case 5: case 6: case 9: case 10: hPen = CreatePen(PS_SOLID, 0, nClrLineC); hOldPen = SelectObject( hDC, hPen); if (box.left>1) { MoveTo( hDC, box.left, box.bottom+1 ); LineTo( hDC, box.left, box.top ); } MoveTo( hDC, box.right+1, box.top ); if ( bDrawFooters && nStyle >= 9 ) { LineTo( hDC, box.right+1, nHeightCtrl - (wFooterHeight+1) ) ; } else { LineTo( hDC, box.right+1, nStyle < 9 ? box.bottom+1 : nHeightCtrl ); } SelectObject( hDC, hOldPen ); DeleteObject( hPen); break; } } else // Box para Headers !!! { box.left ++; // CeSoTech if ( bFooter ) // Linea negra sobre el Footer { hPen = GetStockObject( BLACK_PEN ); hOldPen = SelectObject( hDC, hPen ); MoveTo( hDC, box.left-1, box.top-1 ); LineTo( hDC, box.right+1, box.top-1 ); SelectObject( hDC, hOldPen ); } box.right-- ; box.bottom-- ; WndDrawBox( hDC, &box, hWhitePen, hGrayPen ); box.bottom++ ; box.right++ ; WndDrawBox( hDC, &box, hWhitePen, GetStockObject( BLACK_PEN ) ); box.left --; } } else { if( ! ( wType & NUMERIC ) ) { box.left -= 16; } } // CeSoTech if( bFocused && wFocus > 0 && wIndex == wFocus ) if( bDrawFocusRect && bFocused && wFocus > 0 && wIndex == wFocus && nStyle != 3) { rct->left++; rct->top++; DrawFocusRect( hDC, rct ); rct->left--; rct->top--; } } #ifndef __HARBOUR__ _tos--; #endif if( rct->right >= iMaxRight ) { wIndex = wLen + 1; // ya no pintamos m s } else ++wIndex; } if (bDrawFocusRect && !bTree && bFocused && wFocus==0 && nStyle!=3) // CeSoTech DrawFocusRect( hDC, &wholebox ); hb_itemRelease( uElem ); }
static PMIXTAG mixTagCreate( const char * szTagName, PHB_ITEM pKeyExpr, PHB_ITEM pKeyItem, PHB_ITEM pForItem, PHB_ITEM pWhileItem, HB_BYTE bType, HB_USHORT uiLen, ADSXAREAP pArea ) { PMIXTAG pTag; PMIXKEY pKey; LPDBORDERCONDINFO pOrdCondInfo = pArea->adsarea.area.lpdbOrdCondInfo; ADSHANDLE hOrder; HB_ULONG ulRec, ulStartRec, ulNextCount = 0; HB_LONG lStep = 0; PHB_ITEM pItem, pEvalItem = NULL; pTag = ( PMIXTAG ) hb_xgrab( sizeof( MIXTAG ) ); memset( pTag, 0, sizeof( MIXTAG ) ); pTag->szName = ( char * ) hb_xgrab( MIX_MAXTAGNAMELEN + 1 ); hb_strncpyUpperTrim( pTag->szName, szTagName, MIX_MAXTAGNAMELEN ); pTag->szKeyExpr = ( char * ) hb_xgrab( hb_itemGetCLen( pKeyExpr ) + 1 ); hb_strncpyTrim( pTag->szKeyExpr, hb_itemGetCPtr( pKeyExpr ), hb_itemGetCLen( pKeyExpr ) ); /* TODO: for expresion */ pTag->szForExpr = NULL; pTag->pKeyItem = pKeyItem; pTag->pForItem = pForItem; pTag->bType = bType; pTag->uiLen = uiLen; /* Use national support */ if( bType == 'C' && pArea->adsarea.area.cdPage && ! HB_CDP_ISBINSORT( pArea->adsarea.area.cdPage ) ) pTag->pCodepage = pArea->adsarea.area.cdPage; pTag->pKeys = ( PMIXKEY * ) hb_xgrab( sizeof( PMIXKEY ) * MIX_KEYPOOLFIRST ); pTag->ulRecMax = MIX_KEYPOOLFIRST; ulStartRec = 0; if( pOrdCondInfo ) { pEvalItem = pOrdCondInfo->itmCobEval; lStep = pOrdCondInfo->lStep; } if( ! pOrdCondInfo || pOrdCondInfo->fAll ) { pArea->adsarea.hOrdCurrent = 0; } else { if( pOrdCondInfo->itmRecID ) ulStartRec = hb_itemGetNL( pOrdCondInfo->itmRecID ); if( ulStartRec ) { ulNextCount = 1; } else if( pOrdCondInfo->fRest || pOrdCondInfo->lNextCount > 0 ) { if( pOrdCondInfo->itmStartRecID ) ulStartRec = hb_itemGetNL( pOrdCondInfo->itmStartRecID ); if( ! ulStartRec ) ulStartRec = pArea->adsarea.ulRecNo; if( pArea->adsarea.area.lpdbOrdCondInfo->lNextCount > 0 ) ulNextCount = pOrdCondInfo->lNextCount; } else if( ! pOrdCondInfo->fUseCurrent ) { pArea->adsarea.hOrdCurrent = 0; } } hOrder = pArea->adsarea.hOrdCurrent ? pArea->adsarea.hOrdCurrent : pArea->adsarea.hTable; if( ulStartRec ) AdsGotoRecord( pArea->adsarea.hTable, ulStartRec ); else AdsGotoTop( pArea->adsarea.hTable ); hb_adsUpdateAreaFlags( pArea ); while( ! pArea->adsarea.area.fEof ) { SELF_RECNO( ( AREAP ) pArea, &ulRec ); SELF_GOTO( ( AREAP ) pArea, ulRec ); if( pEvalItem ) { if( lStep >= pOrdCondInfo->lStep ) { lStep = 0; if( ! mixEvalCond( pEvalItem, NULL ) ) break; } ++lStep; } if( pWhileItem && ! mixEvalCond( pWhileItem, NULL ) ) { break; } if( pForItem == NULL || mixEvalCond( pForItem, NULL ) ) { pItem = hb_vmEvalBlockOrMacro( pKeyItem ); pKey = mixKeyNew( pItem, ulRec, bType, uiLen ); if( pTag->ulRecCount == pTag->ulRecMax ) { pTag->pKeys = ( PMIXKEY * ) hb_xrealloc( pTag->pKeys, sizeof( PMIXKEY ) * ( pTag->ulRecMax + MIX_KEYPOOLRESIZE ) ); pTag->ulRecMax += MIX_KEYPOOLRESIZE; } pTag->pKeys[ pTag->ulRecCount ] = pKey; pTag->ulRecCount++; } if( ulNextCount ) { ulNextCount--; if( ! ulNextCount ) break; } AdsSkip( hOrder, 1 ); hb_adsUpdateAreaFlags( pArea ); } /* QuickSort */ if( pTag->ulRecCount >= 2 ) mixQSort( pTag->pKeys, 0, pTag->ulRecCount - 1, uiLen, pTag->pCodepage ); return pTag; }
LOGFONT * hbwapi_par_LOGFONT( LOGFONT * p, int iParam, HB_BOOL bMandatory ) { PHB_ITEM pStru = hb_param( iParam, HB_IT_ANY ); void * hfFaceName; LPCTSTR pfFaceName; HB_SIZE nLen; memset( p, 0, sizeof( LOGFONT ) ); if( pStru && HB_IS_HASH( pStru ) ) { p->lfHeight = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "lfHeight" ) ); p->lfWidth = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "lfWidth" ) ); p->lfEscapement = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "lfEscapement" ) ); p->lfOrientation = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "lfOrientation" ) ); p->lfWeight = ( LONG ) hb_itemGetNL( hb_hashGetCItemPtr( pStru, "lfWeight" ) ); p->lfItalic = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfItalic" ) ); p->lfUnderline = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfUnderline" ) ); p->lfStrikeOut = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfStrikeOut" ) ); p->lfCharSet = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfCharSet" ) ); p->lfOutPrecision = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfOutPrecision" ) ); p->lfClipPrecision = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfClipPrecision" ) ); p->lfQuality = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfQuality" ) ); p->lfPitchAndFamily = ( BYTE ) hb_itemGetNI( hb_hashGetCItemPtr( pStru, "lfPitchAndFamily" ) ); pfFaceName = HB_ITEMGETSTR( hb_hashGetCItemPtr( pStru, "lfFaceName" ), &hfFaceName, &nLen ); if( nLen > ( LF_FACESIZE - 1 ) ) nLen = LF_FACESIZE - 1; memcpy( p->lfFaceName, pfFaceName, nLen * sizeof( TCHAR ) ); p->lfFaceName[ nLen ] = TEXT( '\0' ); hb_strfree( hfFaceName ); return p; } else if( pStru && HB_IS_ARRAY( pStru ) && hb_arrayLen( pStru ) >= 14 ) { p->lfHeight = ( LONG ) hb_arrayGetNL( pStru, 1 ); p->lfWidth = ( LONG ) hb_arrayGetNL( pStru, 2 ); p->lfEscapement = ( LONG ) hb_arrayGetNL( pStru, 3 ); p->lfOrientation = ( LONG ) hb_arrayGetNL( pStru, 4 ); p->lfWeight = ( LONG ) hb_arrayGetNL( pStru, 5 ); p->lfItalic = ( BYTE ) hb_arrayGetNI( pStru, 6 ); p->lfUnderline = ( BYTE ) hb_arrayGetNI( pStru, 7 ); p->lfStrikeOut = ( BYTE ) hb_arrayGetNI( pStru, 8 ); p->lfCharSet = ( BYTE ) hb_arrayGetNI( pStru, 9 ); p->lfOutPrecision = ( BYTE ) hb_arrayGetNI( pStru, 10 ); p->lfClipPrecision = ( BYTE ) hb_arrayGetNI( pStru, 11 ); p->lfQuality = ( BYTE ) hb_arrayGetNI( pStru, 12 ); p->lfPitchAndFamily = ( BYTE ) hb_arrayGetNI( pStru, 13 ); pfFaceName = HB_ARRAYGETSTR( pStru, 14, &hfFaceName, &nLen ); if( nLen > ( LF_FACESIZE - 1 ) ) nLen = LF_FACESIZE - 1; memcpy( p->lfFaceName, pfFaceName, nLen * sizeof( TCHAR ) ); p->lfFaceName[ nLen ] = TEXT( '\0' ); hb_strfree( hfFaceName ); return p; } else if( bMandatory ) return p; return NULL; }
static HB_UINT SCItm( char * cBuffer, HB_UINT ulMaxBuf, char * cParFrm, int iCOut, int IsIndW, int iIndWidth, int IsIndP, int iIndPrec, PHB_ITEM pItmPar ) { HB_UINT s; if( IsIndW && IsIndP ) { switch( iCOut ) { case 'p': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iIndWidth, iIndPrec, hb_itemGetPtr( pItmPar ) ); break; case 's': case 'S': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iIndWidth, iIndPrec, hb_itemGetCPtr( pItmPar ) ); break; case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iIndWidth, iIndPrec, hb_itemGetND( pItmPar ) ); break; /* case 'c': case 'C': case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': */ default: s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iIndWidth, iIndPrec, HB_IS_LONG( pItmPar ) ? hb_itemGetNL( pItmPar ) : hb_itemGetNI( pItmPar ) ); } } else if( IsIndW || IsIndP ) { int iInd = ( IsIndW ? iIndWidth : iIndPrec ); switch( iCOut ) { case 'p': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iInd, hb_itemGetPtr( pItmPar ) ); break; case 's': case 'S': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iInd, hb_itemGetCPtr( pItmPar ) ); break; case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iInd, hb_itemGetND( pItmPar ) ); break; /* case 'c': case 'C': case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': */ default: s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, iInd, HB_IS_LONG( pItmPar ) ? hb_itemGetNL( pItmPar ) : hb_itemGetNI( pItmPar ) ); } } else { switch( iCOut ) { case 'p': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, hb_itemGetPtr( pItmPar ) ); break; case 's': case 'S': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, hb_itemGetCPtr( pItmPar ) ); break; case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, hb_itemGetND( pItmPar ) ); break; /* case 'c': case 'C': case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': */ default: s = hb_snprintf( cBuffer, ulMaxBuf, cParFrm, HB_IS_LONG( pItmPar ) ? hb_itemGetNL( pItmPar ) : hb_itemGetNI( pItmPar ) ); } } return s; }
static HB_ERRCODE sqlbaseRddInfo( LPRDDNODE pRDD, HB_USHORT uiIndex, HB_ULONG ulConnect, PHB_ITEM pItem ) { HB_ULONG ulConn; SQLDDCONNECTION * pConn; HB_SYMBOL_UNUSED( pRDD ); ulConn = ulConnect ? ulConnect : s_ulConnectionCurrent; if( ulConn > 0 && ulConn <= s_ulConnectionCount ) pConn = s_pConnection[ ulConn - 1 ]; else pConn = NULL; switch( uiIndex ) { case RDDI_REMOTE: hb_itemPutL( pItem, HB_TRUE ); break; case RDDI_CONNECTION: { HB_ULONG ulNewConnection = 0; if( hb_itemType( pItem ) & HB_IT_NUMERIC ) ulNewConnection = hb_itemGetNL( pItem ); hb_itemPutNL( pItem, ulConnect ? ulConnect : s_ulConnectionCurrent ); if( ulNewConnection ) s_ulConnectionCurrent = ulNewConnection; break; } case RDDI_ISDBF: hb_itemPutL( pItem, HB_FALSE ); break; case RDDI_CANPUTREC: hb_itemPutL( pItem, HB_TRUE ); break; case RDDI_CONNECT: { PSDDNODE pNode = NULL; HB_ULONG ul; const char * pStr; pStr = hb_arrayGetCPtr( pItem, 1 ); if( pStr ) { pNode = s_pSdd; while( pNode ) { if( ! hb_stricmp( pNode->Name, pStr ) ) break; pNode = pNode->pNext; } } hb_rddsqlSetError( 0, NULL, NULL, NULL, 0 ); pConn = ( SQLDDCONNECTION * ) hb_xgrab( sizeof( SQLDDCONNECTION ) ); memset( pConn, 0, sizeof( SQLDDCONNECTION ) ); if( pNode && pNode->Connect( pConn, pItem ) == HB_SUCCESS ) { pConn->pSDD = pNode; /* Find free connection handle */ for( ul = 0; ul < s_ulConnectionCount; ul++ ) { if( ! s_pConnection[ ul ] ) break; } if( ul >= s_ulConnectionCount ) { /* Realloc connection table */ if( s_pConnection ) s_pConnection = ( SQLDDCONNECTION ** ) hb_xrealloc( s_pConnection, sizeof( SQLDDCONNECTION * ) * ( s_ulConnectionCount + CONNECTION_LIST_EXPAND ) ); else s_pConnection = ( SQLDDCONNECTION ** ) hb_xgrab( sizeof( SQLDDCONNECTION * ) * CONNECTION_LIST_EXPAND ); memset( s_pConnection + s_ulConnectionCount, 0, sizeof( SQLDDCONNECTION * ) * CONNECTION_LIST_EXPAND ); ul = s_ulConnectionCount; s_ulConnectionCount += CONNECTION_LIST_EXPAND; } s_pConnection[ ul ] = pConn; ul++; s_ulConnectionCurrent = ul; } else { hb_xfree( pConn ); ul = 0; } hb_itemPutNI( pItem, ul ); break; } case RDDI_DISCONNECT: hb_rddsqlSetError( 0, NULL, NULL, NULL, 0 ); if( pConn && ! pConn->uiAreaCount && pConn->pSDD->Disconnect( pConn ) == HB_SUCCESS ) { hb_xfree( pConn ); s_pConnection[ ulConn - 1 ] = NULL; if( s_ulConnectionCurrent == ulConn ) s_ulConnectionCurrent = 0; hb_itemPutL( pItem, HB_TRUE ); return HB_SUCCESS; } hb_itemPutL( pItem, HB_FALSE ); return HB_SUCCESS; case RDDI_EXECUTE: hb_rddsqlSetError( 0, NULL, NULL, NULL, 0 ); if( pConn ) hb_itemPutL( pItem, pConn->pSDD->Execute( pConn, pItem ) == HB_SUCCESS ); else hb_itemPutL( pItem, HB_FALSE ); return HB_SUCCESS; case RDDI_ERROR: hb_itemPutC( pItem, s_szError ); return HB_SUCCESS; case RDDI_ERRORNO: hb_itemPutNI( pItem, s_errCode ); return HB_SUCCESS; case RDDI_QUERY: hb_itemPutC( pItem, s_szQuery ); return HB_SUCCESS; case RDDI_NEWID: hb_itemCopy( pItem, s_pItemNewID ); return HB_SUCCESS; case RDDI_AFFECTEDROWS: hb_itemPutNInt( pItem, s_ulAffectedRows ); return HB_SUCCESS; #if 0 default: return SUPER_RDDINFO( pRDD, uiIndex, ulConnect, pItem ); #endif } return HB_SUCCESS; }
static HB_ERRCODE adsxOrderInfo( ADSXAREAP pArea, HB_USHORT uiIndex, LPDBORDERINFO pOrderInfo ) { PMIXTAG pTag = pArea->pTagCurrent; /* resolve any pending relations */ if( pArea->adsarea.lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); /* all others need an index handle */ if( uiIndex != DBOI_ORDERCOUNT ) { if( pOrderInfo->itmOrder ) { if( HB_IS_STRING( pOrderInfo->itmOrder ) ) { pTag = pArea->pTagList; while( pTag ) { if( ! hb_stricmp( hb_itemGetCPtr( pOrderInfo->itmOrder ), pTag->szName ) ) break; pTag = pTag->pNext; } } else if( HB_IS_NUMERIC( pOrderInfo->itmOrder ) ) { UNSIGNED16 usOrder = 0, usSearch = ( UNSIGNED16 ) hb_itemGetNI( pOrderInfo->itmOrder ); AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); pTag = usSearch <= usOrder ? NULL : pArea->pTagList; while( pTag ) { if( ++usOrder == usSearch ) break; pTag = pTag->pNext; } } } if( ! pTag ) return SUPER_ORDINFO( ( AREAP ) pArea, uiIndex, pOrderInfo ); } switch( uiIndex ) { case DBOI_CONDITION: hb_itemPutC( pOrderInfo->itmResult, pTag->szForExpr ); break; case DBOI_EXPRESSION: hb_itemPutC( pOrderInfo->itmResult, pTag->szKeyExpr ); break; case DBOI_ISCOND: hb_itemPutL( pOrderInfo->itmResult, pTag->pForItem != NULL ); break; case DBOI_ISDESC: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_UNIQUE: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_KEYTYPE: hb_itemPutCL( pOrderInfo->itmResult, ( char * ) &pTag->bType, 1 ); break; case DBOI_KEYSIZE: hb_itemPutNI( pOrderInfo->itmResult, pTag->uiLen ); break; case DBOI_KEYVAL: { PHB_ITEM pItem; PHB_CODEPAGE pCodepage = hb_cdpSelect( pArea->adsarea.area.cdPage ); pItem = hb_vmEvalBlockOrMacro( pTag->pKeyItem ); hb_cdpSelect( pCodepage ); hb_itemMove( pOrderInfo->itmResult, pItem ); break; } case DBOI_KEYCOUNT: case DBOI_KEYCOUNTRAW: /* ignore filter but RESPECT SCOPE */ hb_itemPutNL( pOrderInfo->itmResult, pTag->ulRecCount ); break; case DBOI_POSITION: case DBOI_RECNO: case DBOI_KEYNORAW: if( uiIndex == DBOI_POSITION && pOrderInfo->itmNewVal && HB_IS_NUMERIC( pOrderInfo->itmNewVal ) ) { HB_ULONG ulPos; ulPos = hb_itemGetNL( pOrderInfo->itmNewVal ); if( ulPos > 0 && ulPos <= pTag->ulRecCount ) SELF_GOTO( ( AREAP ) pArea, pTag->pKeys[ ulPos - 1 ]->rec ); pOrderInfo->itmResult = hb_itemPutL( pOrderInfo->itmResult, ! pArea->adsarea.area.fEof ); } else { PMIXKEY pKey; HB_ULONG ulKeyPos; if( ! pArea->adsarea.fPositioned ) SELF_GOTO( ( AREAP ) pArea, pArea->adsarea.ulRecNo ); else pArea->adsarea.area.fEof = HB_FALSE; pKey = mixKeyEval( pTag, pArea ); hb_itemPutNL( pOrderInfo->itmResult, mixFindKey( pTag, pKey, &ulKeyPos ) ? ( ulKeyPos + 1 ) : 0 ); mixKeyFree( pKey ); } break; case DBOI_RELKEYPOS: if( pOrderInfo->itmNewVal && HB_IS_NUMERIC( pOrderInfo->itmNewVal ) ) { HB_ULONG ulPos; ulPos = ( HB_ULONG ) ( hb_itemGetND( pOrderInfo->itmNewVal ) * ( double ) pTag->ulRecCount ); if( ulPos > 0 && ulPos <= pTag->ulRecCount ) SELF_GOTO( ( AREAP ) pArea, pTag->pKeys[ ulPos - 1 ]->rec ); pOrderInfo->itmResult = hb_itemPutL( pOrderInfo->itmResult, ! pArea->adsarea.area.fEof ); } else { PMIXKEY pKey; HB_ULONG ulKeyPos; if( ! pArea->adsarea.fPositioned ) SELF_GOTO( ( AREAP ) pArea, pArea->adsarea.ulRecNo ); else pArea->adsarea.area.fEof = HB_FALSE; pKey = mixKeyEval( pTag, pArea ); if( ! mixFindKey( pTag, pKey, &ulKeyPos + 1 ) ) ulKeyPos = 0; mixKeyFree( pKey ); pOrderInfo->itmResult = hb_itemPutND( pOrderInfo->itmResult, ( double ) ulKeyPos / ( double ) pTag->ulRecCount ); } break; case DBOI_NAME: hb_itemPutC( pOrderInfo->itmResult, pTag->szName ); break; case DBOI_BAGNAME: hb_itemPutC( pOrderInfo->itmResult, NULL ); break; case DBOI_FULLPATH: hb_itemPutC( pOrderInfo->itmResult, NULL ); break; case DBOI_BAGEXT: hb_itemPutC( pOrderInfo->itmResult, "mix" ); break; case DBOI_ORDERCOUNT: { UNSIGNED16 usOrder = 0; AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); pTag = pArea->pTagList; while( pTag ) { pTag = pTag->pNext; usOrder++; } hb_itemPutNI( pOrderInfo->itmResult, ( int ) usOrder ); break; } case DBOI_NUMBER: { PMIXTAG pTag2; UNSIGNED16 usOrder = 0; AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); pTag2 = pArea->pTagList; usOrder++; while( pTag2 && pTag != pTag2 ) { pTag2 = pTag2->pNext; usOrder++; } hb_itemPutNI( pOrderInfo->itmResult, ( int ) usOrder ); break; } case DBOI_CUSTOM: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_OPTLEVEL: hb_itemPutNI( pOrderInfo->itmResult, DBOI_OPTIMIZED_NONE ); break; case DBOI_KEYADD: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_KEYDELETE: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_AUTOOPEN: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; default: return SUPER_ORDINFO( ( AREAP ) pArea, uiIndex, pOrderInfo ); } return HB_SUCCESS; }