Detecting double-click on ListView's column header

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
think
Posts: 137
Joined: 09 Feb 2014, 05:20

Detecting double-click on ListView's column header

Post by think » 12 Jul 2022, 10:07

Hi, is it possible to detect when ListView column header is double-clicked?
In the code below I can detect double click on the content but only single view on the header.
Any tip is greatly appreciated.

Code: Select all

gui, Add, ListView, w200 h100 -LV0x10 NoSort gClick, Column 1|Column 2
gui, show
return

Click:
if (A_GuiEvent = "ColClick")
	msgbox % "Column clicked: " A_EventInfo
if (A_GuiEvent = "DoubleClick")
   msgbox Double clicked
return

User avatar
neovis
Posts: 34
Joined: 12 Jun 2022, 03:56
Location: Republic of Korea
Contact:

Re: Detecting double-click on ListView's column header

Post by neovis » 12 Jul 2022, 10:40

As far as I know, it is not supported in basic commands.

This is using OnMessage.

Code: Select all

OnMessage(0x203, "WM_LBUTTONDBLCLK")

WM_LBUTTONDBLCLK(wparam, lparam, msg, hwnd) {
    WinGetClass class, % "ahk_id" hwnd
    if (class == "SysHeader32") {
        hwnd := DllCall("GetParent", "ptr",hwnd, "ptr") ; hListView from hHeader
        
        VarSetCapacity(hti, 24, 0)
        DllCall("GetCursorPos", "ptr",&hti)
        DllCall("ScreenToClient", "ptr",hwnd, "ptr",&hti)
        
        ; LVM_SUBITEMHITTEST
        DllCall("SendMessage", "ptr",hwnd, "uint",0x1039, "uptr",0, "ptr",&hti)
        column := NumGet(hti, 16, "int")+1 ; iSubItem
        
        ToolTip % "Column: " column
    }
}

Post Reply

Return to “Ask for Help (v1)”