Honestly, I find the "typical parameter order" harder to remember than simple object properties. The letters are easier to remember than the parameter order (again, in my opinion). Additionally, I usually don't need all of them. And while it may be more efficient to only retrieve those that you'll use, having to remember which parameter to pass a var name to and which to skip is annoying and causes me to look at the docs much more frequently. It also creates a lot of spaghetti code with missing parameters. Code becomes bloated as well because now every byref parameter I pass in for each unique control must have a unique name. So instead of scoping the position values with a single unified object, I must prefix all of the properties variables with that same similar scoping prefix, ex: myCtrl.GetPos(myCtrlX, myCtrlY, myCtrlH, myCtrlW).No need to remember W vs. Width, H vs. Height, just the typical parameter order.
Another argument was:
If that's a valid concern, then I propose the following. Change GuiCtrl.GetPos to return the same object that GuiCtrl.Pos used to but cache the coordinates. Instead, have the method accept a single, optional parameter that forces the window position to be re-queried and a new object created (and re-cached).Avoids the gc.Pos.X, gc.Pos.Y, etc. anti-pattern (repeatedly retrieving window position and creating multiple objects).
Would love to hear other's thoughts on this topic.
Code: Select all
main := Gui.new("+Resize +MinSize", "User Search")
main.OnEvent("size", "mainResize")
main.OnEvent("close", (*) => main.hide())
; off screen default button for searching via Enter
main.addButton("x-100 w25 Default", "Submit").OnEvent("click", "userSearch")
searchBox := main.addEdit("xm ym w150 Section vSearchBox 0x2000000")
SetEditCueBanner(searchBox.hwnd, "Search")
EM_SETMARGIN(searchBox.hwnd, 0, 20)
resetSearchFn := Func("resetSearch").bind(searchBox)
searchClearGui := Gui.new("-Caption +Parent" searchBox.hwnd " 0x40000000")
searchClearGui.MarginX := searchClearGui.MarginY := 0
searchClearGui.BackColor := "White"
searchClear := searchClearGui.addButton("w15 h15", Chr(10005))
searchClear.OnEvent("Click", resetSearchFn)
searchClearGui.Show("x" searchBox.pos.w - 20)
main.addRadio("xs+20 vsearchType Checked", "Users").OnEvent("Click", resetSearchFn)
main.addRadio("yp", "Groups").OnEvent("Click", resetSearchFn)
resultsLV := main.addListView("r10 xs w150 vresults -Multi +LV0x4000", "Users")
resultsLV.OnEvent("ItemSelect", "handleSelection")
resultsLV.OnNotify(LVN_GETEMPTYMARKUP := -187, "lvMarkupHandler")
SetExplorerTheme(resultsLV.hwnd)
grouper := main.addGroupBox("ys-6 w300 h" searchBox.pos.h + resultsLV.pos.h + main["searchType"].pos.h + (main.MarginY * 3) " vGrouper")
main.setFont("s14")
main.addEdit("xp+5 yp+10 wp-10 r2 Center vName ReadOnly -E0x200 0x1 -VScroll")
; main.addEdit("y+-" main.MarginY " wp Center vTitle ReadOnly -E0x200")
main.setFont()
detailsLV := main.addListView("xp-2 y+m wp r" detailFields.length " vDetails Hidden BackgroundEEEEEE -E0x200 -Hdr +LV0x4000", "Label|Value")
detailsLV.OnEvent("ContextMenu", "lvContext")
for i, field in detailFields {
detailsLV.Add("", field)
}
detailsLV.ModifyCol(1)
width := SendMessage(LVM_GETCOLUMNWIDTH := 0x101D, 0, 0, detailsLV.hwnd)
detailsLV.ModifyCol(2, detailsLV.pos.w - width)
membershipLV := main.addListView("ys h" grouper.pos.h - 6 " w250 vGroups +LV0x4000 Sort", "AD Groups")
membershipLV.OnEvent("ContextMenu", "lvContext")
SetExplorerTheme(membershipLV.hwnd)
membershipLV.ModifyCol(1, membershipLV.pos.w - SysGet(2) - (SysGet(45) * 2))