Wrong color

mevets

Member
Joined
Jun 22, 2006
Messages
17
Location
Northern, VA
Programming Experience
Beginner
When I


Dim c as Color = btn.color

btn.color = color.red
btn.color = c


The color seems to be wrong. Is there a solution?
 
Oddly, that answers different question of mine.

My problem is that the color is not the gradient-color that all buttons have by default.
 
Dim c as Color = btn.color

btn.color = color.red
btn.color = c

Whats this bit of code supposed to be doing? You are dimensioning a variable as the type color and assigning it to the current color of your button. The middle line isn't doing anything at all, because in the last line you re-assign the color of your button to the variable you just created, which is the same color as the button is at the moment anyway??
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.BackColor = Button1.BackColor
End Sub
-----------
There was no point to the .red, it was simply there to show the color had to change for another reason which isn't really important. I wrote the code before on a PSP so it didn't really make sense. But the current code above will show how the color isnt as it was. Am I crazy?
 
Yes, i think you are a raving looney:) This thread has become somewhat confusing. To summarise, am i right in saying that you are trying to assign the buttons backcolor to the color that it already is??
 
I believe the color that mevets want to obtain is the color (actually gradient colors) used when the buttons are visually styled (with the WinXP style).
When a button is styled like that, the BackColor property is ignored and the drawings are handled an entirely different way. How I'm not sure.
 
Oh, i see.... Well the different versions of the comctl32.dll's that control the rendering for both the new and old styling can be accessed through the p/invoke GetUxTheme API, however i've not tried it and i don't know how far it extends. The rendering, as i understand it, takes place after the properties are set and the buttons region property is manipulated to only display the new styling. As for the color.... well you could get a fair idea using the GetPixel API function that returns the color of the pixel at the specified location.
 
Back
Top