Jump to content

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


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?


Link to post
Share on other sites


Sorry for the misunderstanding, was a little to quick.

Maybe this can be of any help.

#include <GUIConstants.au3>

; 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

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

;Some more gadgets to play with:



; 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

With $oButton
    .caption="Test Button"

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

With $oCheckBox
    .caption="Test Check"

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

With $oSpinButton

$oToggleButton=$oForm.Add("Forms.ToggleButton.1","TestToggle",1)   ;ok
With $oToggleButton
    .caption="Test Toggle"

$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

GUIDelete ()

; Clear all created objects.
$oButtonEvt=""  ; Clear button event handler
$oButton=""     ; Remove the button
$oFormEvt=""    ; Clear form event handler
$oForm=""       ; Clear form


; This is my custom error handler
Func MyErrFunc()


  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

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

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

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

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

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

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

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



Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...