Class ActiveX

Class ActiveX

Postby lailton.webmaster » Tue Aug 04, 2009 6:23 am

estoy finalizando las melhorias en la class ToleWevents pero ainda necessito de una ajuda,
estoy testando un activeX que necessito passar pelo objetos valores e recebelos,

EX:

Code: Select all  Expand view
public top:=0, width:=0, left:=0, right:=0
myActive:GetWindowRect( @top, @width, @left, @right)

Msginfo(top) // con la Class TActiveX funciona perfeitamente pero con la ToleWevents da GPFs


yo no entendo de C/C++ Alguem pode ajudar ?
creio que necessita alterar alguna cosa en lo arquivo C

Arquivo: ToleWevents.c
Code: Select all  Expand view
/*
 *  Events for OLE
 *  (c) 2008 Carlos Mora (carlosantoniomora@yahoo.es - harbouradvisor.blogspot.com )
 *  based on the work of Oscar Lira Lira for ActiveX
 *    (oscarlira78@hotmail.com - http://_...net)
 */


#ifndef NONAMELESSUNION
   #define NONAMELESSUNION
#endif

#ifndef _HB_API_INTERNAL_
   #define _HB_API_INTERNAL_
#endif

#include <hbvmopt.h>
#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>
#include <hbvm.h>
#include <hbstack.h>
#include <ocidl.h>
#include <hbapiitm.h>

#ifdef HB_ITEM_NIL
   #define hb_dynsymSymbol( pDynSym )        ( ( pDynSym )->pSymbol )
#endif

PHB_SYMB s___GetMessage = NULL;

typedef HRESULT ( WINAPI *LPAtlAxWinInit )       ( void );
typedef HRESULT ( WINAPI *LPAtlAxGetControl )    ( HWND, IUnknown** );
typedef HRESULT ( WINAPI *LPAtlAxCreateControl ) ( LPCOLESTR, HWND, IStream*, IUnknown** );

HMODULE hDll = NULL;
LPAtlAxWinInit       AtlAxWinInit;
LPAtlAxGetControl    AtlAxGetControl;
LPAtlAxCreateControl AtlAxCreateControl;

static void LoadAtl( void )
{
   if( ! hDll )
   {
      hDll = LoadLibrary( "Atl.dll" );
      AtlAxWinInit       = ( LPAtlAxWinInit )       GetProcAddress( hDll, "AtlAxWinInit" );
      AtlAxGetControl    = ( LPAtlAxGetControl )    GetProcAddress( hDll, "AtlAxGetControl" );
      AtlAxCreateControl = ( LPAtlAxCreateControl ) GetProcAddress( hDll, "AtlAxCreateControl" );
      AtlAxWinInit();
   }
}

HB_FUNC( OLEWECREATE )
{
   HWND hWndCtrl;

   LoadAtl();
   hWndCtrl = CreateWindowEx(
      (DWORD)   0                   ,   // nExStyle
      (LPCTSTR) "AtlAxWin"          ,   // cClsName
      (LPCTSTR) hb_parc( 1 )        ,   // cProgId
      (DWORD)   WS_OVERLAPPEDWINDOW ,   // style
                CW_USEDEFAULT       ,   // nLeft
                CW_USEDEFAULT       ,   // nTop
                0                   ,   // nWidth
                0                   ,   // nHeight
                HWND_DESKTOP        ,    // oParent:handle
               0,
               0,
               NULL );

   hb_retnl( (long) hWndCtrl );

}

HB_FUNC( OLEWEDESTROY )
{
   DestroyWindow( (HWND) hb_parnl( 1 ) );

}



HB_FUNC( OLEGETDISP )
{
   IUnknown *pUnk;
   IDispatch *pDisp;
   LoadAtl();
   AtlAxGetControl( (HWND) hb_parnl( 1 ), &pUnk );
   if (pUnk)
   {
      pUnk->lpVtbl->QueryInterface( pUnk, &IID_IDispatch, ( void ** ) &pDisp );
      pUnk->lpVtbl->Release( pUnk );
      hb_retnl( (long) pDisp );
   }
}

HRESULT hb_oleVariantToItem( PHB_ITEM pItem, VARIANT *pVariant );

