0

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?

Praetorian
  • 106,671
  • 19
  • 240
  • 328
Joe
  • 104
  • 1
  • 13

2 Answers2

0

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.

Mike Seymour
  • 249,747
  • 28
  • 448
  • 644
0

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)