QScrollBar Examples
' Color Palette for Rapid-Q by William Yu
DECLARE SUB ColorChange
DECLARE SUB Paint
CONST False = 0
CONST True = NOT False
'' Here's something that will convert your standard RGB to Rapid-Q's BGR.
'' And quite useless because an RGB function is already implemented!
FUNCTION ConvertRGB(R AS INTEGER, G AS INTEGER, B AS INTEGER) AS INTEGER
ConvertRGB = (B SHL 16) OR (G SHL 8) OR R
END FUNCTION
CREATE Form AS QForm
CREATE LabelRed AS QLabel
Left = 10
Top = 22
Caption = "Red:"
END CREATE
CREATE LabelGreen AS QLabel
Left = 5
Top = 52
Caption = "Green:"
END CREATE
CREATE LabelBlue AS QLabel
Left = 10
Top = 82
Caption = "Blue:"
END CREATE
CREATE LabelNum1 AS QLabel
Left = 270
Top = 22
Caption = "0"
END CREATE
CREATE LabelNum2 AS QLabel
Left = 270
Top = 52
Caption = "0"
END CREATE
CREATE LabelNum3 AS QLabel
Left = 270
Top = 82
Caption = "0"
END CREATE
CREATE ScrollRed AS QScrollBar
Left = 50
Top = 20
Width = 200
Height = 20
Min = 0: Max = 255
ShowHint = True
Hint = "Red Attribute"
OnChange = ColorChange
END CREATE
CREATE ScrollGreen AS QScrollBar
Left = 50
Top = 50
Width = 200
Height = 20
Min = 0: Max = 255
ShowHint = True
Hint = "Green Attribute"
OnChange = ColorChange
END CREATE
CREATE ScrollBlue AS QScrollBar
Left = 50
Top = 80
Width = 200
Height = 20
Min = 0: Max = 255
ShowHint = True
Hint = "Blue Attribute"
OnChange = ColorChange
END CREATE
CREATE PaintBox AS QCanvas
Left = 50
Top = 110
Height = 90
Width = 200
OnPaint = Paint
END CREATE
Caption = "Color Palette"
Center
ShowModal
END CREATE
SUB ColorChange
LabelNum1.Caption = STR$(ScrollRed.Position)
LabelNum2.Caption = STR$(ScrollGreen.Position)
LabelNum3.Caption = STR$(ScrollBlue.Position)
Paint
END SUB
SUB Paint
PaintBox.Paint(0,0,ConvertRGB(ScrollRed.Position, ScrollGreen.Position, ScrollBlue.Position),&HFFFFFF)
END SUB