11-28-2006, 08:28 PM
Function TB_AdjustSize
Function __tb_auto_size. This toolbar hook function adjusts toolbar size automatically.
Toolbar example
;/
function hWnd
;Adjusts QM toolbar width and height so that all (and only) buttons would be visible.
;EXAMPLE
;TB_AdjustSize win("TOOLBAR17" "QM_toolbar")
def TB_BUTTONCOUNT 0x00000418
def TB_GETITEMRECT 0x0000041D
def TB_GETBUTTONSIZE 0x0000043A
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(r.bottom-r.top<15) continue ;;hor sep
,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
r.left=0; r.top=0
AdjustWindowRectEx &r GetWinStyle(hWnd) 0 GetWinStyle(hWnd 1)
siz r.right-r.left r.bottom-r.top hWnd
Function __tb_auto_size. This toolbar hook function adjusts toolbar size automatically.
;/
function# hWnd message wParam lParam
dll user32 #GetCapture
sel message
,case WM_CREATE
,SetTimer hWnd 1 1000 0
,
,case WM_TIMER
,;KillTimer hWnd 1
,if(wParam=1)
,,if(GetCapture) ret
,,TB_AdjustSize hWnd
,
Toolbar example