CREATE CPick_Form AS QFORM
FormStyle = fsStayOnTop
BorderStyle = bsDialog
CAPTION = "Color Picker"
Height = 340
Width = 338
BorderStyle = bsDialog
KeyPreview = True
OnKeyPress = CPick_Form_KeyPress
CREATE CPick_ScrollRed AS QSCROLLBAR
Left = 50
Top = 20
Width = 255
Height = 18
Min = 0
Max = 255
Smallchange = 1
Largechange = 5
ShowHint = True
Hint = "Red Attribute"
OnChange = CPick_ColorChange
END CREATE
CREATE CPick_ScrollGreen AS QSCROLLBAR
Left = 50
Top = 50
Width = 255
Height = 18
Min = 0
Max = 255
Smallchange = 1
Largechange = 5
ShowHint = True
Hint = "Green Attribute"
OnChange = CPick_ColorChange
END CREATE
CREATE CPick_ScrollBlue AS QSCROLLBAR
Left = 50
Top = 80
Width = 255
Height = 18
Min = 0
Max = 255
Smallchange = 1
Largechange = 5
ShowHint = True
Hint = "Blue Attribute"
OnChange = CPick_ColorChange
END CREATE
CREATE CPick_LabelRed AS QLABEL
Left = 8
Top = 22
CAPTION = "Red:"
END CREATE
CREATE CPick_LabelGreen AS QLABEL
Left = 7
Top = 52
CAPTION = "Green:"
END CREATE
CREATE CPick_LabelBlue AS QLABEL
Left = 8
Top = 82
CAPTION = "Blue:"
END CREATE
CREATE CPick_Group AS QGROUPBOX
CAPTION = "Chosen Color
Top = 110
Left = 8
Height = 68
Width = 255
CREATE CPick_PaintBox AS QLABEL
Enabled = False
Left = 10
Top = 18
Height = 42
Width = 235
Color = &H000000
Transparent = False
END CREATE
END CREATE
CREATE CPick_Dialog AS QBUTTON
Caption = ">"
Left = CPick_Group.Left + CPick_Group.Width + 10
Top = CPick_Group.Top + 18
Height = 28
Width = 32
OnClick = CPick_ColorDialog
END CREATE
CREATE CPick_RGBValue AS QLABEL
Left = 8
Top = 190
Caption = "RGB Value:"
END CREATE
CREATE CPick_Value AS QLABEL
Left = 8
Top = 215
Caption = "Value decimal:"
END CREATE
CREATE CPick_Value2 AS QLABEL
Left = 8
Top = 240
Caption = "Value hexidecimal:"
END CREATE
CREATE CPick_RGBVal AS QLABEL
Left = 150
Top = 190
Caption = "(0,0,0)"
END CREATE
CREATE CPick_DecVal AS QLABEL
Left = 150
Top = 215
Width = 100
Caption = ""0
END CREATE
CREATE CPick_HexVal AS QLABEL
Left = 150
Top = 240
Width = 100
Caption = ""000000
END CREATE
CREATE CPick_Copy0 AS QCOOLBTN
Left = 260
Top = 190
BMPHandle = Paste_BMP
Flat = True
Hint = "Insert into "text
ShowHint = True
OnClick = CPick_InsertText0
END CREATE
CREATE CPick_Copy1 AS QCOOLBTN
Left = 260
Top = 215
BMPHandle = Paste_BMP
Flat = True
Hint = "Insert into "text
ShowHint = True
OnClick = CPick_InsertText1
END CREATE
CREATE CPick_Copy2 AS QCOOLBTN
Left = 260
Top = 240
BMPHandle = Paste_BMP
Flat = True
Hint = "Insert into "text
ShowHint = True
OnClick = CPick_InsertText2
END CREATE
CREATE CPick_Normal AS QCOOLBTN
Left = 20
Top = 270
Width = 110
Caption = "All "colors
Groupindex = 1
Down = True
OnClick = CPick_Normalclick
END CREATE
CREATE CPick_Websafe AS QCOOLBTN
Left = 150
Top = 270
Width = 110
Caption = "Web safe "colors
Groupindex = 1
OnClick = CPick_Websafeclick
END CREATE
END CREATE
SUB CPick_Paint
DEFSTR Hred, Hgreen, Hblue
CPick_PaintBox.Color = RGB(CPick_ScrollRed.Position, CPick_ScrollGreen.Position, CPick_ScrollBlue.Position)
CPick_RGBVal.Caption = "( "+STR$(CPick_ScrollRed.Position)+", "+STR$(CPick_ScrollGreen.Position)+", "+STR$(CPick_ScrollBlue.Position)+" )"
CPick_DecVal.Caption = STR$(RGB(CPick_ScrollRed.Position, CPick_ScrollGreen.Position, CPick_ScrollBlue.Position))
IF CPick_ScrollBlue.Position < 16 THEN
Hblue = ""0 + CONVBASE$(STR$(CPick_ScrollBlue.Position), 10, 16)
ELSE
Hblue = CONVBASE$(STR$(CPick_ScrollBlue.Position),10,16)
END IF
IF CPick_ScrollGreen.Position < 16 THEN
Hgreen = ""0 + CONVBASE$(STR$(CPick_ScrollGreen.Position),10,16)
ELSE
Hgreen = CONVBASE$(STR$(CPick_ScrollGreen.Position),10,16)
END IF
IF CPick_ScrollRed.Position < 16 THEN
Hred = ""0 + CONVBASE$(STR$(CPick_ScrollRed.Position),10,16)
ELSE
Hred = CONVBASE$(STR$(CPick_ScrollRed.Position),10,16)
END IF
IF CPick_ScrollBlue.Position = 0 THEN Hblue = ""00 END IF
IF CPick_ScrollGreen.Position = 0 THEN Hgreen = ""00 END IF
IF CPick_ScrollRed.Position = 0 THEN Hred = ""00 END IF
CPick_HexVal.Caption = Hblue + Hgreen + Hred
END SUB
SUB CPick_ColorChange
' CPick_LabelNum1.Caption = STR$(CPick_ScrollRed.Position)
' CPick_LabelNum2.Caption = STR$(CPick_ScrollGreen.Position)
' CPick_LabelNum3.Caption = STR$(CPick_ScrollBlue.Position)
CPick_Paint
END SUB
SUB CPick_Normalclick
CPick_ScrollRed.Largechange = 5
CPick_ScrollRed.Smallchange = 1
CPick_ScrollGreen.Largechange = 5
CPick_ScrollGreen.Smallchange = 1
CPick_ScrollBlue.Largechange = 5
CPick_ScrollBlue.Smallchange = 1
END SUB
SUB CPick_Websafeclick
CPick_ScrollRed.Largechange = 51
CPick_ScrollRed.Smallchange = 51
CPick_ScrollGreen.Largechange = 51
CPick_ScrollGreen.Smallchange = 51
CPick_ScrollBlue.Largechange = 51
CPick_ScrollBlue.Smallchange = 51
CPick_ScrollRed.Position = ROUND((CPick_ScrollRed.Position)/51)*51
CPick_ScrollGreen.Position = ROUND((CPick_ScrollGreen.Position)/51)*51
CPick_ScrollBlue.Position = ROUND((CPick_ScrollBlue.Position)/51)*51
CPick_ColorChange
END SUB
SUB CPick_InsertText0
re.AddStrings(""RGB + CPick_RGBVal.Caption)
END SUB
SUB CPick_InsertText1
re.AddStrings(CPick_DecVal.Caption)
END SUB
SUB CPick_InsertText2
re.AddStrings("&"H + CPick_HexVal.Caption)
END SUB
SUB CPick_ColorDialog
IDE_ColorSelector.Style = cdFullOpen
IDE_ColorSelector.Top = CPick_Dialog.Top
IDE_ColorSelector.Left = CPick_Dialog.Left + CPick_Dialog.Width + 32
IDE_ColorSelector.Color = CPick_PaintBox.Color
IF IDE_ColorSelector.Execute THEN
CPick_ScrollRed.Position = (IDE_ColorSelector.Color AND &HFF)
CPick_ScrollGreen.Position = ((IDE_ColorSelector.Color AND &HFF00) SHR 8)
CPick_ScrollBlue.Position = ((IDE_ColorSelector.Color AND &HFF0000) SHR 16)
END IF
END SUB
SUB ColorPicker_Show
CPick_Form.ShowModal
END SUB
SUB CPick_Form_KeyPress(Key AS BYTE)
IF Key = 27 THEN CPick_Form.Close
END SUB
|