Results 1 to 3 of 3

Thread: Colours

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    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.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    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:
    1. Private Sub Form_Load()
    2.     Randomize
    3. End Sub
    4.  
    5. Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6.     Label1.ForeColor = ((Label1.ForeColor Xor &HFF0000) And &HFF0000) + _
    7.                        ((Label1.ForeColor Xor &HFF00&) And &HFF00&) + _
    8.                        ((Label1.ForeColor Xor &HFF) And &HFF)
    9.     Label1.Drag vbBeginDrag
    10. End Sub
    11.  
    12. Private Sub Label1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    13.     If State = vbLeave Then
    14.         Label1.ForeColor = RGB(101 * Rnd + 155, 101 * Rnd + 155, 101 * Rnd + 155)
    15.         Label1.Drag vbEndDrag
    16.     End If
    17. End Sub
    18.  
    19. Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
    20.     Debug.Print "Label1_Click"
    21. 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)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: Colours

    Thanx a lot!!!

    Khanjan
    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
  •  



Click Here to Expand Forum to Full Width