// FiveWin ActiveX support (32 bits only)
#include "FiveWin.ch"
#ifndef __XPP__
#define HKEY_CLASSES_ROOT 2147483648
#else
#define HKEY_CLASSES_ROOT 1
#endif
//----------------------------------------------------------------------------//
CLASS TActiveX FROM TControl
CLASSDATA lRegistered AS LOGICAL
DATA hActiveX
DATA cProgID
DATA cString
DATA aProperties, aMethods, aEvents
DATA bOnEvent
METHOD New( oWnd, cProgID, nRow, nCol, nWidth, nHeight ) CONSTRUCTOR
METHOD ReDefine( nId, oWnd, cProgID ) CONSTRUCTOR
METHOD Do( cMethodName, uParam1, uParam2, uParam3 )
METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
METHOD EraseBkGnd( hDC ) INLINE 1
METHOD GetProp( cPropName ) INLINE ;
ActXGetProperty( ActXPdisp( ::hActiveX ), cPropName )
METHOD Initiate( hDlg )
METHOD OnEvent( nEvent, aParams )
METHOD ReadTypes()
METHOD ReSize( nFlags, nWidth, nHeight ) INLINE ;
ActXSetLocation( ::hActiveX, 0, 0, nWidth, nHeight )
METHOD SetProp( cPropName, uParam1 ) INLINE ;
ActXSetProperty( ActXPdisp( ::hActiveX ), cPropName, uParam1 )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( oWnd, cProgID, nRow, nCol, nWidth, nHeight ) CLASS TActiveX
DEFAULT oWnd := GetWndDefault(), nRow := 0, nCol := 0, nWidth := 200,;
nHeight := 200
::nTop = nRow
::nLeft = nCol
::nBottom = nRow + nHeight
::nRight = nCol + nWidth
::oWnd = oWnd
::nId = ::GetNewId()
::nStyle = nOR( WS_CHILD, WS_VISIBLE )
::cProgID = cProgID
::cString = ActXString( cProgID )
::Register()
if ! Empty( oWnd:hWnd )
::Create()
oWnd:AddControl( Self )
::hActiveX = CreateActiveX( ::hWnd, cProgID, Self )
::nTop = nRow
::nLeft = nCol
::nWidth = nWidth
::nHeight = nHeight
::ReadTypes()
else
oWnd:DefControl( Self )
endif
return Self
//----------------------------------------------------------------------------//
METHOD Do( cMethodName, uParam1, uParam2, uParam3, uParam4 ) CLASS TActiveX
local uRet
do case
case PCount() == 1
uRet = ActXInvoke( ActXPdisp( ::hActiveX ), cMethodName )
case PCount() == 2
uRet = ActXInvoke( ActXPdisp( ::hActiveX ), cMethodName, uParam1 )
case PCount() == 3
uRet = ActXInvoke( ActXPdisp( ::hActiveX ), cMethodName, uParam1, uParam2 )
case PCount() == 4
uRet = ActXInvoke( ActXPdisp( ::hActiveX ), cMethodName, uParam1, uParam2,;
uParam3 )
case PCount() == 5
uRet = ActXInvoke( ActXPdisp( ::hActiveX ), cMethodName, uParam1, uParam2,;
uParam3, uParam4 )
endcase
return uRet
//----------------------------------------------------------------------------//
METHOD ReDefine( nId, oWnd, cProgID ) CLASS TActiveX
DEFAULT oWnd := GetWndDefault()
::nId = nId
::oWnd = oWnd
::cProgID = cProgID
::cString = ActXString( cProgID )
::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
oWnd:DefControl( Self )
return Self
//----------------------------------------------------------------------------//
METHOD Initiate( hDlg ) CLASS TActiveX
Super:Initiate( hDlg )
::hActiveX = CreateActiveX( ::hWnd, ::cProgID, Self )
::ReadTypes()
return nil
//----------------------------------------------------------------------------//
METHOD OnEvent( nEvent, aParams, pParams ) CLASS TActiveX
local nAt := AScan( ::aEvents, { | aEvent | aEvent[ 2 ] == nEvent } )
local cEvent := If( nAt != 0, ::aEvents[ nAt ][ 1 ], "" )
if ! Empty( ::bOnEvent )
Eval( ::bOnEvent, If( ! Empty( cEvent ), cEvent, nEvent ), aParams, pParams )
endif
return nil
//----------------------------------------------------------------------------//
METHOD ReadTypes() CLASS TActiveX
local oReg := TReg32():New( HKEY_CLASSES_ROOT, "CLSID\" + ::cString + ;
"\InprocServer32" )
local cTypeLib := oReg:Get( "" )
oReg:Close()
if ! Empty( cTypeLib ) .and. File( cTypeLib )
::aEvents = ActXEvents( cTypeLib, ::hActiveX )
endif
return nil
//----------------------------------------------------------------------------//
MsgInfo( "paso1" )
oCRApp := CreateObject( "CrystalRuntime.Application.12" )
MsgInfo( "paso2" )
Subsystem:
TOLEauto
SubCode:
65535
Operation:
TOLEAUTO:NEW
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: nageswaragunupudi and 50 guests