Page 1 of 1

[v2] ActiveX ComObjConnect example

Posted: 24 Sep 2021, 17:29
by swagfag
https://lexikos.github.io/v2/docs/commands/GuiControls.htm#ActiveX
this(current) v2 code doesnt work:

Code: Select all

MyGui := Gui()
URL := MyGui.Add("Edit", "w930 r1", "https://www.autohotkey.com/boards/")
MyGui.Add("Button", "x+6 yp w44 Default", "Go").OnEvent("Click", ButtonGo)
WB := MyGui.Add("ActiveX", "xm w980 h640", "Shell.Explorer").Value
ComObjConnect(WB, WB_events)  ; Connect WB's events to the WB_events class object.
MyGui.Show()
; Continue on to load the initial page:
ButtonGo()

ButtonGo(*) {
    WB.Navigate(URL.Value)
}

class WB_events {
    NavigateComplete2(wb, NewURL) {
        URL.Value := NewURL  ; Update the URL edit control.
    }
}

this one does:

Code: Select all

MyGui := Gui()
URL := MyGui.Add("Edit", "w930 r1", "https://www.autohotkey.com/boards/")
MyGui.Add("Button", "x+6 yp w44 Default", "Go").OnEvent("Click", ButtonGo)
WB := MyGui.Add("ActiveX", "xm w980 h640", "Shell.Explorer").Value
ComObjConnect(WB, WB_events)  ; Connect WB's events to the WB_events class object.
MyGui.Show()
; Continue on to load the initial page:
ButtonGo()

ButtonGo(*) {
    WB.Navigate(URL.Value)
}

class WB_events {
    static NavigateComplete2(wb, &NewURL, OriginalComObj) {
        URL.Value := NewURL  ; Update the URL edit control.
    }
}

Re: [v2] ActiveX ComObjConnect example  Topic is solved

Posted: 26 Sep 2021, 07:24
by Ragnar
Thanks for reporting. Change added in PR #492.