
#Include "window9.bi"

Dim Shared As Integer hwnd,event
Sub WriteClipboard(byval Text As String, byval CPFormat As Integer = CF_TEXT, byref hWnd As HWND = NULL)
	Var hGlobalClip = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE, Len(Text)+1)
	OpenClipboard(hWnd)
	EmptyClipboard()
	Var lpMem = GlobalLock(hGlobalClip)
	CopyMemory(lpMem, Strptr(Text), Len(text))
	GlobalUnlock(lpMem)
	SetClipboardData(CPFormat, hGlobalClip)
	CloseClipboard()
End Sub
hwnd=OpenWindow("Color",10,10,135,150) : CenterWindow(hwnd):WindowColor(hwnd,&hACD2B6)
TextGadget(1,25,10,70,20,,SS_Center): SetGadgetColor(1,&hFF0000,&hFFFFFF,3)
ButtonGadget(2,10,80,100,20,"Copy")
ButtonGadget(3,10,50,100,20,"Other color")
SetGadgetText(1, "&h" & Hex(ColorRequester(,,hwnd)))
Do
	event=WindowEvent()
	If Event=EventClose Then End
	If Event=EventGadget Then
		If EventNumber=2 Then
			WriteClipboard(GetGadgetText(1))
		ElseIf	EventNumber=3 Then
			SetGadgetText(1, "&h" & Hex(ColorRequester(,,hwnd)))
		EndIf
	EndIf
Loop
