Jump to content

ActiveX w/ AutoIt


Recommended Posts

Does anyone know how to get this ActiveX control to work with AutoIt? I can get the control to display in AutoIt's GUI but cannot access its methods or properties.

ActiveX source can be downloaded here (click the 'Download demo project' at the bottom):

http://www.codeguru.com/cpp/com-tech/activ...icle.php/c5517/

I also had to comment out the following line in the function (void CPlotCtrl::OnDraw) in file (PlotCtl.cpp) to get the sin graph to display correctly (for some reason):

pdc->FillRect (m_DrawRect,&hbrBackground); // <---- I had to comment out this line

This control works perfectly unmodified in VB6 (no need to comment out the line and methods and properties work fine)...what's the deal?

-Livewire

Link to comment
Share on other sites

Link to comment
Share on other sites

@livewire

AU3 can not build ActiveX controles natively, only use ActiveX controls.

Ypu can create your COM Objects using Windows Script Components

regards,

ptrex

@ptrex,

I know that AU3 cannot build ActiveX controls. In this post, I'm saying that AU3 cannot use the C++ ActiveX control mentioned in the ActiveX tutorial link in the first post.

-Livewire

Link to comment
Share on other sites

@livewire

Sorry for the misunderstanding, was a little to quick.

Maybe this can be of any help.

#include <GUIConstants.au3>

; EXAMPLE
;
; Just experimenting around with the Forms 2.0 controls
;
; However, its poorly documented by Microsoft

; Initialize my error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Create a new Forms collection
$oForm = ObjCreate("Forms.Form.1")

; Initialize a custom Event Handler
$oFormEvt=ObjEvent($oForm,"Form_")

$oForm.caption = "Forms Frame Test" ; OK!

$oForm.Zoom=100
;Some more gadgets to play with:

;$oForm.ScrollWidth=200
;$oForm.ScrollHeight=200

;$oForm.InsideWidth(100)
;$oForm2.ShowGridDots(1)
;$oForm2.Width=200

; The undocumented 'Add' method adds ONLY Forms 2.0 controls.
; Why is that?  I don't know yet.
$oButton=$oForm.Add("Forms.CommandButton.1","TestButton",1)   ;ok
$oButtonEvt=ObjEvent($oButton,"Button_")

With $oButton
    .caption="Test Button"
    .Left=10
    .Top=8
    .Height=20
    .Width=70
    .Visible=1
EndWith

$oCheckBox=$oForm.Add("Forms.CheckBox.1","TestCheck",1)   ;ok
$oCheckBoxEvt=ObjEvent($oCheckBox,"CheckBox_")

With $oCheckBox
    .caption="Test Check"
    .Left=10
    .Top=28
    .Height=20
    .Width=100
    .Visible=1
EndWith

$oSpinButton=$oForm.Add("Forms.SpinButton.1","TestSpin",1)   ;ok
$oSpinButtonEvt=ObjEvent($oSpinButton,"SpinButton_")

With $oSpinButton
    .Left=10
    .Top=45
    .Height=15
    .Width=50
    .Visible=1
EndWith

$oToggleButton=$oForm.Add("Forms.ToggleButton.1","TestToggle",1)   ;ok
With $oToggleButton
    .caption="Test Toggle"
    .Left=10
    .Top=63
    .Height=20
    .Width=50
    .Visible=1
EndWith


$oForm.repaint ; Not really necessary

; Create a simple GUI for our test output
GUICreate ( "Embedded ActiveX Test", 640, 480,(@DesktopWidth-640)/2, (@DesktopHeight-480)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE )

$GUI_ActiveX    =   GUICtrlCreateObj ( $oForm, 30, 30 , 400 , 400 )
$GUI_Label      =   GUICtrlCreateLabel ( "", 10, 420 , 300 , 20 )

GUISetState ()       ;Show GUI

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

GUIDelete ()

; Clear all created objects.
$oCheckBoxEvt=""
$oCheckBox=""
$oSpinButtonEvt=""
$oSpinButton=""
$oToggleButton=""
$oButtonEvt=""  ; Clear button event handler
$oButton=""     ; Remove the button
$oFormEvt=""    ; Clear form event handler
$oForm=""       ; Clear form

Exit

; This is my custom error handler
Func MyErrFunc()

  $HexNumber=hex($oMyError.number,8)

  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )

  SetError(1)  ; to check for after this function returns
Endfunc

; -----Some example Event Functions
;
; NOTE: Events can already appear BEFORE the GUI is fully initialized.
; That's why the 'If Isdeclared ...' must be used.


; This one catches all unused 'Form' events
Func Form_($Event)
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"Form Unused Event: " & $Event)
EndFunc

Func Form_MouseMove($Button, $Shift, $X, $Y)
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"Form Mousemove: X:" & round($X,2)  & "  Y:" & round($Y,2))
EndFunc

Func Form_Click()
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"Form: Single mouseclick!")
EndFunc

Func Button_Click()
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"Button: Single mouseclick!")
EndFunc

Func Button_DblClick()
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"Button: Double mouseclick!")
EndFunc

Func SpinButton_Change()
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"SpinButton: Change!")
EndFunc

Func SpinButton_SpinUp()
    If Isdeclared("GUI_Label") then GUICtrlSetData($GUI_Label,"SpinButton: SpinUp!")
EndFunc

regards,

ptrex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...