[2.1-alpha.9] GuiControl.Prototype.OnMessage receives Gui in the callback's first parameter.

Report problems with documented functionality
ntepa
Posts: 429
Joined: 19 Oct 2022, 20:52

[2.1-alpha.9] GuiControl.Prototype.OnMessage receives Gui in the callback's first parameter.

Post by ntepa » 08 Apr 2024, 22:28

I expected the GuiOrCtrlObj parameter to be Gui if the callback was passed to Gui.Prototype.OnMessage or GuiControl if GuiControl.Prototype.OnMessage is used. Instead, I always get a Gui object.

Code: Select all

#Requires AutoHotkey v2.1-alpha.9

g := Gui()
editCtrl := g.AddEdit("w200", "Edit")
LV := g.AddListView("w200 h100", [1,2,3])

WM_MOUSEMOVE := 0x0200
editCtrl.OnMessage(WM_MOUSEMOVE, GuiControlCallback)
LV.OnMessage(WM_MOUSEMOVE, GuiControlCallback)
OnMessage(WM_MOUSEMOVE, OnMessageCallback)
g.Show()

GuiControlCallback(GuiOrCtrlObj, wParam, lParam, msg) {
    ; GuiOrCtrlObj is always Gui
    OutputDebug("GuiControl.OnMessage: " Type(GuiOrCtrlObj))
}

OnMessageCallback(wParam, lParam, msg, hwnd) {
    ; If hovering over a control, hwnd is a handle to the control.
    if CtrlObj := GuiCtrlFromHwnd(hwnd)
        OutputDebug("OnMessage: " Type(CtrlObj))
}

Return to “Bug Reports”