08-13-2022, 10:46 AM
This should work well.
Function autotext_popup_resize
Trigger !v"" "QM_PopupList" /QM
Function autotext_popup_resize
Trigger !v"" "QM_PopupList" /QM
;Resizes QM autotext popup lists. Can change font.
int hwnd=TriggerWindow
int hlv=child("" "SysListView32" hwnd)
if 1 ;;replace 1 with 0 if don't want to change font
,int style=GetWinStyle(hlv)
,__Font f.CreateNew(hlv "Comic Sans MS" 12) ;;change this
,SendMessage hlv WM_SETFONT f 1
,if(style&WS_VSCROLL=0 and style=GetWinStyle(hlv)) ret
else
,if(GetWinStyle(hlv)&WS_VSCROLL=0) ret
int widthPercent=150 ;;change this
RECT r.left=LVIR_BOUNDS; SendMessage(hlv LVM_GETITEMRECT 0 &r)
int ni=SendMessage(hlv LVM_GETITEMCOUNT 0 0)
if(ni>50) ni=50 ;;limit height to 50 items. Change the value if want.
r.bottom*ni
int y cx addWidth
RECT rm; MonitorFromIndex hwnd 0 rm
GetWinXY hwnd 0 y cx; y=rm.bottom-(y+r.bottom)-10; if(y<0) r.bottom+y
addWidth=MulDiv(cx widthPercent 100)-cx
cx+addWidth
siz cx r.bottom+4 hwnd
siz cx-4 r.bottom hlv
if addWidth
,SendMessage(hlv LVM_SETCOLUMNWIDTH 0 SendMessage(hlv LVM_GETCOLUMNWIDTH 0 0)+addWidth-(addWidth/10))
,SendMessage(hlv LVM_SETCOLUMNWIDTH 1 SendMessage(hlv LVM_GETCOLUMNWIDTH 1 0)+(addWidth/10))
wait 0 -WC hwnd