[v2] ListView EmptyText

Post your working scripts, libraries and tools
User avatar
kczx3
Posts: 978
Joined: 06 Oct 2015, 21:39

[v2] ListView EmptyText

30 Mar 2019, 20:21

Here's a quick little demo on how to set the empty text to be displayed in a ListView control. Requires Vista+. See LVN_GETEMPTYMARKUP and LVN_LINKCLICK. The LVM_RESETEMPTYTEXT message is undocumented.

Uses AHK v2-a100.

Code: Select all

global count := 0

main := GuiCreate()

btn := main.addButton(, "Increase count")
btn.OnEvent("click", () => SendMessage(LVM_RESETEMPTYTEXT := 0x1054, 0, 0, LV.hwnd))

LV := main.addListView("w600 h400", "Column 1|Column 2")

LV.OnNotify(LVN_GETEMPTYMARKUP := -187, "setEmptyText")
LV.OnNotify(LVN_LINKCLICK := -184, () => ToolTip("Clicked!"))

main.show()
return

setEmptyText(ctrl, l) {
    text := "<a>My empty text!`nCount = " count++ "</a>"
    ; see LVN_GETEMPTYMARKUP
    
    ; 0 displays the text in the upper-left corner while 1 displays it centered both vertically and horizontally
    NumPut(0x1, l, A_PtrSize * 3, "UInt")
    
    ; put our string in the buffer
    StrPut(text, l + A_PtrSize * 3 + 4, StrLen(text))
    
    return true ; you must return true in order to set the text.  This can be used to your advantage to return false to not change it possibly
}

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 46 guests