static void HB_EXPORT hb_itemPushList( ULONG ulRefMask, ULONG ulPCount, PHB_ITEM** pItems )
{
   PHB_ITEM itmRef;
   ULONG ulParam;

   if( ulPCount )
   {
      itmRef = hb_itemNew( NULL );

      itmRef->type = HB_IT_BYREF;
      itmRef->item.asRefer.offset = -1;
      itmRef->item.asRefer.BasePtr.itemsbasePtr = pItems;
      for( ulParam = 0; ulParam < ulPCount; ulParam++ )
      {
         if( ulRefMask & ( 1L << ulParam ) )
         {
            itmRef->item.asRefer.value = ulParam+1;
            hb_vmPush( itmRef );
         }
         else
         {
            hb_vmPush( (*pItems)[ulParam] );
         }
      }

      hb_itemRelease( itmRef );
   }
}

#undef  INTERFACE
#define INTERFACE IEventHandler

DECLARE_INTERFACE_ ( INTERFACE, IDispatch )
{
   STDMETHOD  ( QueryInterface          ) ( THIS_ REFIID, void **                                                          ) PURE;
   STDMETHOD_ ( ULONG, AddRef           ) ( THIS                                                                           ) PURE;
   STDMETHOD_ ( ULONG, Release          ) ( THIS                                                                           ) PURE;
   STDMETHOD_ ( ULONG, GetTypeInfoCount ) ( THIS_ UINT *                                                                   ) PURE;
   STDMETHOD_ ( ULONG, GetTypeInfo      ) ( THIS_ UINT, LCID, ITypeInfo **                                                 ) PURE;
   STDMETHOD_ ( ULONG, GetIDsOfNames    ) ( THIS_ REFIID, LPOLESTR *, UINT, LCID, DISPID *                                 ) PURE;
   STDMETHOD_ ( ULONG, Invoke           ) ( THIS_ DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT * ) PURE;
};


typedef struct {

   IEventHandler*          lpVtbl;
   DWORD                   count;
   IConnectionPoint*       pIConnectionPoint;
   DWORD                   dwEventCookie;
   IID                     device_event_interface_iid;
   PHB_ITEM                pEvents;
   PHB_ITEM                pEventsExec;

} MyRealIEventHandler;

static HRESULT STDMETHODCALLTYPE QueryInterface( IEventHandler *this, REFIID vTableGuid, void **ppv )
{

   if ( IsEqualIID( vTableGuid, &IID_IUnknown ) )
   {
      *ppv = (IUnknown*) this;
      this->lpVtbl->AddRef( this );
      return S_OK;
   }

   if ( IsEqualIID( vTableGuid, &IID_IDispatch ) )
   {
      *ppv = (IDispatch*) this;
      this->lpVtbl->AddRef( this );
      return S_OK;
   }

   if ( IsEqualIID( vTableGuid, &(((MyRealIEventHandler*) this)->device_event_interface_iid ) ) )
   {
      *ppv = (IDispatch*) this;
      this->lpVtbl->AddRef( this );
      return S_OK;
   }

   *ppv = 0;
   return(E_NOINTERFACE);
}

static ULONG STDMETHODCALLTYPE AddRef(IEventHandler *this)
{
   return(++((MyRealIEventHandler *) this)->count);
}

static ULONG STDMETHODCALLTYPE Release(IEventHandler *this)
{
   if (--((MyRealIEventHandler *) this)->count == 0)
   {
      GlobalFree(this);
      return(0);
   }
   return(((MyRealIEventHandler *) this)->count);
}

static ULONG STDMETHODCALLTYPE GetTypeInfoCount(IEventHandler *this, UINT *pCount)
{
   HB_SYMBOL_UNUSED(this);
   HB_SYMBOL_UNUSED(pCount);
   return E_NOTIMPL;
}

static ULONG STDMETHODCALLTYPE GetTypeInfo(IEventHandler *this, UINT itinfo, LCID lcid, ITypeInfo **pTypeInfo)
{
   HB_SYMBOL_UNUSED(this);
   HB_SYMBOL_UNUSED(itinfo);
   HB_SYMBOL_UNUSED(lcid);
   HB_SYMBOL_UNUSED(pTypeInfo);
   return E_NOTIMPL;
}

static ULONG STDMETHODCALLTYPE GetIDsOfNames(IEventHandler *this, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)
{
   HB_SYMBOL_UNUSED(this);
   HB_SYMBOL_UNUSED(riid);
   HB_SYMBOL_UNUSED(rgszNames);
   HB_SYMBOL_UNUSED(cNames);
   HB_SYMBOL_UNUSED(lcid);
   HB_SYMBOL_UNUSED(rgdispid);
   return E_NOTIMPL;
}

