$TYPECHECK ON
CONST CC_RGBINIT = &H1
CONST CC_FULLOPEN = &H2
CONST CC_PREVENTFULLOPEN = &H4
CONST CC_SHOWHELP = &H8
CONST CC_ENABLEHOOK = &H10
CONST CC_ENABLETEMPLATE = &H20
CONST CC_ENABLETEMPLATEHANDLE = &H40
CONST CC_SOLIDCOLOR = &H80
CONST CC_ANYCOLOR = &H100
TYPE TCHOOSECOLOR
lStructSize AS LONG
hWndOwner AS LONG
hInstance AS LONG
rgbResult AS LONG
CustColors(1 TO 16) AS LONG
Flags AS DWORD
lCustData AS LONG
lpfnHook AS LONG
lpTemplateName AS LONG
END TYPE
DECLARE FUNCTION ChooseColorDlg LIB "COMDLG32" ALIAS "ChooseColorA" _
(CC AS TCHOOSECOLOR) AS LONG
CONST GWL_HWNDPARENT = -8
CONST HWND_DESKTOP = 0
DECLARE FUNCTION SetWindowLong LIB "user32" ALIAS "SetWindowLongA" (hwnd AS LONG, nIndex AS LONG, dwNewLong AS LONG) AS LONG
DECLARE SUB ButtonClick (Sender AS QBUTTON)
DIM CC AS TCHOOSECOLOR
CC.CustColors(1) = &HFF0000
CC.CustColors(2) = &H00FF00
CC.CustColors(3) = &H0000FF
CC.CustColors(4) = &HFF00FF
CC.CustColors(5) = &H00FFFF
CC.CustColors(6) = &HFFFFFF
CC.CustColors(7) = &H559911
CC.CustColors(8) = &HEE44BB
CC.CustColors(9) = &HBB44EE
CC.CustColors(10) = &H115599
CC.CustColors(11) = &H333333
CC.CustColors(12) = &H666666
CC.CustColors(13) = &H999999
CC.CustColors(14) = &HABABAB
CC.CustColors(15) = &HDDDDDD
CC.CustColors(16) = &H550000
CREATE Form AS QFORM
CAPTION="Choose color"
CREATE ed AS QRICHEDIT
height=20
END CREATE
CREATE Button AS QBUTTON
Width = 80
CAPTION = "Choose color"
OnClick = ButtonClick
left=ed.width
height=20
END CREATE
Center
width=button.width+ed.width+10
height=50
END CREATE
setwindowlong(form.handle, GWL_HWNDPARENT, HWND_DESKTOP)
setwindowlong(application.handle, GWL_HWNDPARENT, form.handle)
form.SHOWMODAL
SUB ButtonClick (Sender AS BUTTON)
DIM ReturnVal AS LONG
CC.lStructSize = SIZEOF(CC)
CC.hWndOwner = Form.Handle
CC.Flags = CC_RGBINIT +CC_FULLOPEN
CC.rgbResult = Form.COLOR
ReturnVal = ChooseColorDlg(CC)
IF ReturnVal <> 0 THEN ed.text="Color=&h"+RIGHT$(HEX$(cc.rgbresult),6)
ed.selstart=0
ed.sellength=LEN(ed.text)
ed.copytoclipboard
END SUB
|