#Include Once "window9.bi"

Dim Shared tbBmp(0 To 14) As Byte = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}
Dim Shared tbAddBmp As TBADDBITMAP
Dim Shared tbb As TBBUTTON
Dim Shared ToolBarHWND As HWND

Function CreateToolBar(ByVal Style As Integer,ByVal Style1 As Integer,ByVal Style2 As Integer) As Integer Export
	Dim hwndToolBar As HWND=CreateWindowEx( Style2,TOOLBARCLASSNAME, 0,WS_CHILD Or WS_VISIBLE Or Style1,0, 0, 0, 0,Cast(HWND,GETGURRENTAL()),0,0,0)
	ToolBarHWND = hwndToolBar
	SendMessage( hwndToolBar, TB_BUTTONSTRUCTSIZE, Len( tbb ), 0 )
	tbAddBmp.hInst = HINST_COMMCTRL
	tbAddBmp.nID   =Style
	SendMessage( hwndToolBar, TB_ADDBITMAP, 0, CInt( @tbAddBmp ) )
	Return Cast(Integer,hwndToolBar)
End Function

Function ToolBarToolTip(ByVal Hwnd As Hwnd, ByVal buttonID As Integer,ByRef toolTipS_ As String) As Integer Export
	Return SetProp(Hwnd,Str(buttonID),StrPtr(toolTipS_))
End Function

Function ToolBarStandardButton(ByVal hwndToolBar As Integer,ByVal buttonID As Integer,ByVal IndexImage As Integer,ByVal String_ As String,ByVal IndexButton As Integer,ByVal Style As Integer,ByVal Style2 As Integer) As Integer Export
	With tbb
		.iBitmap   = tbBmp(Indeximage)
		.fsState   = style
		.fsStyle   =  style2
		.idCommand =  buttonID
		.dwData    = 0
		.iString = Cast(Integer,StrPtr(String_))
		Function=SendMessage( Cast(hwnd,hwndToolBar), TB_INSERTBUTTON, indexButton, CInt( @tbb ) )
	End With
	SendMessage(Cast(hwnd,hwndToolBar),TB_AUTOSIZE,0,0)
End Function

Function ToolBarSeparator(ByVal hwndToolBar As Integer,ByVal IndexButton As Integer) As Integer Export
	With tbb
		.iBitmap   = tbBmp(IndexButton)
		.fsState   = TBSTATE_ENABLED
		.fsStyle   = TBSTYLE_SEP
		.idCommand =  0
		.dwData    = 0
		.iString = 0
		Function=SendMessage(Cast(hwnd, hwndToolBar), TB_INSERTBUTTON,IndexButton , CInt( @tbb ) )
	End With
	SendMessage(Cast(hwnd,hwndToolBar),TB_AUTOSIZE,0,0)
End Function

Function ToolBarImageButton(ByVal hwndToolBar As Integer,ByVal buttonID As Integer,ByVal ImageID_ As Integer,ByVal String_ As String,ByVal IndexButton As Integer,ByVal Style As Integer,ByVal Style2 As Integer,ByVal SizeIcon As Integer) As Integer Export
	Dim As hImageList hImageList = GetProp(Cast(HWND,hwndToolBar),"HIMAGELISTTOOLBAR")
	If hImageList = 0 Then
		hImageList = ImageList_Create(SizeIcon,SizeIcon,ILC_COLOR32,1,1)
		SetProp(Cast(HWND,hwndToolBar),"HIMAGELISTTOOLBAR",hImageList)
		SendMessage(Cast(hwnd,hwndToolBar), TB_SETIMAGELIST, 0, Cast(LPARAM,hImageList))
	EndIf
	Dim As Integer ppoos=ImageList_Add(hImageList,Cast(hbitmap,ImageID_),0)
	With tbb
		.iBitmap= ppoos
		.fsState   = style
		.fsStyle   = style2
		.idCommand =  buttonID
		.dwData    = 0
		.iString = Cast(Integer,StrPtr(String_))
	End With
	Return SendMessage( Cast(hwnd,hwndToolBar), TB_INSERTBUTTON,IndexButton , CInt( @tbb ) )
	SendMessage(Cast(hwnd,hwndToolBar),TB_AUTOSIZE,0,0)
End Function