static ULONG STDMETHODCALLTYPE Invoke( IEventHandler *this, DISPID dispid, REFIID riid,
   LCID lcid, WORD wFlags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *pexcepinfo,
   UINT *puArgErr )
{
   PHB_ITEM pItem;
   USHORT iArg, i;
   PHB_ITEM pItemArray[32];
   PHB_ITEM *pItems;
   ULONG ulRefMask = 0;
   ULONG ulPos;
   PHB_ITEM Key;
   BOOL bDefault = FALSE;

   Key = hb_itemNew( NULL );

   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);

   ulPos = hb_arrayScan( ((MyRealIEventHandler* ) this)->pEvents, hb_itemPutNL( Key, dispid ),
      NULL, NULL, 0
         #ifdef __XHARBOUR__
            , 0
         #endif
      );
   if ( !ulPos )
   {
      ulPos = hb_arrayScan( ((MyRealIEventHandler* ) this)->pEvents, hb_itemPutNL( Key, 0 ),
      NULL, NULL, 0
         #ifdef __XHARBOUR__
            , 0
         #endif
      );
      bDefault = TRUE;
   };


   if ( ulPos )
   {
      PHB_ITEM pExec = hb_arrayGetItemPtr( ((MyRealIEventHandler* ) this)->pEventsExec, ulPos );

      if ( pExec )
      {

         hb_vmPushState();

         switch ( hb_itemType( pExec ) )
         {

            case HB_IT_BLOCK:
            {
               hb_vmPushSymbol( &hb_symEval );
               hb_vmPush( pExec );
               break;
            }

            case HB_IT_STRING:
            {
               hb_vmPushSymbol( hb_dynsymSymbol( hb_dynsymFindName( hb_itemGetCPtr( pExec ) ) ) );
               hb_vmPushNil();
               break;

            }

            case HB_IT_POINTER:
            {
               hb_vmPushSymbol( hb_dynsymSymbol( ( (PHB_SYMB) pExec ) -> pDynSym ) );
               hb_vmPushNil();
               break;
            }

         }

         if( bDefault )
         {
            // in default event manager (0), first param will be the EventId
            hb_vmPushLong( dispid );
         }

         iArg = (USHORT) params->cArgs;
         for( i = 1; i<= iArg; i++ )
         {
            pItem = hb_itemNew(NULL);
            hb_oleVariantToItem( pItem, &(params->rgvarg[iArg-i]) );
            pItemArray[i-1] = pItem;
            ulRefMask |= ( 1L << (i-1) );
         }

         if( iArg )
         {
            pItems = pItemArray;
            hb_itemPushList( ulRefMask, iArg, &pItems );
         }

         hb_vmDo( (USHORT) ( iArg + ( bDefault ? 1 : 0 ) ) );

         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_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) = hb_itemGetL( pItemArray[i-1] ) ? (USHORT) 0xFFFF : (USHORT)  0;
                     break;
                  case VT_DATE|VT_BYREF:
                     *((&(params->rgvarg[iArg-i]))->n1.n2.n3.pdate)    = (DATE) (double) (hb_itemGetDL(pItemArray[i-1])-2415019 );
                     break;
               }
            }
         }
         hb_vmPopState();
      }
   }

   hb_itemRelease( Key );
   return S_OK;

}

static const IEventHandlerVtbl IEventHandler_Vtbl = {
   QueryInterface,
   AddRef,
   Release,
   GetTypeInfoCount,
   GetTypeInfo,
   GetIDsOfNames,
   Invoke
};

typedef IEventHandler device_interface;

