Results 1 to 8 of 8

Thread: changing forecolor of command btn

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    35

    Exclamation

    Does anyone know how I can change the color of the text inside the command button from black to white. Thanks!!!

  2. #2
    Junior Member
    Join Date
    Nov 2000
    Posts
    30
    This is a lot of **** about changing the colors, but i didnt feel like cutting it down for you to get just white. here it is:

    To a form, add a control array of VB Checkbox buttons (cmdChk(0) through cmdChk(9)) and a control array of option buttons (option1(0) through option1(9)), as well as an exit button (cmdEnd). Set the Style property of all check box buttons to 1-Graphical, and add any images, if desired. Add the following code:

    --------------------------------------------------------------------------------


    Option Explicit
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Copyright ©1996-2000 VBnet, Randy Birch, All Rights Reserved.
    ' Some pages may also contain other copyrights by the author.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' You are free to use this code within your own applications,
    ' but you are expressly forbidden from selling or otherwise
    ' distributing this source code without prior written consent.
    ' This includes both posting free demo projects made from this
    ' code as well as reproducing the code in text or html format.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    'non-vb colours
    Const vbDarkRed = &H90&
    Const vbDarkBlue = &H900000

    'consts for the cmdChk button control array
    Const nDefault = 0
    Const nRed = 1
    Const nGreen = 2
    Const nBlue = 3
    Const nYellow = 4
    Const nMagenta = 5
    Const nCyan = 6
    Const nWhite = 7
    Const nDkRed = 8
    Const nDkBlue = 9


    Private Sub Form_Load()

    'create the coloured buttons
    cmdChk(nRed).Forecolor = vbRed
    cmdChk(nGreen).Forecolor = vbGreen
    cmdChk(nBlue).Forecolor = vbBlue
    cmdChk(nYellow).Forecolor = vbYellow
    cmdChk(nMagenta).Forecolor = vbMagenta
    cmdChk(nCyan).Forecolor = vbCyan
    cmdChk(nWhite).Forecolor = vbWhite
    cmdChk(nDkRed).Forecolor = vbDarkRed
    cmdChk(nDkBlue).Forecolor = vbDarkBlue

    'set the default backcolour
    Option1(0).Value = True

    End Sub


    Private Sub cmdChk_Click(Index As Integer)


    'when the click event occurs, which normally
    'makes the check button toggle its
    'presses/unpressed state, mimic the
    'action of a standard command button by
    'canceling the pressed state.
    If cmdChk(Index).Value = vbChecked Then

    cmdChk(Index).Value = vbUnchecked

    'Button is back to 'normal', so
    'place your action code here....

    End If

    End Sub


    Private Sub cmdEnd_Click()

    Unload Me

    End Sub


    Private Sub Option1_Click(Index As Integer)

    Dim clrref As Long

    Select Case Index
    Case 0: clrref = vbButtonFace
    Case 1: clrref = vbApplicationWorkspace
    Case 2: clrref = vbBlack
    Case 3: clrref = vbWhite
    Case 4: clrref = vbRed
    Case 5: clrref = vbGreen
    Case 6: clrref = &H900000
    Case 7: clrref = vbCyan
    Case 8: clrref = vbMagenta
    Case 9: clrref = vbYellow

    End Select

    cmdChk(nRed).BackColor = clrref
    cmdChk(nGreen).BackColor = clrref
    cmdChk(nBlue).BackColor = clrref
    cmdChk(nYellow).BackColor = clrref
    cmdChk(nMagenta).BackColor = clrref
    cmdChk(nCyan).BackColor = clrref
    cmdChk(nWhite).BackColor = clrref
    cmdChk(nDkRed).BackColor = clrref
    cmdChk(nDkBlue).BackColor = clrref

    End Sub
    '--end block--'
    --> noware <--
    [email protected]

  3. #3
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303
    According to what people told me, you can NOT!
    Or at least Bill Gates does not want to have people
    do it with ease.

    What you can do is create your own image and then
    refer/place these buttons inside of your command
    button or something like that.

    What I did I just use the TEXT object as my command
    button. It is not as pretty, but it works with colors
    and highlight just similar to command buttons.


  4. #4
    Guest


    Basically, just place a Checkbox on the form and set it's Style to Graphical. Than you have yourself a Command Button where you can change the forecolor.

  5. #5
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303

    What a wonderful discover, Mathew!

    Thanks for the tip. I tried and it works great!

    Are sure you are not related to Bill Gates?

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    No, he knows me. LOL
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    Addicted Member
    Join Date
    Nov 2000
    Posts
    217
    I tried the check box technique, but when it's clicked, it stays pressed, so I changed the value of the checkbox back to 0, and it repeats the click_even again..any ways around this??

  8. #8
    Addicted Member
    Join Date
    Mar 2000
    Location
    Gainesville, FL
    Posts
    131
    if check1.value = 1 then exit sub


    Easy! =)

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