Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Auto toolbar height
This version also has flags for toolbars that must have single horizontal or vertical line of buttons.

Function TB_AdjustSize
Copy      Help
function hWnd [flags] ;;flags: 1 horizontal tb, 2 vertical tb

;Adjusts QM toolbar width and height so that all (and only) buttons would be visible.

;TB_AdjustSize win("TOOLBAR17" "QM_toolbar")

def TB_BUTTONCOUNT 0x00000418
def TB_GETITEMRECT 0x0000041D
dll user32 #AdjustWindowRectEx RECT*lpRect dsStyle bMenu dwEsStyle

int htb=id(9999 hWnd)
RECT r; int cx cy i
for i 0 SendMessage(htb TB_BUTTONCOUNT 0 0)
,SendMessage(htb TB_GETITEMRECT i &r)
,if(<15) continue ;;hor sep
,sel flags&3
,,case 1
,,if(r.right>cx) cx=r.right; else cx+r.right-r.left
,,if(cy=0) cy=r.bottom
,,case 2
,,if(r.bottom>cy) cy=r.bottom; else
,,if(cx=0) cx=r.right
,,case else
,,if(r.right>cx) cx=r.right
,,if(r.bottom>cy) cy=r.bottom
if(cx) r.right=cx; r.bottom=cy
else i=SendMessage(htb TB_GETBUTTONSIZE 0 0); r.right=i&0xffff; r.bottom=i>>16

AdjustWindowRectEx &r GetWinStyle(hWnd) 0 GetWinStyle(hWnd 1)
siz r.right-r.left hWnd

Messages In This Thread

Forum Jump:

Users browsing this thread: 1 Guest(s)