//-----------------------------------------------
HB_FUNC( OLECONNECTEVENTS )
//-----------------------------------------------
{
   IConnectionPointContainer*  pIConnectionPointContainerTemp = NULL;
   IUnknown*                   pIUnknown = NULL;
   IConnectionPoint*           m_pIConnectionPoint;
   IEnumConnectionPoints*      m_pIEnumConnectionPoints;
   HRESULT                     hr; //,r;
   IID                         rriid;
   register IEventHandler *    thisobj;
   DWORD                       dwCookie = 0;

   device_interface*           pdevice_interface = (device_interface*) hb_parnl( 1 );
   MyRealIEventHandler*        pThis;

   thisobj = ( IEventHandler *) GlobalAlloc( GMEM_FIXED, sizeof( MyRealIEventHandler ) );

   if ( thisobj )
   {
      thisobj->lpVtbl = (IEventHandlerVtbl *) &IEventHandler_Vtbl;

      ((MyRealIEventHandler *) thisobj)->count = 0;

      ((MyRealIEventHandler *) thisobj)->device_event_interface_iid = IID_IDispatch;

      hr = thisobj->lpVtbl->QueryInterface( thisobj, &IID_IUnknown, (void**) &pIUnknown );
      if ( hr == S_OK && pIUnknown )
      {

         hr = pdevice_interface->lpVtbl->QueryInterface( pdevice_interface,
            &IID_IConnectionPointContainer, (void**) &pIConnectionPointContainerTemp );

         if ( hr == S_OK && pIConnectionPointContainerTemp )
         {
            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);
            }
            pIConnectionPointContainerTemp->lpVtbl->Release( pIConnectionPointContainerTemp );
            pIConnectionPointContainerTemp = NULL;
         }

         if ( hr == S_OK && m_pIConnectionPoint )
         {
            if( hr == S_OK )
            {
               ((MyRealIEventHandler *) thisobj)->device_event_interface_iid = rriid;
            };

            m_pIConnectionPoint->lpVtbl->Advise( m_pIConnectionPoint, pIUnknown, &dwCookie );
            ((MyRealIEventHandler *) thisobj)->pIConnectionPoint = m_pIConnectionPoint;
            ((MyRealIEventHandler *) thisobj)->dwEventCookie = dwCookie;

         }

         pIUnknown->lpVtbl->Release(pIUnknown);
         pIUnknown = NULL;

      }
   }

   if( thisobj )
   {
      pThis = (void*) thisobj;

      pThis->pEvents     = hb_itemNew( hb_param( 2, HB_IT_ANY ) );
      pThis->pEventsExec = hb_itemNew( hb_param( 3, HB_IT_ANY ) );
      hb_retnl( (LONG) pThis );
   }
   else
   {
      hb_ret();
   };

}

//-----------------------------------------------
HB_FUNC( OLEDISCONNECTEVENTS )
//-----------------------------------------------
{
   MyRealIEventHandler *this = ( MyRealIEventHandler * ) hb_parnl( 1 );
   if( this->pIConnectionPoint )
   {
      this->pIConnectionPoint->lpVtbl->Unadvise( this->pIConnectionPoint, this->dwEventCookie );
      this->dwEventCookie = 0;
      this->pIConnectionPoint->lpVtbl->Release( this->pIConnectionPoint );
      this->pIConnectionPoint = NULL;
   }
}

//-----------------------------------------------
HB_FUNC( OLEFREEDISPATCH )
//-----------------------------------------------
{
   IDispatch * pObj;
   pObj = ( IDispatch * ) hb_parnl( 1 );
   pObj->lpVtbl->Release( pObj );
}

 

gracias.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby lailton.webmaster » Tue Aug 04, 2009 11:38 am

More information / mais informarcion

Description
Gets the bounding rectangle of the command bar. This is the area of the window that the command bar occupies

Syntax

Public Sub GetWindowRect( _
ByRef Left As Long, _
ByRef Top As Long, _
ByRef Right As Long, _
ByRef Bottom As Long _
)

Parameters
Left
The left point of the window rectangle
Top
The top point of the window rectangle
Right
The right point of the window rectangle
Bottom
The bottom point of the window rectangle

lo erro acontece en la chamada oAct:GetWindowRect(@left, @top, @right, @bottom) // GPF aqui


Code: Select all  Expand view
ERro

Application
===========
   Path and name: C:\Event\demo.exe (32 bits)
   Size: 1,675,264 bytes
   Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 08/04/09, 08:40:40
   Error description: Error 18926648/15  DISP_E_PARAMNOTOPTIONAL: GETWINDOWRECT
   Args:
     [   1] = N   0
     [   2] = N   0
     [   3] = N   0
     [   4] = N   0

Stack Calls
===========
   Called from: source\rtl\win32ole.prg => TOLEAUTO:GETWINDOWRECT(0)
   Called from:  => HB_EXECFROMARRAY(0)
   Called from: MYACTIVEX.PRG => MYACTIVEX&#058;GETWINDOWRECT(243)
   Called from: DEMO.PRG => MAIN(38)
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby Antonio Linares » Tue Aug 04, 2009 1:04 pm

