Page 1 of 1

[solved]Ahk V2 Listview ControlSetStyle problem

Posted: 09 Sep 2018, 01:25
by rodemp

Code: Select all

Gui := GuiCreate(,"Fixed Colum Width")
LV := Gui.Add("ListView", "r15 w200 Grid NoSortHdr -LV0x10", "A|B|C|D")
LVHeader:=SendMessage(0x101F, 0, 0, , "ahk_id " . LV.HWND) ; LVM_GETHEADER = 0x101F
ControlSetStyle +0x0800, , "ahk_id " . LVHeader
Loop 10
	LV.Add(,a_index,a_index+1,a_index*a_index)
Gui.Show()
Gui.OnEvent("Close", "Gui_Close")

Gui_Close() {
	ExitApp
}
When Fixed Colum Width is applied, there is a problem that the focus is lost when the column is clicked.

Code: Select all

;ahk v1
Gui, Add, ListView, r15 w200 Grid NoSortHdr -LV0x10 hwndLV, A|B|C|D
Loop 10
	LV_Add(,a_index,a_index+1,a_index*a_index)
SendMessage, 0x101F, 0, 0, , % "ahk_id " . LV
LVHeader:=ErrorLevel
Control, Style, +0x0800, , % "ahk_id " . LVHeader
Gui, Show,, Fixed Colum Width
Return

GuiClose:
ExitApp

Re: Ahk V2 Listview ControlSetStyle problem  Topic is solved

Posted: 21 Sep 2018, 23:50
by rodemp

Code: Select all

Gui := GuiCreate(,"Fixed Colum Width")
LV := Gui.Add("ListView", "r15 w200 Grid NoSortHdr -LV0x10", "A|B|C|D")
LVHeader:=SendMessage(0x101F, 0, 0, , "ahk_id " . LV.HWND) ; LVM_GETHEADER = 0x101F
ControlSetStyle "+0x0800", , "ahk_id " . LVHeader
Loop 10
	LV.Add(,a_index,a_index+1,a_index*a_index)
Gui.Show()
Gui.OnEvent("Close", "Gui_Close")

Gui_Close() {
	ExitApp
}
ControlSetStyle style parameter must be enclosed in ""

or

currentstyle:=ControlGetStyle(,"ahk_id " LVHeader)
ControlSetStyle(currentstyle|0x0800, ,"ahk_id " LVHeader)