PDA

Click to See Complete Forum and Search --> : Visual Basic Colors


deDogs
Nov 12th, 1999, 09:25 PM
MS Paint displays a pallet of solid colors where the user is able to point and click.
I have been trying to reproduce such in VB, but have had no success?
I have:
- Created a Box using the Line method and FillColor property.
- Used the Text control and its BackColor property to change colors.

When using a Text control and its BackColor property, I am able to view black, blue, green, cyan, red, magenta, yellow, white, gray, but when equating dark red (&H00008B), the text box isn't solid in looking rather 'pixelized'?

I have noticed when setting a Text box BackColor from its properties - the colors shown from its pallet isn't solid?

I would like to view colors as solid colors as MS pallet is shown.

Thank you,
deDogs

Compwiz
Nov 12th, 1999, 09:40 PM
Here, I made a 10 color palette for you:

Start with an empty form (you'll see why), with two labels: Label1(0) and Label2

Make sure that Label1 has an index of 0


Dim Colors(0 To 9)
Private Sub Form_Load()
Colors(0) = vbWhite
Colors(1) = vbRed
Colors(2) = vbBlue
Colors(3) = vbBlack
Colors(4) = vbGreen
Colors(5) = vbYellow
Colors(6) = vbCyan
Colors(7) = vbMagenta
Colors(8) = RGB(123, 123, 123)
Colors(9) = RGB(255, 123, 0)
Dim Num As Integer
Dim y As Long
With Label1(0)
.Width = 255
.BackColor = Colors(0)
y = .Width
.Left = 0
.Top = 0
End With
For Num = 1 To 9
Load Label1(Num)
With Label1(Num)
.BackColor = Colors(Num)
.Visible = True
.Width = 255
.Left = y
.Top = 1
End With
y = y + 255
Next Num
End Sub

Private Sub Label1_Click(Index As Integer)
Label2.BackColor = Colors(Index)
End Sub


When you click on a color, Label2's BackColor changes to the color selected.

------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer

deDogs
Nov 13th, 1999, 12:26 AM
Thank you Compwiz, but Colors(8) = RGB(123, 123, 123) and Colors(9) = RGB(255, 123, 0) when they are displayed in Label1, colored dots are also seen. They are not presented as a solid color? Why the colored dots?

I thank you for the help.

Thank you,
deDogs

Compwiz
Nov 13th, 1999, 12:37 AM
Well, on my screen, every thing is solid.

Although, I am running at:

1280x1024
with 16 bit colors.

deDogs
Nov 13th, 1999, 01:06 AM
Thank you Compwiz, but Colors(8) = RGB(123, 123, 123) and Colors(9) = RGB(255, 123, 0) when they are displayed in Label1, colored dots are also seen. They are not presented as a solid color? Why the colored dots?

I thank you for the help.

Thank you,
deDogs