Well, yes you can, but the problem is *keeping* it's color changed. Here's the method to change the color, but it will change itself back to white if any of the following occur:
1: Box is checked or unchecked. In this case, it's easy enough to run the code in the check event for the checkbox, so that the color changes back to what you want.
2: Form is covered by another window and then uncovered. This is a little more difficult to fix. Probably could use a timer set for a fairly small interval to just keep changing the color back to what you want.
Anyway, you'll need the following in your declaration section:
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
OK, put this code wherever you want to change the color. Note that QBColor(9) is dark blue. Choose the value for the color you want.
Also note that, depending on your checkbox size, that the second and third values in the ExtFloodFill line may need to be changed. these two numbers are the X and Y position, in pixels, that are located *inside* the white square of the checkbox. There's probably a way to figure this mathmatically, based on the height/width of the box, but I didn't bother and just hard coded them in my test.
Of course, anywhere it says "check1" you need to substitute the control name of your checkbox.
Dim CboxDC As Long
Dim hBrush As Long
Dim oldBrush As Long
hBrush = CreateSolidBrush(QBColor(9))
CboxDC = GetDC(Check1.hwnd)
oldBrush = SelectObject(CboxDC, hBrush)
Call ExtFloodFill(CboxDC, 3, 13, vbWhite, 1)
Call SelectObject(CboxDC, oldBrush)
ReleaseDC Check1.hwnd, CboxDC
DeleteObject hBrush
And that's it.
Depending on what you want to do with this, it may just be easier to make your own activeX control that supports a property that lets you set the color of the box.
Hope this helps,
Robert