Adding static text to wxMenuBar

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
Experienced Solver
Experienced Solver
Posts: 75
Joined: Thu Jul 25, 2019 12:31 pm

Adding static text to wxMenuBar

Post by Ksawery » Sun Jun 07, 2020 10:53 am


I'm developing an application with a top menu bar, along with some drop-down menus. This works fine, however I'd also like to use a part of the menu bar (ideally the top right corner) to display the system time. Is there any way to display (and periodically update) a wxStaticText, or some equivalent class, in the top menu bar?

Here is a screenshot of a portion of the application window:

Screenshot from 2020-06-07 12-50-46.png
Screenshot from 2020-06-07 12-50-46.png (21.55 KiB) Viewed 197 times

Edit: so far I've managed to add another menu to the menu bar, disable it, and update the string as follows:

Code: Select all

	mMenuBar->EnableTop(2, false);
	mMenuBar->SetMenuLabel(2, wxString("12:00:01"));
It works, but its not the best solution. The clock is grayed out and isn't clearly visible. Ideally, i'd like to place it in the right corner of the menu bar. Any other solutions would be appreciated.

Screenshot from 2020-06-07 13-14-06.png
Screenshot from 2020-06-07 13-14-06.png (18.33 KiB) Viewed 193 times

Many thanks,

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

Re: Adding static text to wxMenuBar

Post by ONEEYEMAN » Sun Jun 07, 2020 4:34 pm

I don't think its possible.
Menu bar is just that - menu bar.
You can try to dive into the wxAUI and see if that possible. Or you can try to see if generic meu bar will let you do that.

Or another possibility - use wxWindow instead of wxMenuBar. But then you will need to handle everything yourself.

Thank you.

Post Reply