Lailton,

Try this:

oAct:GetRect() --> aRect // 4 elements array
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Class ActiveX

Postby lailton.webmaster » Tue Aug 04, 2009 4:10 pm

Exemplo usando TActiveX, ( Funcionando Bien )
Code: Select all  Expand view
#include "fivewin.ch"

function main()

 public oWnd
 public oCommandbar
 public oRibbonbar
 public oToolA

 public Left:=Top:=Right:=Bottom:=0

 define window ownd

    oCommandBar:= TactiveX():New(oWnd,"Codejock.CommandBarsFrame.12.1.1",0,0,0,0)
    oCommandBar:Do("AttachToWindow", oWnd:hWnd )
    oRibbonBar:= oCommandBar:Do("AddRibbonBar","Redstarsoft")
    oRibbonBar:EnableFrameTheme()

    cToolA:=oCommandBar:Do("Add","ToolBar", 0)
    cToolA:GetWindowRect( @Left, @Top, @Right, @Bottom )
 
    MsgInfo(Left)
    MsgInfo(Top)
    MsgInfo(Right)
    MsgInfo(Bottom)

 activate window ownd


return


Exemplo usando ToleWevent ( GPF )
Code: Select all  Expand view
#include "fivewin.ch"

function main

 public oWnd
 public oCommandbar
 public oRibbonbar
 public oToolA

 public Left:=Top:=Right:=Bottom:=0

 define window ownd

    oCommandBar:= OleWEvent():New("Codejock.CommandBars.12.1.1")
    oCommandBar:AttachToWindow( oWnd:hWnd )
    oRibbonBar:= oCommandBar:AddRibbonBar("Redstarsoft")
    oRibbonBar:EnableFrameTheme()

    cToolA:=oCommandBar:Add("ToolBar", 0)
    cToolA:GetWindowRect( @Left, @Top, @Right, @Bottom )
 
    MsgInfo(Left)
    MsgInfo(Top)
    MsgInfo(Right)
    MsgInfo(Bottom)

 activate window ownd
return


Antonio, tu pode me dizer una cosa, porque en la class ToleWevent yo necessito usar "Codejock.CommandBars.12.1.1"
pero "Codejock.CommandBarsFrame.12.1.1" return GPF ?

y con la TactiveX es lo iverso, yo necessito usar Codejock.CommandBarsFrame.12.1.1 y Codejock.CommandBars.12.1.1 return GPF.

No consito entender :(

Link abaxo con lo exemplos.
http://www.redstarsoft.com.br/TOleDemo.rar
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby lailton.webmaster » Thu Aug 06, 2009 1:45 am

:?:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby Antonio Linares » Thu Aug 06, 2009 8:15 am

Lailton,

> pero "Codejock.CommandBarsFrame.12.1.1" return GPF ?

It is very difficult (almost impossible) to know why, because we don't have the source for that activex.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Class ActiveX

Postby lailton.webmaster » Thu Aug 06, 2009 8:22 am

Antonio please revisa :
viewtopic.php?f=3&t=16311

Sample + CLASS ToleWevent

http://www.redstarsoft.com.br/TOleDemo.rar
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby Antonio Linares » Fri Aug 07, 2009 9:24 am

Lailton,

Please modify these lines and the GPF is solved :-)

oCommandBar:= OleWEvent():New("Codejock.CommandBars.13.0.0", oWnd:hWnd)

y
Code: Select all  Expand view

HB_FUNC( OLEWECREATE )
{
   HWND hWndCtrl;

   LoadAtl();
   hWndCtrl = CreateWindowEx(
      (DWORD)   0                   ,   // nExStyle
      (LPCTSTR) "AtlAxWin"          ,   // cClsName
      (LPCTSTR) hb_parc( 1 )        ,   // cProgId
      (DWORD)   WS_CHILD | WS_VISIBLE,   // style
                0       ,   // nLeft
                0      ,   // nTop
                200      ,   // nWidth
                200    ,   // nHeight
                ( HWND ) hb_parnl( 2 ),    // oParent:handle
               0,
               0,
               NULL );

   hb_retnl( (long) hWndCtrl );
}
 

You can use hb_parnl( 3 ) and hb_parnl( 4 ) for width and height and supply them from the PRG
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Class ActiveX

