wxColour set with int array?

时间:2019-04-16 22:44:19

标签: c++ wxwidgets

I want to pass an array to a wxColour element:

    int COLOUR_DEFAULT [4] = {0, 0, 100, 255};
    myelement->SetBackgroundColour(*COLOUR_DEFAULT);

But it does not work.

If I do:

    #define  COLOUR_DEFAULT         {100, 100, 100, 255}
    myelement->SetBackgroundColour(COLOUR_DEFAULT);

….it works. How can I make it work with the variable?

1 个答案:

答案 0 :(得分:1)

In WxWidgets, if you want to make a WxColour class, you must define the variable as

wxColour COLOUR_DEFAULT(0, 0, 100, 255);

You can not pass an integer array directly to a function expecting a WxColour parameter.

Now you can simply type the following (it is no longer a pointer, so the * is not needed):

myelement->SetBackgroundColour(COLOUR_DEFAULT);