What`s wrong with this code?
Posted: Tue Jan 01, 2008 10:31 pm
Code:
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 Double
lCustData AS LONG
lpfnHook AS LONG
lpTemplateName AS LONG
END TYPE
dim cc as TCHOOSECOLOR
`-- 16 of these custom colors, whatever you want...
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
DECLARE ChooseColorDlg as ChooseColorA of "COMDLG32"
cc AS LONG
Return AS LONG
end declare
dim colordlg as colordialog
object form3 as form
Caption = "Color Value"
Width = 400
Height = 225
color = &H0080FF80
object Edit1 AS EDIT
Text = ""
Left = 151
Top = 22
END object
object Label1 As LABEL
Caption = " Decimal"
Top = 2
Left = 158
END object
object Label2 As LABEL
Caption = " Hexdecimal"
Top = 52
Left = 158
END object
object Edit2 AS EDIT
Text = ""
Left = 151
Top = 72
END object
object button1 as button
Caption = "Choose color "
Left = 5
Top = 10
Width = 100
TabOrder = 0
onclick=buttonClick
end object
END object
form3.ShowModal
SUB ButtonClick()
colordlg.show
DIM ReturnVal AS LONG
dim Hex1 as double
dim Hex2 as string
` cc.lStructSize = CC
` cc.hWndOwner = Form3.Handle
` CC.Flags = CC_RGBINIT + CC_FULLOPEN
`cc.rgbResult = Form3.Color
` ReturnVal = ChooseColorDlg(cc)
`-- rgbResult is in BGR format, so no conversion is necessary.
IF ReturnVal <> 0 THEN Form3.Color = CC.rgbResult
Edit1.text = Str$(CC.rgbResult)
Hex1 = Val(Edit1.text)
Hex2 = HEX$(Hex1)
Edit2.text = "&H" + Hex2
END SUB
:o
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 Double
lCustData AS LONG
lpfnHook AS LONG
lpTemplateName AS LONG
END TYPE
dim cc as TCHOOSECOLOR
`-- 16 of these custom colors, whatever you want...
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
DECLARE ChooseColorDlg as ChooseColorA of "COMDLG32"
cc AS LONG
Return AS LONG
end declare
dim colordlg as colordialog
object form3 as form
Caption = "Color Value"
Width = 400
Height = 225
color = &H0080FF80
object Edit1 AS EDIT
Text = ""
Left = 151
Top = 22
END object
object Label1 As LABEL
Caption = " Decimal"
Top = 2
Left = 158
END object
object Label2 As LABEL
Caption = " Hexdecimal"
Top = 52
Left = 158
END object
object Edit2 AS EDIT
Text = ""
Left = 151
Top = 72
END object
object button1 as button
Caption = "Choose color "
Left = 5
Top = 10
Width = 100
TabOrder = 0
onclick=buttonClick
end object
END object
form3.ShowModal
SUB ButtonClick()
colordlg.show
DIM ReturnVal AS LONG
dim Hex1 as double
dim Hex2 as string
` cc.lStructSize = CC
` cc.hWndOwner = Form3.Handle
` CC.Flags = CC_RGBINIT + CC_FULLOPEN
`cc.rgbResult = Form3.Color
` ReturnVal = ChooseColorDlg(cc)
`-- rgbResult is in BGR format, so no conversion is necessary.
IF ReturnVal <> 0 THEN Form3.Color = CC.rgbResult
Edit1.text = Str$(CC.rgbResult)
Hex1 = Val(Edit1.text)
Hex2 = HEX$(Hex1)
Edit2.text = "&H" + Hex2
END SUB
:o