#Include once "window9.bi"
#if 0
Type charformat
	As integer     cbSize
	As Integer     dwMask
	As Integer     dwEffects
	As Integer     yHeight
	As integer     yOffset
	As COLORREF    crTextColor
	As BYTE        bCharSet
	As BYTE        bPitchAndFamily
	As String*32   szFaceName
End Type
#endif
Dim Shared  Cf As CHARFORMAT

Function DSGC(ByVal gadget As HWND,ByVal COLBND As integer,ByVal COLText As Integer,ByVal flag As byte) As byte Export
	Dim fbgui77 As String  = GetClassName_(gadget)
	Select Case fbgui77
		Case "RichEdit20A"
			Select Case flag
				Case 2
					cf.cbSize=SizeOf(cf)
					cf.dwMask=1073741824
					cf.crTextColor= COLText
					SendMessage(gadget , WM_USER + 68,4, Cast(LPARAM,@cf))
				Case 1
					SendMessage(Gadget, WM_USER + 67, 0,COLBND)
				Case 3
					cf.cbSize=SizeOf(cf)
					cf.dwMask=1073741824
					cf.crTextColor= COLText
					SendMessage(gadget , WM_USER + 68,4, Cast(LPARAM,@cf))
					SendMessage(Gadget, WM_USER + 67, 0,COLBND)
			End Select
			Return 1
		Case "tooltips_class32"
			Select Case flag
				Case 1
					SendMessage(gadget,WM_USER+19,COLBND,0)
				Case 2
					SendMessage(gadget,WM_USER+20,COLText,0)
				Case 3
					SendMessage(gadget,WM_USER+19,COLBND,0)
					SendMessage(gadget,WM_USER+20,COLText,0)
			End Select
			Return 1
		Case "ComboBox"
			COOLOOR(COLBND ,COLText)
			Return 3
		Case "SysTreeView32"
			Select Case flag
				Case 1
					SendMessage(gadget,4381,0,cast(LPARAM,COLBND))
				Case 2
					SendMessage(gadget,4382,0,cast(LPARAM,COLText))
				Case 3
					SendMessage(gadget,4381,0,cast(LPARAM,COLBND))
					SendMessage(gadget,4382,0,cast(LPARAM,COLText))
			End Select
			Return 1
		Case "SysListView32"
			Select Case flag
				Case 1
					SendMessage(gadget,LVM_SETBKCOLOR,0,COLBND)
					SendMessage(gadget,LVM_SETTEXTBKCOLOR,0,COLBND)
				Case 2
					SendMessage(gadget,LVM_SETTEXTCOLOR ,0,COLText)
				Case 3
					SendMessage(gadget,LVM_SETBKCOLOR ,0,COLBND)
					SendMessage(gadget,LVM_SETTEXTBKCOLOR,0,COLBND)
					SendMessage(gadget,LVM_SETTEXTCOLOR ,0,COLText)
			End Select
			Return 1
			'  result=FBIDLISTBOX
			'Case "SysTabControl32"
			'  result=FBIDTABBERBOX
			'Case "msctls_trackbar32"
			'  result=FBIDTRACKBAR
		Case "ScrollBar"
			COOLOOR(COLBND ,COLText)
			Return 2
			'  result=FBIDSCROLLBAR
		Case "msctls_progress32"
			Select Case flag
				Case 1
					SendMessage(gadget,8193,0,COLBND)
				Case 2
					SendMessage(gadget,1033 ,0,COLText)
				Case 3
					SendMessage(gadget,8193 ,0,COLBND)
					SendMessage(gadget,1033 ,0,COLText)
			End Select
		Case "msctls_statusbar32"
			SendMessage(gadget,&h2001,0,COLBND)
		Case "Static"
			InvalidateRect(gadget,0,1)
		Case "ExplorerGadget"
			dim hwndEG as HWND = *cast(HWND ptr,GetProp(gadget,"addparam60000"))
			Select Case flag
				Case 1
					SendMessage(hwndEG,LVM_SETBKCOLOR,0,COLBND)
					SendMessage(hwndEG,LVM_SETTEXTBKCOLOR,0,COLBND)
				Case 2
					SendMessage(hwndEG,LVM_SETTEXTCOLOR ,0,COLText)
				Case 3
					SendMessage(hwndEG,LVM_SETBKCOLOR ,0,COLBND)
					SendMessage(hwndEG,LVM_SETTEXTBKCOLOR,0,COLBND)
					SendMessage(hwndEG,LVM_SETTEXTCOLOR ,0,COLText)
			End Select
			Return 4
	End Select
	If Mid(fbgui77,1,11)="CLASSCLASS_" Or Mid(fbgui77,1,9)="Container" Then
		WindowColor(gadget,COLBND)
	EndIf
	Return 0
End Function
