Results 1 to 4 of 4

Thread: Changing the background color of a checkbox

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Question

    Does anybody out there know how to change the background of the check portion of a checkbox (not the caption portion, which can easily be done with the BackColor property)? I suspect that this must be done with the API. Thanks.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I wouldn't be surprised if this doesn't work, especially if there's no childwnd in the checkbox. if there is you could use
    Code:
    Declare Function SetBkColor Lib "gdi32" Alias "SetBkColor" (ByVal hdc As Long, ByVal crColor As Long) As Long
    on it. I'll have a look on it later
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I appreciate your speedy reply, kedaman, but unfortunately, your hunch was right, and the function did not work (unless I did something wrong). I put a checkbox and a command button on a form. I did a Private Declare with the API function you recommended, then in the Command1_Click event, I put:

    Dim L as Long
    L = SetBkColor(Check1.hWnd, vbButtonFace)

    When I ran it and clicked the button, nothing happened.

    If you come up with anything further, I'd be very grateful. Thanks again.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    ACtually it's the childwnd, which background should be changed, but there's no childwnd, so i can't help you furher, you could probably make your own active-X, a checkbox should be the easiest thing to do.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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