Color Problems

cSuttle

New member
Local time
Today, 05:25
Joined
Dec 1, 2013
Messages
6
Ok, I'm confused. Check out this very simple code.

Private Sub TestButton_Click()
Dim bc As Long

bc = TestButton.BackColor
TestButton.BackColor = bc

End Sub

Somehow this changes the color of the button from light blue to a darker blue. Yes, this has no real purpose, but it is a test to see why be app. isn't working. And this is the problem. I store the color, but it back and it's not the same color.

Any ideas?
 
I post this because I like to highlight one more thing linked to your question. If someone will answer to this thread I think that will be a help for both of us.

Sometime I need to color an object at run time. So, in order to know the exact code color I tried this:
1) Switch the form in Design View
2) Copy (in Note Pad) the actual code color from the Property Sheet
3) Changed the color in form Design View (to what I need at run time)
4) Copy this new code color to my code
5) Restore the code color for the object (copy from Note Pad -> paste on the property sheet)

Step 5 always set the right color (the initial one)
But when I run the code, the new color for my object is something else. Frequently is far a way from the expected one (for me, I don't know for the code color).
 
Sounds like the same problem. I have experimented with a number of things. I always get some color, but not the one I want :-(
 
Here is an interesting update. If I work with the button directly in the form editing and switch the back style to "Transparent" and then back to "Normal" I get the same results as my code above. Another interest fact is it's always the same color just a darker shade. So blue, slightly darker blue, Red, slightly darker red.
 
I think I found the problem, but not the solution. There is a "hidden" attribute BackThemeColorIndex. If I look at the original button I get

backColor = 14136213
backThemeColorIndex = 4

With VBA if I set the color to 14136213, it automatically sets the ThemeColor to -1 (don't use). Then if I set the ThemeColor to 4, it changes the BackColor to 12419407, a different color. So either order I set them in it screws up the other.

So that appears to be the problem, but I can't figure out the solution.
 
Have you looked at this?

I just found it after reading your post -- hadn't heard of backThemeColorIndex and still don't know how /where it fits.

Yeah, saw that. It what made me investigate that property in the first place. I wonder how many other hidden properties there are.
 

Users who are viewing this thread

Back
Top Bottom