Ok I read through that post. So, I guess now we'll see if I got the intended meaning out of it.
For an example, to extend the ListView control to have a few extra methods, is this the suggested / preferred way, or at least one of the paths of least resistance:
Code: Select all
class ListView_Ext extends Gui.ListView { ; Technically no need to extend classes unless
Static __New() { ; you are attaching new base on control creation.
For prop in this.Prototype.OwnProps()
super.Prototype.%prop% := this.Prototype.%prop%
}
IsChecked(row) { ; This was taken directly from the AutoHotkey help files.
return (SendMessage(4140,row-1,0xF000,, "ahk_id " this.hwnd) >> 12) - 1 ; VM_GETITEMSTATE = 4140 / LVIS_STATEIMAGEMASK = 0xF000
}
IconIndex(row,col:=1) { ; from "just me" LV_EX ; Link: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=69262&p=298308#p299057
LVITEM := Buffer((A_PtrSize=8)?56:40, 0) ; create variable/structure
NumPut("UInt", 0x2, "Int", row-1, "Int", col-1, LVITEM.ptr, 0) ; LVIF_IMAGE := 0x2 / iItem (row) / column num
NumPut("Int", 0, LVITEM.ptr, (A_PtrSize=8)?36:28) ; iImage
SendMessage(StrLen(Chr(0xFFFF))?0x104B:0x1005, 0, LVITEM.ptr,, "ahk_id " this.hwnd) ; LVM_GETITEMA/W := 0x1005 / 0x104B
return NumGet(LVITEM.ptr, (A_PtrSize=8)?36:28, "Int")+1 ;iImage
}
GetColWidth(n) {
return SendMessage(0x101D, n-1, 0, this.hwnd)
}
}
Apart from the above code, I know that it is also possible to omit
Static __New() and either:
- extend the Gui class to override .Add() when creating a ListView
or
- to simply assign the prototype of the class to the base of an instantiated control (this, I believe, is my main method lately, embedded in the extending class)
The intent/criteria I'm looking to accomplish is very similar to swagfag's, namely:
- not require anything from the client code other than #Include
- only exception to the above maybe would be to require that #Include be near the top to ensure the class __New() method is run on script init before control creation.
- and also the rest of swagfag's criteria is what I'm also going for
Is that about right?