示例
#NoEnv
; #Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
OnMessage(0x404, "AHK_NOTIFYICON")
Gosub OpenSetting
Menu,Tray,Tip,单击或双击托盘图标打开窗口
Return
OpenSetting:
Gui,Test:Destroy
Gui,Test:Default
Gui,Test:+Resize
SysGet, CXVSCROLL, 2
LVWidth:=LVWidth?LVWidth:350,LVHeight:=LVHeight?LVHeight:150 ;设定listview尺寸
,CGuiHeight:=0,CGuiWidth:=0 ;初始化
Gui,Test:Add, ListView,w%LVWidth% h%LVHeight% AltSubmit Grid +E0x10 -LV0x10 -Multi NoSortHdr -WantF2 0x8 LV0x40 LV0x800 LV0x80 gControl_Gui vSetHLV HWNDHLV, 编号|内容
LV_ModifyCol(1,LVWidth*0.25),LV_ModifyCol(2,LVWidth*0.75-CXVSCROLL*(A_ScreenDPI/96) " Center"),Count:=1
Loop,15
LV_Add("",A_Index,Count++ "-1")
LV:=New ExtLV(HLV)
Gui,Test:Show,AutoSize,SendMessage操作ListView
return
TestGuiSize:
if A_Cursor In SizeNESW,SizeNS,SizeNWSE,SizeWE
{
GuiControlGet,CGSize,Test:Pos,SetHLV
if (!CGuiHeight&&!CGuiWidth&&CGSizeW=LVWidth) {
Gui, Test:+MinSize%A_GuiWidth%x%A_GuiHeight%
}else{
GuiControlGet,CGSize,Test:Pos,SetHLV
GuiControl,Test:Move,SetHLV,% "w" CGSizeW+A_GuiWidth-CGuiWidth " h" CGSizeH+A_GuiHeight-CGuiHeight
LV_ModifyCol(1,(CGSizeW+A_GuiWidth-CGuiWidth)*0.25),LV_ModifyCol(2,(CGSizeW+A_GuiWidth-CGuiWidth)*0.75-CXVSCROLL*(A_ScreenDPI/96))
}
CGuiHeight:=A_GuiHeight,CGuiWidth:=A_GuiWidth,LVWidth:=CGSizeW,LVHeight:=CGSizeH
}
return
Control_Gui:
Gui,Test:Submit,NoHide
Switch A_GuiControl
{
Case "SetHLV":
LV.GetItemHitPos(lRows,lColumn) ;获取点击行列号
SubItemText:=LV.GetSubItemText(lRows,lColumn)
ColumnWidth:=LV.GetColumnWidth(lColumn)
ToolTipBox.ToolTip("行:" lRows "`n列:" lColumn "`n单元格内容:" SubItemText "`n列宽:" ColumnWidth,,,6,{auto_color:True})
}
Return
TestGuiClose:
Gui,Test:Destroy
Return
AHK_NOTIFYICON(wParam, lParam, uMsg, hWnd){
if (lParam = 0x201||lParam = 0x203) {
Gosub OpenSetting
}
}
如果有需要完善的地方大家可以接力完成,以此打造一个系列完整且有据可依的Gui控件操作扩展库。让零散的片段形成个完整的调用参考标准。