Postby lailton.webmaster » Fri Aug 07, 2009 10:50 am

Antonio,

Continue GPF,

i did it:

Code: Select all  Expand view
#include "fivewin.ch"
function main()
 public oWnd,oCommandbar,oToolA
 public Left:=Top:=Right:=Bottom:=0
 define window ownd
    oCommandBar:= OleWEvent():New("Codejock.CommandBars.13.0.0", oWnd:hWnd)
    oCommandBar:AttachToWindow( oWnd:hWnd )
    cToolA:=oCommandBar:Add("ToolBar", 0)
    cToolA:GetWindowRect( @Left, @Top, @Right, @Bottom )  // GPF
   // Gpf yet here  
    MsgInfo(Left)
    MsgInfo(Top)
    MsgInfo(Right)
    MsgInfo(Bottom)
 activate window ownd
return


Change class OleWevents.prg method new
Code: Select all  Expand view
METHOD New( cProgId, janela ) CLASS OleWEvent
   Local oError
   If ( ::hWnd := OLEWECREATE( cProgId , janela) ) != 0
      ::hObj := OleGetDisp( ::hWnd )
      TRY
         ::oOle := ToleAuto():New( ::hObj )
      CATCH oError
         QOut( oError:Description )
      END
      ::hSink := OleConnectEvents( ::hObj, ::aEvent:= {} , ::aBlock:= {} )
   EndIf
   RETURN SELF


and file C that you change.
Code: Select all  Expand view
HB_FUNC( OLEWECREATE )
{
   HWND hWndCtrl;

   LoadAtl();
   hWndCtrl = CreateWindowEx(
      (DWORD)   0                   ,   // nExStyle
      (LPCTSTR) "AtlAxWin"          ,   // cClsName
      (LPCTSTR) hb_parc( 1 )        ,   // cProgId
      (DWORD)   WS_CHILD | WS_VISIBLE,   // style
                0       ,   // nLeft
                0      ,   // nTop
                200      ,   // nWidth
                200    ,   // nHeight
                ( HWND ) hb_parnl( 2 ),    // oParent:handle
               0,
               0,
               NULL );

   hb_retnl( (long) hWndCtrl );
}


Estoy errado en alguna cosa ? necessita alterar algo mas ?

Gracias.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby lailton.webmaster » Fri Aug 07, 2009 11:08 am

Sample que estoy usando

Code: Select all  Expand view
#include "fivewin.ch"

function main()

 public oWnd,oCommandbar,oToolA
 public Left:=Top:=Right:=Bottom:=0

 define window ownd

    oCommandBar:= OleWEvent():New("Codejock.CommandBars.13.0.0", oWnd:hWnd)
    oCommandBar:AttachToWindow( oWnd:hWnd )

    cToolA:=oCommandBar:Add("ToolBar", 0)
    //cToolA:GetWindowRect( @Left, @Top, @Right, @Bottom )  // GPF nessa linha
    // se estiver marcada funciona normal.  pero necessito usar lo GetWindowRect y no posso  :(

    MsgInfo(Left)
    MsgInfo(Top)
    MsgInfo(Right)
    MsgInfo(Bottom)

 activate window ownd

return
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Class ActiveX

Postby Antonio Linares » Fri Aug 07, 2009 11:13 am

Lailton,

Why don't you simply use FWH Class TActiveX that works fine ?

You can use OleConnectEvents() to provide events support to OleAuto child objects of the ActiveX.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Class ActiveX

Postby lailton.webmaster » Fri Aug 07, 2009 8:28 pm

porque yo necessito delos source, estoy criando de form que funcione con harbour svn,
xharbour Free y xharbour Comercial, y tambem la class TactiveX estas tento muchas modificaciones
sieprete tiengo que ficar adaptando en mi aplicativos, ja con la ToleWevent funciona bem y consigo
compilar ja con xh free y xh comercial, y tambem con la class TactiveX usando Biometria da GPF (Screen of erro of windows)
pero con la ToleWevent it´s solved.

entos necessito mucho continuar con ela, pero necessito tambem solver este erro que estas me retornando en la chamada
GetWindowRect, creio que es o problem en passar variables @VAR,

tu disse que alterando las linhas estarias solved, poderia manda-me las modificaciones que fez para mi email para que eu
possa probar.

gracias
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests

cron