wxMenuItem colour change Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ruvindra
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon May 26, 2008 3:38 pm
Location: Colombo , Sri lanka
Contact:

wxMenuItem colour change

Post by ruvindra » Wed Jun 04, 2008 3:07 pm

I Created a wxMenuItem and want to set a background colour for it.

So I used the following code lines

wxMenuItem* item = menuFile->Append(ID_CONTROLLER,s);
item->SetBackgroundColour(wxColour(0,0,0));

The s is the name of the menu item.

But the menu Item colour does not change when I run this.

Any reason for this unusual Behaviour?
Range

Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank » Wed Jun 04, 2008 3:41 pm

Are you on windows? This is working on windows only.

ruvindra
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon May 26, 2008 3:38 pm
Location: Colombo , Sri lanka
Contact:

Post by ruvindra » Wed Jun 04, 2008 3:46 pm

Yes I am on Windows.
Range

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4535
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN » Wed Jun 04, 2008 3:50 pm

What version of Windows and wx?

Thank you.

ruvindra
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon May 26, 2008 3:38 pm
Location: Colombo , Sri lanka
Contact:

Post by ruvindra » Wed Jun 04, 2008 3:53 pm

I am in Windows XP Service Pack 2 and wxWidgets 2.8.7
Range

Grrr
Earned some good credits
Earned some good credits
Posts: 126
Joined: Fri Apr 11, 2008 8:48 am
Location: Netherlands

Post by Grrr » Thu Jun 05, 2008 8:25 am

You must set the background color before appending the menu item, like this:

Code: Select all

wxMenu *toolsMenu = new wxMenu();
wxMenuItem *optionsItem = new wxMenuItem(toolsMenu, ID_OPTIONS, _T("&Options..."));
optionsItem->SetBackgroundColour(wxColour(255, 128, 64));
toolsMenu->Append(optionsItem);
I have noticed that some menu properties only work when they are set BEFORE the item is added to the menu.

Maybe you need to call some update function to make changes active if you set properties afterwards. Maybe it is just not possible. Anyways many of these things are not portable, as they work on Windows only.

ruvindra
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon May 26, 2008 3:38 pm
Location: Colombo , Sri lanka
Contact:

Post by ruvindra » Thu Jun 05, 2008 9:18 am

Hi Grrr,

Thanks Grrr. It worked as you told. Again thanks
Range

Grrr
Earned some good credits
Earned some good credits
Posts: 126
Joined: Fri Apr 11, 2008 8:48 am
Location: Netherlands

Post by Grrr » Thu Jun 05, 2008 10:54 am

Please mark the topic as answered so other people know they can find answered questions here.

Post Reply