|
-
Jul 31st, 2006, 03:33 PM
#1
Thread Starter
Hyperactive Member
Colours
Hi all,
I am working on this game... and I had two questions..
1) How do I chose random colours?
2) I have a label that I want to act as a command button. Dun worry about that.
What I want to do is... Each time the mouse is moved over the command button, I want the colour of the text to be inverted to that of the colour that was previously the forecolour of the label. And when the mouse is moved away from the label... I want the program to choose another random colour for the label. And the cycle continues.
Also... I have the background colour set to black... so is it possible that the program chooses random bright colours?
Thanx for your help in advance,
Khanjan
Hey... If you found this post helpful please rate it.

-
Jul 31st, 2006, 03:53 PM
#2
Re: Colours
ok, here's some code. You said you want bright colours, but it has to be inverted upon mouseover. Well if you invert a bright colour then you're going to get a dark colour...
VB Code:
Private Sub Form_Load()
Randomize
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = ((Label1.ForeColor Xor &HFF0000) And &HFF0000) + _
((Label1.ForeColor Xor &HFF00&) And &HFF00&) + _
((Label1.ForeColor Xor &HFF) And &HFF)
Label1.Drag vbBeginDrag
End Sub
Private Sub Label1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
If State = vbLeave Then
Label1.ForeColor = RGB(101 * Rnd + 155, 101 * Rnd + 155, 101 * Rnd + 155)
Label1.Drag vbEndDrag
End If
End Sub
Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
Debug.Print "Label1_Click"
End Sub
Then recreation of a mouseleave event for a label was taken from this post by JA. You'll also need the hand icon that JA includes (or another icon of your choice) to make sure it works properly (read his post)
-
Jul 31st, 2006, 03:59 PM
#3
Thread Starter
Hyperactive Member
Hey... If you found this post helpful please rate it.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|