I was trying to set the BackColor of my form in C++, and I a syntax error, to do with the 'FromArgb' statement, when using the code:
this->BackColor = gcnew Color::FromArgb(0,0,15);
What should I do?
I was trying to set the BackColor of my form in C++, and I a syntax error, to do with the 'FromArgb' statement, when using the code:
this->BackColor = gcnew Color::FromArgb(0,0,15);
What should I do?
You haven't given us enough context to answer, but I'll hazard a guess that FromArgb
is a function, not a type, in which case it doesn't make sense to new
(or gcnew
) it.
If that's the case, and assuming BackColor
is a Color
object and not a pointer, and that FromArgb
returns a Color
by value, then you want
this->BackColor = Color::FromArgb(0,0,15);
If that doesn't work, please let us know exactly what BackColor
and FromArgb
are.
Color is a public value class Color - hence gcnew is wrong. Also the number of arguments do not match:
public: static Color FromArgb(
unsigned char a,
unsigned char r,
unsigned char g,
unsigned char b)