#include once "window9.bi"

Function GadgetWidth(ByVal iGadget As Long) As Long Export
	dim as HWND hWin = gadgetid(iGadget)
	dim as Hwnd hExtWin = GetProp(hWin,"addparam60000")
	If win9GetGadgetClass(hExtWin)=14 Then
        Dim As RECT rEdit , rBut
        GetWindowRect(Cast(HWND,hWin),@rEdit)
        GetWindowRect(Cast(HWND,hExtWin),@rBut)
        Return Cast(Long,rBut.right - rEdit.left)
	EndIf
	Dim As RECT r
	GetWindowRect(Cast(HWND,hWin),@r)
	Return Cast(Long,r.right-r.left)
End Function
