#include once "window9.bi"

Dim Shared As CHOOSECOLORA g_cc

Function ColorRequester(ByVal rgbCurrentUSER As Integer=0, _
				ByVal flag As Integer=2, ByVal hWin As HWND=0) As COLORREF Export
	Static acrCustClr(16) As COLORREF
	Static rgbCurrent As Integer
	If rgbCurrentUSER<>0 Then rgbCurrent=rgbCurrentUSER
	ZeroMemory(Cast(PVOID,@g_cc), Cast(DWORD,SizeOf(CHOOSECOLORA)))
	g_cc.lStructSize = sizeof(CHOOSECOLORA)
	g_cc.hwndOwner = hWin
	g_cc.lpCustColors = @acrCustClr(0)
	g_cc.rgbResult = rgbCurrent
	g_cc.Flags = 1 Or flag
	if ChooseColor(Cast(LPCHOOSECOLOR,@g_cc))=1 Then
		rgbCurrent=g_cc.rgbResult
		Return g_cc.rgbResult
	Else
			Return rgbCurrentUSER
	End If
End Function
