ENUM font type does not work?

 

I did some search work, and the following code works with CButton font type:

   string FontType = "Calibri Bold"; 

   alertbutton.Font(FontType);

However, my effort to make it an enum list failed:

enum fonts
  {
   fntArial,               // Arial
   Calibri Bold
  };            
extern fonts FontType;     

alertbutton.Font(FontType);

And this problem is not related to the spacebar before "Bold" - a list without any space still fails.

Could anyone please give me a hand?

Documentation on MQL5: Standard Library / Panels and Dialogs / CButton
Documentation on MQL5: Standard Library / Panels and Dialogs / CButton
  • www.mql5.com
CButton - Panels and Dialogs - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
joshatt:

And this problem is not related to the spacebar before "Bold" - a list without any space still fails.

Could anyone please give me a hand?

How about this code?

enum fonts
  {
   fntArial,               // Arial
   fntCalibriBold          // Calibri Bold
  };            
extern fonts FontType = fntCalibriBold;

string fontname[] = {"Arial", "Calibri Bold"};     

alertbutton.Font(fontname[FontType]);
 
Nagisa Unada:

How about this code?

Marvellous! This helps me understand ENUM deeper. You saved my day. Thanks a lot!

Reason: