/* undocumented Clipper _cEval1() */ void hb_evalBlock1( PHB_ITEM pCodeBlock, PHB_ITEM pParam ) { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pCodeBlock ); hb_vmPush( pParam ); hb_vmSend( 1 ); }
PHB_ITEM hb_itemDoC( const char * szFunc, HB_ULONG ulPCount, ... ) { PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDoC(%s, %lu, ...)", szFunc, ulPCount ) ); if( szFunc ) { PHB_DYNS pDynSym = hb_dynsymFindName( szFunc ); if( pDynSym ) { if( hb_vmRequestReenter() ) { hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); if( ulPCount ) { HB_ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } hb_vmProc( ( HB_USHORT ) ulPCount ); pResult = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); } } } return pResult; }
static void hb_hrbInitStatic( PHRB_BODY pHrbBody ) { if( ! pHrbBody->fInit && ! pHrbBody->fExit ) { HB_ULONG ul; pHrbBody->fInit = HB_TRUE; /* Initialize static variables first */ for( ul = 0; ul < pHrbBody->ulSymbols; ul++ ) /* Check _INITSTATICS functions */ { if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_INITEXIT ) { /* call (_INITSTATICS) function. This function assigns * literal values to static variables only. There is no need * to pass any parameters to this function because they * cannot be used to initialize static variable. */ /* changed to call VM execution instead of direct function address call * pHrbBody->pSymRead[ ul ].value.pFunPtr(); * [MLombardo] */ hb_vmPushSymbol( &( pHrbBody->pSymRead[ ul ] ) ); hb_vmPushNil(); hb_vmProc( 0 ); } } } }
static void hb_hrbExit( PHRB_BODY pHrbBody ) { if( pHrbBody->fExit ) { if( hb_vmRequestReenter() ) { HB_ULONG ul; pHrbBody->fExit = HB_FALSE; pHrbBody->fInit = HB_TRUE; for( ul = 0; ul < pHrbBody->ulSymbols; ul++ ) { if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_EXIT ) { hb_vmPushSymbol( pHrbBody->pSymRead + ul ); hb_vmPushNil(); hb_vmProc( 0 ); if( hb_vmRequestQuery() != 0 ) break; } } hb_vmRequestRestore(); } } }
LRESULT CALLBACK ControlWindowProcedure( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { PHB_ITEM pBlock = ( PHB_ITEM ) GetProp( hwnd, TEXT( "BLOCKCALLBACK" ) ); long lRet; if( pBlock ) { if( hb_itemType( pBlock ) == HB_IT_POINTER ) { hb_vmPushSymbol( hb_dynsymSymbol( ( ( PHB_SYMB ) pBlock )->pDynSym ) ); hb_vmPushNil(); } else { hb_vmPushEvalSym(); hb_vmPush( pBlock ); } hb_vmPushNumInt( ( HB_PTRUINT ) hwnd ); hb_vmPushInteger( msg ); hb_vmPushNumInt( ( HB_PTRUINT ) wParam ); hb_vmPushNumInt( ( HB_PTRUINT ) lParam ); hb_vmDo( 4 ); lRet = ( long ) hb_parnint( -1 ); return lRet; } return DefWindowProc( hwnd, msg, wParam, lParam ); }
static void hb_hrbDo( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams ) { PHB_ITEM pRetVal = NULL; int i; hb_hrbInit( pHrbBody, iPCount, pParams ); /* May not have a startup symbol, if first symbol was an INIT Symbol (was executed already). */ if( pHrbBody->lSymStart >= 0 && hb_vmRequestQuery() == 0 ) { hb_vmPushSymbol( &pHrbBody->pSymRead[ pHrbBody->lSymStart ] ); hb_vmPushNil(); for( i = 0; i < iPCount; i++ ) hb_vmPush( pParams[ i ] ); hb_vmProc( ( HB_USHORT ) iPCount ); pRetVal = hb_itemNew( NULL ); hb_itemMove( pRetVal, hb_stackReturnItem() ); } if( pRetVal ) hb_itemReturnRelease( pRetVal ); }
PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo ) { HB_THREAD_STUB PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_evalLaunch(%p)", pEvalInfo ) ); if( pEvalInfo ) { register USHORT uiParam = 1; if( HB_IS_STRING( pEvalInfo->pItems[ 0 ] ) ) { const char * ptr = pEvalInfo->pItems[ 0 ]->item.asString.value; hb_vmPushSymbol( hb_dynsymFindName( ptr )->pSymbol ); hb_vmPushNil(); while( uiParam <= pEvalInfo->paramCount ) hb_vmPush( pEvalInfo->pItems[ uiParam++ ] ); hb_vmDo( pEvalInfo->paramCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); } else if( HB_IS_BLOCK( pEvalInfo->pItems[ 0 ] ) ) { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pEvalInfo->pItems[ 0 ] ); while( uiParam <= pEvalInfo->paramCount ) hb_vmPush( pEvalInfo->pItems[ uiParam++ ] ); hb_vmSend( pEvalInfo->paramCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); } } return pResult; }
PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo ) { PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_evalLaunch(%p)", pEvalInfo ) ); if( pEvalInfo ) { PHB_ITEM pItem = pEvalInfo->pItems[ 0 ]; PHB_SYMB pSymbol = NULL; if( HB_IS_STRING( pItem ) ) { PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value ); if( pDynSym ) { pSymbol = pDynSym->pSymbol; pItem = NULL; } } else if( HB_IS_SYMBOL( pItem ) ) { pSymbol = pItem->item.asSymbol.value; pItem = NULL; } else if( HB_IS_BLOCK( pItem ) ) { pSymbol = &hb_symEval; } if( pSymbol ) { HB_USHORT uiParam = 0; hb_vmPushSymbol( pSymbol ); if( pItem ) hb_vmPush( pItem ); else hb_vmPushNil(); while( uiParam < pEvalInfo->paramCount ) hb_vmPush( pEvalInfo->pItems[ ++uiParam ] ); if( pItem ) hb_vmSend( uiParam ); else hb_vmProc( uiParam ); pResult = hb_itemNew( hb_stackReturnItem() ); } } return pResult; }
static char * sz_callhrb_i( char * szName, int iParam1 ) { PHB_DYNS pSym_onEvent = hb_dynsymFindName( szName ); if( pSym_onEvent ) { hb_vmPushSymbol( hb_dynsymSymbol( pSym_onEvent ) ); hb_vmPushNil(); hb_vmPushInteger( iParam1 ); hb_vmDo( 1 ); return (char *) hb_parc(-1); } else return ""; }
static char * sz_callhrb_sz( char * szName, char * szParam1 ) { PHB_DYNS pSym_onEvent = hb_dynsymFindName( szName ); if( pSym_onEvent ) { hb_vmPushSymbol( hb_dynsymSymbol( pSym_onEvent ) ); hb_vmPushNil(); hb_vmPushString( szParam1, strlen( szParam1 ) ); hb_vmDo( 1 ); return (char *) hb_parc(-1); } else return ""; }
static void hb_hrbInit( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams ) { if( pHrbBody->fInit ) { if( hb_vmRequestReenter() ) { HB_ULONG ul; HB_BOOL fRepeat, fClipInit = HB_TRUE; int i; pHrbBody->fInit = HB_FALSE; pHrbBody->fExit = HB_TRUE; do { fRepeat = HB_FALSE; ul = pHrbBody->ulSymbols; while( ul-- ) { /* Check INIT functions */ if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_INIT ) { if( strcmp( pHrbBody->pSymRead[ ul ].szName, "CLIPINIT$" ) ? ! fClipInit : fClipInit ) { hb_vmPushSymbol( pHrbBody->pSymRead + ul ); hb_vmPushNil(); for( i = 0; i < iPCount; i++ ) hb_vmPush( pParams[ i ] ); hb_vmProc( ( HB_USHORT ) iPCount ); if( hb_vmRequestQuery() != 0 ) break; } else if( fClipInit ) fRepeat = HB_TRUE; } } fClipInit = HB_FALSE; } while( fRepeat && hb_vmRequestQuery() == 0 ); hb_vmRequestRestore(); } } }
/* NOTE: Same as hb_itemDo(), but even simpler, since the function name can be directly passed as a zero terminated string. [vszakats] */ PHB_ITEM hb_itemDoC( const char * szFunc, HB_SIZE ulPCount, ... ) { HB_THREAD_STUB PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDoC(%s, %hu, ...)", szFunc, ulPCount ) ); if( szFunc ) { PHB_DYNS pDynSym; pDynSym = hb_dynsymFindName( szFunc ); if( pDynSym ) { hb_vmPushState(); hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); if( ulPCount ) { register ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } hb_vmDo( ( USHORT ) ulPCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); hb_vmPopState(); } } return pResult; }
/* same functionality but with a NULL terminated list of parameters */ void hb_evalBlock( PHB_ITEM pCodeBlock, ... ) { va_list args; UINT uiParams = 0; PHB_ITEM pParam; hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pCodeBlock ); va_start( args, pCodeBlock ); while( ( pParam = va_arg( args, PHB_ITEM ) ) != NULL ) { hb_vmPush( pParam ); ++uiParams; } va_end( args ); hb_vmSend( ( USHORT ) uiParams ); }
/* NOTE: Same as hb_itemDoC(), but has additional second parameter which set the reference mask for 1-st 32/64 parametes [druzus] */ PHB_ITEM hb_itemDoCRef( char * szFunc, HB_SIZE ulRefMask, HB_SIZE ulPCount, ... ) { HB_THREAD_STUB PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDoCRef(%s, %hu, %hu, ...)", szFunc, ulRefMask, ulPCount ) ); if( szFunc ) { PHB_DYNS pDynSym; pDynSym = hb_dynsymFindName( szFunc ); if( pDynSym ) { hb_vmPushState(); hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); if( ulPCount ) { PHB_ITEM pItemRefBuf[ sizeof( HB_SIZE ) * 8 ]; HB_ITEM itmRef; register HB_SIZE ulParam; HB_SIZE ulRef = 0; va_list va; PHB_ITEM * pRefBase; PHB_ITEM pParam; pRefBase = pItemRefBuf; /* initialize the reference item */ itmRef.type = HB_IT_BYREF; itmRef.item.asRefer.offset = -1; itmRef.item.asRefer.BasePtr.itemsbasePtr = &pRefBase; va_start( va, ulPCount ); for( ulParam = 0; ulParam < ulPCount; ulParam++ ) { pParam = va_arg( va, PHB_ITEM ); if( ulRefMask & ( 1L << ulParam ) ) { /* when item is passed by reference then we have to put * the reference on the stack instead of the item itself */ pItemRefBuf[ ulRef++ ] = pParam; itmRef.item.asRefer.value = ( LONG ) ulRef; /* hb_vmPush( &itmRef ); */ pParam = &itmRef; } hb_vmPush( pParam ); } va_end( va ); } hb_vmDo( ( USHORT ) ulPCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); hb_vmPopState(); } } return pResult; }
static void s_pushMethod( PHB_IOUSR pIO, int iMethod ) { hb_vmPushSymbol( pIO->prg_funcs[ iMethod - 1 ] ); hb_vmPushNil(); }
//------------------------------------------------------------------------------ // 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 ); }
CLIPPER WBRWPANE( PARAMS ) // ( hWnd, hDC, Self, bLine, aSizes, nFirstItem, // nClrFore, nClrBack, hFont, aJustify, nStyle // lCellStyle, lFocused ) -> nRowsSkipped // bTextColor, bBkColor, nClrLine, nColorFondo, bFont ) // New's by CesoTech #endif { HWND hWnd = ( HWND ) _parnl( 1 ); HDC hDC = ( HDC ) _parnl( 2 ); WORD wRows; WORD wLastBottom = 0; WORD wRow = 1; WORD wSkipped = 1; PCLIPVAR Self = _param( 3, -1 ); PCLIPVAR bLine = _param( 4, -1 ); PCLIPVAR pASizes = _param( 5, -1 ); HFONT hFont = ( HFONT ) _parnl( 9 ); HFONT hOldFont; BOOL bDestroyDC = FALSE; WORD wHeight ; RECT rct, box, client; WORD wIndex = _parni( 6 ); PCLIPVAR bClrFore = 0, bClrBack = 0; COLORREF clrFore = 0; COLORREF clrBack = 0; HPEN hGrayPen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) ); HPEN hWhitePen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); // GetStockObject( WHITE_PEN ); #ifndef __HARBOUR__ BOOL bColBlock = pASizes->wType & BLOCK; #else BOOL bColBlock = hb_itemType( pASizes ) & BLOCK; PHB_ITEM aLine = hb_itemNew( NULL ); #endif PCLIPVAR pAJustify = ISARRAY( 10 ) ? _param( 10, -1 ): 0; WORD nHeightCtrl ; // by CeSoTech WORD nStyle = _parni( 11 ); if( PCOUNT() > 6 ) { if( ISBLOCK( 7 ) ) bClrFore = _param( 7, -1 ); else clrFore = _parnl( 7 ); } if( PCOUNT() > 7 ) { if( ISBLOCK( 8 ) ) { bClrBack = _param( 8, -1 ); _cEval0( bClrBack ); clrBack = _parnl( -1 ); } else clrBack = _parnl( 8 ); } if( ! hDC ) { bDestroyDC = TRUE; hDC = GetDC( hWnd ); } if( ! pSkip ) pSkip = _Get_Sym( "SKIP" ); if( hFont ) hOldFont = SelectObject( hDC, hFont ); ///////////////////////// // Borremos el Area de la derecha no coubierta if ( !bAdjBrowse && !bAdjLastCol ) { GetClientRect( hWnd, &rct ); SetBkColor( hDC, _parnl( 17 ) ) ; for( wIndex=wIndex ; wIndex <= (WORD) _parinfa( 5, NULL); wIndex++ ) { rct.left += _parni( 5, wIndex ) ; } if ( !(nStyle == 0 || nStyle == 7 || nStyle == 8 || nStyle == 3) ) rct.left++; ExtTextOut( hDC, rct.left, rct.top, ETO_OPAQUE | ETO_CLIPPED, &rct, "", 0, 0 ); wIndex = _parni( 6 ); GetClientRect( hWnd, &rct ); } ///////////////////////// GetClientRect( hWnd, &client ); nHeightCtrl = client.bottom-client.top ; // by CeSoTech wHeight = wLineHeight + 1 ; wRows = WBrwRowsC( hWnd, hDC, hFont ); if( ! bClrFore ) SetTextColor( hDC, clrFore ); SetBkColor( hDC, clrBack ); while( wRow <= wRows && wSkipped == 1 ) { rct.top = client.top + ( bDrawHeaders ? wHeaderHeight+1 : 0 ) + (wHeight * (wRow-1) ) ; rct.bottom = rct.top + wHeight; rct.left = 0; rct.right = client.right; #ifndef __HARBOUR__ _cEval0( bLine ); _xPushM( _eval ); if( bClrFore ) { _cEval0( bClrFore ); SetTextColor( hDC, _parnl( -1 ) ); } if( bClrBack ) { _cEval0( bClrBack ); SetBkColor( hDC, _parnl( -1 ) ); } if( bColBlock ) _cEval0( pASizes ); PaintTheLine( hDC, &rct, wIndex, _tos, ( bColBlock ? _eval : pASizes ), hWhitePen, hGrayPen, bColBlock, pAJustify, 0, FALSE, _parni( 11 ), _parni ( 12 ), _parl( 13 ), ISBLOCK( 14 ) ? _param( 14, -1 ) : 0, // CeSoTech ISBLOCK( 15 ) ? _param( 15, -1 ) : 0, // CeSoTech wRow, nHeightCtrl, // CeSoTech ISNUM( 16 ) ? _parnl( 16 ) : -1, // CeSoTech FALSE, FALSE, // CeSoTech ISBLOCK( 18 ) ? _param( 18, -1 ) : 0, // CeSoTech FALSE ) ; _tos--; _PutSym( pSkip ); _xPushM( Self ); _PutQ( 1 ); _xSend( 1 ); #else { // aLine.type = HB_IT_NIL; // Esta extension de xHarbour no se puede aplicar en Harbour // hb_itemForwardValue( aLine, hb_vmEvalBlock( bLine ) ); hb_itemCopy( aLine, hb_vmEvalBlock( bLine ) ); if( bClrFore ) { _cEval0( bClrFore ); SetTextColor( hDC, _parnl( -1 ) ); } if( bClrBack ) { _cEval0( bClrBack ); SetBkColor( hDC, _parnl( -1 ) ); } PaintTheLine( hDC, &rct, wIndex, aLine, ( bColBlock ? hb_vmEvalBlock( pASizes ) : pASizes ), hWhitePen, hGrayPen, bColBlock, pAJustify, 0, FALSE, _parnl( 11 ), _parnl ( 12 ), _parl( 13 ), ISBLOCK( 14 ) ? _param( 14, -1 ) : 0, // CeSoTech ISBLOCK( 15 ) ? _param( 15, -1 ) : 0, // CeSoTech wRow, nHeightCtrl, // CeSoTech ISNUM( 16 ) ? _parnl( 16 ) : -1, // CeSoTech FALSE, FALSE, // CeSoTech ISBLOCK( 18 ) ? _param( 18, -1 ) : 0, // CeSoTech FALSE ) ; if ( pSkip ) { hb_vmPushSymbol( hb_dynsymSymbol( pSkip ) ); hb_vmPush( Self ); hb_vmPushLong( 1 ); hb_vmDo( 1 ); } } #endif wLastBottom = rct.bottom ; wSkipped = _parni( -1 ); if( wSkipped == 1 ) wRow++; } //////////////////////// // Borremos el Area de Abajo no cubierta GetClientRect( hWnd, &rct ); SetBkColor( hDC, _parnl( 17 ) ) ; rct.top = wLastBottom + 1 ; if ( wLastBottom == 0 ) // No Mostro Registros rct.top = ( bDrawHeaders ? wHeaderHeight+1 : 0 ) ; rct.bottom-= 1 + ( bDrawFooters ? wFooterHeight+1 : 0 ) ; if (nStyle == 0 || nStyle == 5 || nStyle == 6 || nStyle == 9 || nStyle == 10 || nStyle == 3 ) rct.top--; if ( !bDrawFooters ) rct.bottom++; if ( rct.top < rct.bottom ) { ExtTextOut( hDC, rct.left, rct.top, ETO_OPAQUE | ETO_CLIPPED, &rct, "", 0, 0 ); } //////////////////////// DeleteObject( hGrayPen ); DeleteObject( hWhitePen ); if( hFont ) SelectObject( hDC, hOldFont ); if( bDestroyDC ) ReleaseDC( hWnd, hDC ); _retni( wRow ); }
HB_BOOL hb_execFromArray( PHB_ITEM pParam ) { PHB_ITEM pArray = NULL; PHB_ITEM pSelf = NULL; HB_ULONG ulParamOffset = 0; if( pParam && HB_IS_ARRAY( pParam ) && ! HB_IS_OBJECT( pParam ) ) { pArray = pParam; pParam = hb_arrayGetItemPtr( pArray, 1 ); if( HB_IS_OBJECT( pParam ) ) { pSelf = pParam; pParam = hb_arrayGetItemPtr( pArray, 2 ); ulParamOffset = 2; } else ulParamOffset = 1; } if( pParam ) { PHB_SYMB pExecSym = NULL; if( HB_IS_SYMBOL( pParam ) ) pExecSym = hb_itemGetSymbol( pParam ); else if( HB_IS_STRING( pParam ) ) pExecSym = hb_dynsymGet( hb_itemGetCPtr( pParam ) )->pSymbol; else if( HB_IS_BLOCK( pParam ) && ! pSelf ) { pSelf = pParam; pExecSym = &hb_symEval; } if( pExecSym ) { int iPCount = 0; hb_vmPushSymbol( pExecSym ); if( pSelf ) hb_vmPush( pSelf ); else hb_vmPushNil(); if( pArray ) { pParam = hb_arrayGetItemPtr( pArray, ++ulParamOffset ); while( pParam && iPCount < 255 ) { hb_vmPush( pParam ); ++iPCount; pParam = hb_arrayGetItemPtr( pArray, ++ulParamOffset ); } } if( pSelf ) hb_vmSend( ( HB_USHORT ) iPCount ); else hb_vmProc( ( HB_USHORT ) iPCount ); return HB_TRUE; } } hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); return HB_FALSE; }
/* undocumented Clipper _cEval0() */ void hb_evalBlock0( PHB_ITEM pCodeBlock ) { hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pCodeBlock ); hb_vmSend( 0 ); }
PHB_ITEM hb_itemDo( PHB_ITEM pItem, HB_ULONG ulPCount, ... ) { PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDo(%p, %lu, ...)", pItem, ulPCount ) ); if( pItem ) { PHB_SYMB pSymbol = NULL; if( HB_IS_STRING( pItem ) ) { PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value ); if( pDynSym ) { pSymbol = pDynSym->pSymbol; pItem = NULL; } } else if( HB_IS_SYMBOL( pItem ) ) { pSymbol = pItem->item.asSymbol.value; pItem = NULL; } else if( HB_IS_BLOCK( pItem ) ) { pSymbol = &hb_symEval; } if( pSymbol ) { if( hb_vmRequestReenter() ) { hb_vmPushSymbol( pSymbol ); if( pItem ) hb_vmPush( pItem ); else hb_vmPushNil(); if( ulPCount ) { HB_ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } if( pItem ) hb_vmSend( ( HB_USHORT ) ulPCount ); else hb_vmProc( ( HB_USHORT ) ulPCount ); pResult = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); } } } return pResult; }
PHB_ITEM hb_itemDo( PHB_ITEM pItem, HB_SIZE ulPCount, ... ) { HB_THREAD_STUB PHB_ITEM pResult = NULL; HB_TRACE( HB_TR_DEBUG, ( "hb_itemDo(%p, %hu, ...)", pItem, ulPCount ) ); if( pItem ) { PHB_SYMB pSymbol = NULL; if( HB_IS_STRING( pItem ) ) { PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value ); if( pDynSym ) pSymbol = pDynSym->pSymbol; } else if( HB_IS_POINTER( pItem ) ) pSymbol = ( PHB_SYMB ) pItem->item.asPointer.value; else if( HB_IS_SYMBOL( pItem ) ) pSymbol = pItem->item.asSymbol.value; if( pSymbol ) { hb_vmPushState(); hb_vmPushSymbol( pSymbol ); hb_vmPushNil(); if( ulPCount ) { register ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } hb_vmDo( ( USHORT ) ulPCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); hb_vmPopState(); } else if( HB_IS_BLOCK( pItem ) ) { hb_vmPushState(); hb_vmPushSymbol( &hb_symEval ); hb_vmPush( pItem ); if( ulPCount ) { register ULONG ulParam; va_list va; va_start( va, ulPCount ); for( ulParam = 1; ulParam <= ulPCount; ulParam++ ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } hb_vmSend( ( USHORT ) ulPCount ); pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); hb_vmPopState(); } else if( HB_IS_ARRAY( pItem ) ) { hb_vmPushState(); if( hb_execFromArray( pItem ) ) { pResult = hb_itemNew( NULL ); hb_itemForwardValue( pResult, &( HB_VM_STACK.Return ) ); } hb_vmPopState(); } } return pResult; }
/* throwing a CT-subsystem error without value substitution - function adapted from errorapi.c */ HB_USHORT ct_error( HB_USHORT uiSeverity, HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation, HB_ERRCODE errOsCode, HB_USHORT uiFlags, HB_ULONG ulArgCount, ... ) { HB_USHORT uiAction; PHB_ITEM pError; PHB_ITEM pArray; va_list va; HB_ULONG ulArgPos; HB_TRACE( HB_TR_DEBUG, ( "ct_error(%hu, %d, %d, %s, %s, %d, %hu, %lu)", uiSeverity, errGenCode, errSubCode, szDescription, szOperation, errOsCode, uiFlags, ulArgCount ) ); pError = hb_errRT_New( uiSeverity, CT_SUBSYSTEM, errGenCode, errSubCode, szDescription, szOperation, errOsCode, uiFlags ); /* Build the array from the passed arguments. */ if( ulArgCount == 0 ) { pArray = NULL; } else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS ) { if( hb_pcount() == 0 ) pArray = NULL; else pArray = hb_arrayBaseParams(); } else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS ) { pArray = hb_arraySelfParams(); } else { pArray = hb_itemArrayNew( ulArgCount ); va_start( va, ulArgCount ); for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ ) { hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) ); } va_end( va ); } if( pArray ) { /* Assign the new array to the object data item. */ hb_vmPushSymbol( hb_dynsymGetSymbol( "_ARGS" ) ); hb_vmPush( pError ); hb_vmPush( pArray ); hb_vmSend( 1 ); /* Release the Array. */ hb_itemRelease( pArray ); } /* launch error codeblock */ uiAction = hb_errLaunch( pError ); /* release error codeblock */ hb_errRelease( pError ); return uiAction; }
BOOL hb_execFromArray( PHB_ITEM pFirst ) { register ULONG i; HB_SIZE ulLen; ULONG ulStart = 1; PHB_ITEM pArgs; PHB_ITEM pString; PHB_ITEM pSelf = NULL; PHB_DYNS pExecSym = NULL; PHB_SYMB pSymbol = NULL; if( pFirst == NULL || pFirst->type != HB_IT_ARRAY ) return FALSE; pString = hb_arrayGetItemPtr( pFirst, 1 ); pArgs = pFirst; if( HB_IS_OBJECT( pString ) && hb_arrayLen( pFirst ) >= 2 ) { pSelf = pString; pString = hb_arrayGetItemPtr( pFirst, 2 ); if( pString->type == HB_IT_STRING ) pExecSym = hb_dynsymFindName( pString->item.asString.value ); else if( pString->type == HB_IT_POINTER ) pSymbol = ( PHB_SYMB ) hb_itemGetPtr( pString ); ulStart = 3; } else if( pString->type == HB_IT_STRING ) { pExecSym = hb_dynsymFindName( pString->item.asString.value ); ulStart = 2; } else if( pString->type == HB_IT_POINTER ) { pSymbol = ( PHB_SYMB ) hb_itemGetPtr( pString ); ulStart = 2; } else if( HB_IS_BLOCK( pString ) ) { pSymbol = &hb_symEval; ulStart = 2; } if( pExecSym ) pSymbol = pExecSym->pSymbol; if( pSymbol == NULL ) return FALSE; hb_vmPushSymbol( pSymbol ); if( pSelf ) hb_vmPush( pSelf ); else hb_vmPushNil(); ulLen = hb_arrayLen( pArgs ); /* pushing the contents of the array */ for( i = ulStart; i <= ulLen; i++ ) hb_vmPush( hb_arrayGetItemPtr( pArgs, i ) ); if( pSelf ) hb_vmSend( ( USHORT ) ( ulLen - ulStart + 1 ) ); else hb_vmDo( ( USHORT ) ( ulLen - ulStart + 1 ) ); return TRUE; }