#include once "window9.bi"

Sub ToolTipStatusBar(ByVal gadget As Integer, ByVal NumberField As Integer, ByRef text As USTRING) Export
	#ifdef UNICODE
		Dim As wString Ptr pws = cast(any ptr , *text)	
	#else	
		Dim As wString Ptr pws = Cast(WString Ptr,StrPtr(text))			
	#EndIf
	SendMessage(GadgetID(gadget),SB_SETTIPTEXT,NumberField,Cast(LPARAM,pws))
End Sub

Function StatusBarGadget(ByVal gadget As long, ByRef SingleText As USTRING, ByVal style As Integer, ByVal style2 As Integer) As HWND Export
	#ifdef UNICODE
		var hwndStatusbar = CreateWindowEx(style2,STATUSCLASSNAME,*SingleText,WS_CHILD Or WS_VISIBLE Or style,0,0,0,0,win9GetCurrent(),NULL,0,NULL)
	#else	
		var hwndStatusbar = CreateWindowEx(style2,STATUSCLASSNAME,SingleText,WS_CHILD Or WS_VISIBLE Or style,0,0,0,0,win9GetCurrent(),NULL,0,NULL)
	#EndIf	
	win9AddNewGadget (gadget,hwndStatusbar)
	SetProp(win9GetCurrent(),"STATUSBARWINDOW",hwndStatusbar)
	win9AddColor(hwndStatusbar,15790320,0)
	If win9GetGadgetFont()<>0 Then
		SendMessage(hwndStatusbar ,WM_SETFONT,win9GetGadgetFont(),0)
	EndIf
	#ifdef UNICODE
		SendMessage(hwndStatusbar,SB_SETTEXT,255, Cast(lparam,*SingleText))
	#else	
		SendMessage(hwndStatusbar,SB_SETTEXT,255, Cast(lparam,StrPtr(SingleText)))
	#EndIf
	Return hwndStatusbar
End Function

Sub SetStatusBarField(ByVal gadget As long,ByVal NField As Long, ByVal Width_ As Long, ByRef sText As USTRING) Export
	Dim As long Ptr iArray = GetProp(GadgetID(gadget),"STATUSBARARRAY")
	Dim As Integer iNfields = Cast(Integer,GetProp(GadgetID(gadget),"STATUSBARNUMBERFIELDS"))
	
	If iArray = 0 Then
		iArray = Allocate(250)
		if iArray then
			SetProp(GadgetID(gadget),"STATUSBARARRAY",iArray)
			SetProp(GadgetID(gadget),"STATUSBARNUMBERFIELDS",Cast(HANDLE,1))
			iNfields = 1
		endif
	Else
		If NField+1>iNfields Then
			iNfields+=1
		EndIf
		SetProp(GadgetID(gadget),"STATUSBARNUMBERFIELDS",Cast(Integer Ptr,iNfields))
	EndIf
	
	if iArray then
		*(iArray+NField) = Width_
		SendMessage(GadgetID(gadget), SB_SETPARTS,Cast(WPARAM,iNfields), Cast(lparam,iArray))
		#ifdef UNICODE
			SendMessage(GadgetID(gadget), SB_SETTEXT ,CInt(NField), Cast(LPARAM,*sText))
		#else	
			SendMessage(GadgetID(gadget), SB_SETTEXT ,CInt(NField), Cast(LPARAM,StrPtr(sText)))
		#EndIf
	endif	
End Sub
